feat(critic): Definition-of-Done gate chain + Finalize Critic (M3.5 /…#21
Merged
Conversation
… §4) Generalize the single structural-verify gate (M3.3) into a DoneGate chain run at the completion path: when the model stops calling tools, each gate must pass; the first failure injects a reflective user turn and the loop continues, bounded by ONE shared bounce budget. With a single gate this is byte-for-byte the old verify behavior (zero behavior change; M3.3 tests stay green). Add a second gate, the Finalize Critic: a read-only model call (no tools given, so read-only by construction; core cannot import the Agent tool, so a tool-less critic call is the layer-safe realization of the read-only verifier idea) that judges whether the final answer satisfies the root task. APPROVE completes; REJECT injects a reflective revise turn. It runs in its own child context (a single synthesized message), so it does not pollute the parent prefix until the reflection is appended (invariant #3). Gate order is verify-then-critic (fail-fast: no model call if it does not even compile). - core: QueryOptions.critic (CriticConfig), CriticEvent, gate-chain runner, createVerifyGate/createCriticGate, runCritic/parseCriticVerdict. - cli: myagent agent --critic [--critic-instructions "<text>"], [critic] event printing, help/usage text. - eval: new finalize-critic task (reject -> revise -> approve) on a separate scripted critic FakeModel; gate fingerprint updated to tasks=9 turns=19 in=13150 out=765. - docs: CLAUDE.md query-loop step 8 rewritten as the gate chain; roadmap M3.5 section + decisions anchored. 210 tests pass (+6 critic query tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… §4)
Generalize the single structural-verify gate (M3.3) into a DoneGate chain run at the completion path: when the model stops calling tools, each gate must pass; the first failure injects a reflective user turn and the loop continues, bounded by ONE shared bounce budget. With a single gate this is byte-for-byte the old verify behavior (zero behavior change; M3.3 tests stay green).
Add a second gate, the Finalize Critic: a read-only model call (no tools given, so read-only by construction; core cannot import the Agent tool, so a tool-less critic call is the layer-safe realization of the read-only verifier idea) that judges whether the final answer satisfies the root task. APPROVE completes; REJECT injects a reflective revise turn. It runs in its own child context (a single synthesized message), so it does not pollute the parent prefix until the reflection is appended (invariant #3). Gate order is verify-then-critic (fail-fast: no model call if it does not even compile).
210 tests pass (+6 critic query tests).