codegen: fidelity gate reads the whole body; bound artifacts to engine ctx
The fidelity gate truncated the body to 4000 chars, so a body whose real
action sat after its helpers (the common shape) was judged on a prefix with
no action and wrongly returned `reconsider` -- a false reject that wasted a
rewrite and mislabeled a working skill. Live-engine probe: the truncated
state scored reconsider 0.96; the whole body scores accept 0.98.
- Fidelity gate: feed the whole body plus a deterministic operation
inventory and the de-identified goal; drop the raw request from the state
(a remote-engine PII path that added no signal). Ask the positive question
("is there a concrete operation that realizes the goal?") and give the gate
its own `codegen.fidelity.tau` instead of the run-assessment tau.
- Artifact size budget: a decision ingests a generated artifact whole, so
bound it. `parse_skill_body`/`parse_skill_test` reject an over-budget
artifact (`ArtifactTooLong`); the codegen retry ladder asks for a shorter
one. The ceiling derives from the active engine's context
(`DecisionEngine.context_tokens`: `engine.context_tokens` for the local
GGUF, `engine.winnow.context_tokens` for Winnow) minus
`codegen.decision_reserve_tokens`; `codegen.max_body_tokens` /
`max_test_tokens` override (separate limits).
- `codegen.operation_inventory()`: static HTTP-verb/path, CLI, mail, file,
and timer inventory, resolving the verb at the call site so a thin-helper
body's real endpoint is visible.
- Docs: AGENTS.md, README.md, CODEGEN.md, config.example.json.
- Tests: unit coverage for the budget, inventory, retry-shortening, and the
gate state; integration regression `test_fidelity_gate_reads_the_whole_body`
(real engine) guards the truncation bug.
This commit is contained in:
1 parent
1833932f1c
commit
9757ae893e
12 files changed
+527
-53
No files matched your search
@@ -52,6 +52,17 @@ class DecisionEngine(ABC):
|
||||
|
||||
label: str = "engine"
|
||||
|
||||
@property
|
||||
def context_tokens(self) -> int:
|
||||
"""The decision context window, in tokens.
|
||||
|
||||
Every decision state must fit inside it, so the scheduler sizes the
|
||||
generated skill bodies it feeds the fidelity gate from this value. A
|
||||
provider that does not expose its window keeps the conservative local
|
||||
default (the local 4B engine's `engine.context_tokens`).
|
||||
"""
|
||||
return 4096
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def loaded(self) -> bool:
|
||||
@@ -210,6 +221,10 @@ class SemIfEngine(DecisionEngine):
|
||||
self._model, self._tokenizer, self._metadata = model, tokenizer, metadata
|
||||
return model, tokenizer, metadata
|
||||
|
||||
@property
|
||||
def context_tokens(self) -> int:
|
||||
return int(self.config.context_tokens or 4096)
|
||||
|
||||
@property
|
||||
def loaded(self) -> bool:
|
||||
return self._model is not None
|
||||
|
||||
Reference in new issue
Block a user