Repository navigation
Read what the agent said, not what the CLI printed - #14
Conversation
A canary against the real CLIs found three things no fake could. The driver read the raw stdout of each executor as if it were the reply. Claude wraps its reply in one JSON object under `result`, so the block arrived with its newlines and quotes still escaped: read_structured_result located ORCHESTRATION_RESULT and then failed to parse it, and a review that had correctly reported BLOCKED was recorded as no verdict at all. Codex wraps its reply in NDJSON `agent_message` items, the same problem one format further away. The fakes had printed the block as plain text, so every test passed while nothing worked. Each adapter now unwraps its own envelope into agent_output and the driver reads that. Neither the driver nor the next executor to be added learns what `result` or `item.completed` mean. Both extractors were written against live captures, not by assumption, and those captures are the fixtures. The fake agents write their CLI's envelope too, so the installed cycle exercises the real shape -- including Codex reporting no model at all, which a live run showed and the test now asserts instead of pretending otherwise. Second: a structured result now distinguishes readable, present-but-unreadable, and absent. One None for all three meant a cycle recorded "no verdict" for a run that was explicitly blocked. A status outside the store's vocabulary is treated as no status rather than carried to record_verdict, where it would raise and end the run without its closing row. Third, and the one that matters for the data: a dispatch that returned is not a stage that worked. The canary had Codex exit 0 having changed nothing -- the work item did not exist -- and the cycle went on to review it. Those are two facts about different layers and the store already keeps them in separate columns, so outcome stays `succeeded` and the reported status is recorded beside it. What changed is that a stage whose own report is not a completion stops the cycle. Every stop condition now lives in one place rather than being repeated per stage; one repeated four times is one that will be missing from the fourth.
Review summaryReviewed the accumulated diff from The change fixes the reported envelope-parsing and functional-stop defects, but the normalized output path still drops valid results from sufficiently long agent responses. That is a blocking correctness issue for the cycle driver. Findings[REV-001] · high · open · blocks:yes — Structured results can be lost after output truncationFile:
I reproduced this with a successful Codex-shaped Preserve the full normalized text for structured-result parsing, or locate and extract the structured block before applying a bounded diagnostic-output limit. Keep any truncation separate from the authoritative result path. Security triageSensitive change: the diff handles executor authentication evidence, subprocess execution, environment-derived credential paths, and untrusted CLI output parsing. The security audit reviewed those trust boundaries and found no confirmed security vulnerability in the changed code. No secrets were exposed in the review. VerificationExecuted:
The repository’s preflight had Python 3.10.12 and PyYAML available. A live Codex/Claude dispatch was not rerun because this review environment does not provide a configured live provider session; the fake-envelope and installed-runtime coverage did run. CIAll four reported PR checks completed successfully:
The remote CI gates are green, but they do not cover a response whose structured block is followed by more than 8,000 characters. Residual riskThe new live-envelope fixtures and installed-cycle tests cover the normal Codex and Claude response shapes. Long or unusually verbose successful responses remain at risk until the bounded-output parsing path is corrected. VerdictCHANGES_REQUESTED — resolve REV-001, then rerun the focused regression and full suite. |
agent_output was capped at 8000 characters, so a reply that carried on past its own structured block lost the block's opening delimiter with the tail. The cycle then recorded a completed stage as having reported nothing, and stopped with HUMAN_INTERVENTION on a run the agent had finished. Reproduced: a valid IMPLEMENTED block followed by 9000 characters gave agent_output of exactly 8000, present=False, status=None. Two different jobs shared one string. The tail in artifacts is diagnostic and stays cut to 4000; agent_output is the authoritative result path and is now whole. It costs nothing to keep -- the full stdout is already in memory at that point -- and a limit on it is a silent deletion of valid results. Three tests: a long reply keeps its result, the diagnostic tail stays bounded while the parsed text does not, and the same case end to end through the cycle. Two of them fail against the previous version.
Resolution summaryReproduced against [REV-001] · high · resolved · valid · blocks:yes — Structured results can be lost after output truncationValid, and self-inflicted: the Worth naming the shape of the mistake, because it is the one this PR was fixing one layer up: two different jobs were sharing one string.
So it is now kept whole. That costs nothing: the complete stdout is already in memory at that point, and Also worth saying plainly: the case is not exotic. A block followed by a summary, next steps or a closing paragraph is what an agent ordinarily writes, and my original comment claimed truncating "after" unwrapping was the safe order. It was safe against cutting the envelope mid-token, and unsafe against exactly this. Regression testsThree, two of which fail against the previous version (verified by restoring
The third one passes both ways by design — it pins the bound that must stay. Verification
Sensitivity triageAgreeing with the review's audit. The change removes a truncation from a transient string and executes nothing new; no data crosses a boundary it did not cross before. No audit finding. Residual risksThe live fixtures cover one response shape per CLI, captured from real runs. A provider changing its envelope would not be caught by these tests — it would be caught by the next canary, which is what found this class of defect in the first place. The canary rerun is still pending and is the acceptance criterion for this work, not the suite. Status: RESOLVED — REV-001 closed at |
Re-review summaryRe-reviewed the accumulated diff from No new findings were identified. Previous finding[REV-001] · high · resolved · blocks:yes — Structured results can be lost after output truncationFile: Corrected and verified by execution. Current accumulated reviewThe full merge-base diff remains in scope: executor envelope extraction, structured-result classification, functional cycle stop semantics, installed fake-agent behavior, telemetry-facing stage recording, documentation, and tests. The latest fix is consistent with the stated design: diagnostic output is bounded, but the caller’s authoritative result is not. Security triageSensitive change: the reviewed files handle executor authentication evidence, subprocess execution, environment-derived credential paths, and untrusted CLI output parsing. The security audit found no confirmed vulnerability in the current accumulated diff. No secrets were exposed. The PR has no sensitive-area labels. VerificationPreflight found Python 3.10.12 and PyYAML available; no database, service, migration, or port prerequisite was required for this repository’s test workflow. Executed:
An authenticated live Codex/Claude dispatch was not rerun in this environment; the live-envelope fixtures and installed-runtime tests cover the observed provider shapes. CICurrent PR checks are all completed successfully, with no pending, failed, cancelled, or skipped gates:
Residual riskProvider behavior outside the captured Codex and Claude envelope shapes remains an external integration risk, but an unrecognized envelope is deliberately passed through and results are now no longer truncated before parsing. VerdictAPPROVED — REV-001 is resolved and verified; no open finding blocks approval. |
What the canary found
One real cycle against Codex and Claude, ~20 céntimos, and it located three defects that 372 passing tests did not. All three come from the same root: the fakes printed the structured block as plain text, and the real CLIs do not.
1. Normalized agent output, per adapter
Claude wraps its reply in one JSON object under
result. Codex wraps its in NDJSONagent_messageitems. The driver was reading raw stdout, so it foundORCHESTRATION_RESULTand then failed to parse the block, because the newlines and quotes were still\nand\"inside a JSON string:The reviewer had done its job perfectly — it reported
BLOCKEDand explained thatCANARY-1matched no issue or PR. The driver recorded "no structured verdict".Each adapter now unwraps its own format into
agent_output, and the driver reads that. It does not learn whatresultoritem.completedmean, and neither does the next executor added.Both extractors were written against live captures, not by assumption, and those captures are the fixtures (
tests/fakes/codex_output.ndjson,tests/fakes/claude_output.json, identifiers replaced). The observed Codex shape:When an adapter does not recognise its own envelope it returns the output unchanged rather than some filtered part of it — returning only what it recognised would silently drop the rest.
2. Presence and readability, not one
Noneread_structured_resultnow returns aReportedcarrying three distinguishable answers: readable, present-but-unreadable, absent. Collapsing them meant a cycle recorded "no verdict" for a run that was explicitly blocked.A status outside the store's vocabulary is treated as no status rather than carried to
record_verdict, where it would raise and end the run without its closing row — a failure this driver has already made once.3. Functional stop semantics
outcome=succeededwas not wrong, and it has not been changed. The canary's implement row saidsucceededand the clone had no commits and no modified files: the call returned, the work did not happen. Two facts about different layers, which the store already keeps in separate columns.What was wrong is that the cycle continued. Now a stage whose own report is not a completion stops it:
COMPLETESstates what each role must report to continue —IMPLEMENTED,RESOLVED/PARTIALLY_RESOLVED,APPROVED/CHANGES_REQUESTED.PARTIALLY_RESOLVEDcontinues because the re-review is what judges how much was resolved. Every stop condition now lives in oneadvance()rather than being repeated per stage: a condition repeated four times is one that will be missing from the fourth.first_pass_rate()is untouched — it already counts only reviews with a terminal verdict, so a blocked implementation never enters the sample.Tests
387 (was 373). The ones that matter:
CHANGES_REQUESTEDrecovered;BLOCKEDstops the cycle with zero reviewer dispatches, while its dispatch row still readssucceededand the reported status is recorded beside it;tests/test_installed_cycle.pyexercises the exact shape the canary broke on — including the blocked-implement case end to end, and Codex reporting no model at all, which the live run showed and the test now asserts instead of pretending otherwise.Verification
python3 -m unittest discover -s tests—Ran 387 tests ... OK.python3 scripts/validate-package.py—VALID.resultyields text whose block parses.After this
Repeat the canary. The acceptance criterion is no longer "three rows" but: a real implement produces a readable structured result; if
IMPLEMENTED, a real review follows with a readable verdict; ifBLOCKED, that is recorded and no review appears. Only then does counting to ten start.