Expand description
Verify-before-finish gate (#2279): rejects a premature finish_task with
a recoverable retry when a named test command was never run.
Why: (bake-off L2 diagnosis) An engineer that never runs the visible,
prompt-named test suite can still call finish_task successfully today;
this module gives both the delegated engineer’s loop and the delegating
PM’s loop a turn-boundary hook to reject that specific case.
What: agent_loop::FinishGate constructors default_finish_gate (own
transcript) and pm_finish_gate (externally shared engineer transcript),
plus the pure names_test_command/is_test_command regex predicates
they share.
Test: verify_gate::tests::*.
Verify-before-finish gate (#2279): a recoverable retry, not a hard block,
that keeps a coding agent from calling finish_task before it has run a
test suite it was explicitly told about.
Why: (bake-off L2 diagnosis) tcode’s delegated engineer authored 81 tests
validating the wrong contract and never ran the visible, prompt-named
test suite the L2 challenge instructed it to run before submitting. The
task prompt and challenges/README.md (folded into project context)
named a runnable test command (pytest challenges/level-2-git-analyzer/ test_suite/ -v); the transcript never shows it being invoked. This
module is the structural fix: at the finish_task turn boundary
(agent_loop::AgentLoop::dispatch_all), if the task/project-context text
names a runnable test command AND no matching bash invocation appears
in the relevant transcript, finish_task is rejected with a recoverable
error — the SAME ToolResult::err retry path every other tool failure
uses — instead of terminating the loop. If no test command is named at
all, the gate is INERT: #2279 explicitly defers general polyglot
test-suite discovery (the “(b2)” follow-up) rather than inventing one
here.
What: [names_test_command] and [is_test_command] are pure,
independently unit-testable regex predicates — Improvement 2’s own
testability principle applied to its sibling Improvement 1. Two
agent_loop::FinishGate constructors build on them: [default_finish_gate]
scans a single loop’s OWN Transcript — what a delegated engineer’s
sub-agent loop attaches (runner::in_process::InProcessAgentRunner),
since its own bash calls land directly in that transcript.
[pm_finish_gate] is for the delegating PM’s loop, which never calls
bash itself — it scans the externally shared run_task::SharedTranscript
of TurnRecords the delegated engineer’s turns are recorded into
instead, via each record’s ran_test_command flag (set by
run_task::recorder::RecordingLlmClient using the SAME [is_test_command]
predicate this module owns, so the two paths can never independently
drift on what counts as a matching invocation).
Test: verify_gate::tests::*.
Functions§
- bash_
command_ from_ call - Extract the shell command from a
bashtool call’s arguments, ifcallnames thebashtool at all. - default_
finish_ gate - Build the default verify-before-finish gate: scans the SAME loop’s own transcript for both the trigger and the verification.
- is_
test_ command - Whether
command(abashtool call’s shell command) IS a matching test invocation (the gate’s VERIFY half). - names_
test_ command - Whether
texttextually names a runnable test command (the gate’s TRIGGER half). - pm_
finish_ gate - Build the delegating PM’s verify-before-finish gate: the trigger comes from the PM’s own transcript, but the verification scans the externally shared engineer transcript instead.