Repository navigation
Show the reason the agent gave for stopping - #16
Conversation
A canary stopped with `the implement reported BLOCKED` and nothing else. The agent had explained itself in its own structured block -- and that explanation died with the process, so working out what it said cost three more dispatches. The status was recorded correctly; the one thing an operator needs to act was dropped. CycleReport now carries the reason from the block's error, summary, blocking_reason or reason, and prints it under the status. It travels with every ending rather than only the bad ones: a run that finished still said something about how. Two things it deliberately is not. It is not stored: telemetry holds references and counts, and a test asserts the prose never reaches a row. And it is not a fact -- the same canary reported "GitHub authentication is invalid and the GitHub API is unreachable" while gh returned the user, the issue and the remote from the same sandbox, the same directory, minutes later. Showing it is what made that checkable; believing it would have sent somebody to read a status page. Nothing branches on it, asserted by a test. Nine tests. One of them found a real gap while being written: the reason was only attached where a stage stopped, so a cycle that reached APPROVED carried none.
Review summaryReviewed PR 16 at head The core reporting behavior works, but the new output path treats untrusted agent prose as terminal-safe text. That creates one blocking security finding. Findings[REV-001] · medium · open · blocks:yes — Untrusted reason text reaches the terminal unsanitizedFile:
I reproduced this with an agent reason containing Sanitize C0/ANSI control sequences before rendering, or encode the reason for terminal-safe display. Keep the existing whitespace normalization and add a regression test covering escape sequences (and preferably a reasonable display-length limit). Security triage and auditSensitive change: the diff adds a trust boundary from agent-provided structured output into operator-facing observability. The security audit reviewed this path and confirmed REV-001. No secrets were exposed during the review. VerificationPreflight succeeded with Python 3.10.12 and PyYAML available. No database, service, migration, or port prerequisite is required by this repository’s verification workflow. Executed:
Live Codex/Claude dispatches were not run in this environment; the repository’s fake-agent and installed-runtime tests were available and passed. CIAll current PR checks are completed successfully, with no pending, failed, cancelled, or skipped gates:
Residual riskThe reason remains intentionally unpersisted, which limits telemetry and database exposure. Until terminal sanitization is added, operator-facing reports must be treated as capable of containing terminal control sequences. VerdictCHANGES_REQUESTED — resolve REV-001 before approval. |
The reason an agent gives is printed into an operator's terminal report, and collapsing whitespace did not make it safe: an escape is not whitespace, so \x1b[31m survived intact. An agent -- compromised, injected, or merely odd -- could recolour, erase or forge the lines around its own. Reproduced: ESC, BEL and backspace all reached the rendered report. The executor's own `detail` had the same hole one line over. It is stderr from a CLI, exactly as untrusted, printed to the same screen, and it now goes through the same function. Control bytes are removed rather than escape sequences recognised. Without ESC such a sequence is inert text, and that claim holds without keeping a grammar in step with every terminal that might read the output. The text is also cut to 500 characters: a reason is one line of a report, not a page of it. Seven tests, five failures and two errors against the previous version. One asserts every C0 control and DEL is gone by building the string from the character codes, rather than listing the three that happened to be reproduced.
Resolution summaryReproduced against [REV-001] · medium · resolved · valid · blocks:yes — Untrusted reason text reaches the terminal unsanitizedValid, and the flaw is precisely in the reasoning I used when I wrote it: I treated The same hole existed one line over, and the finding did not name it. Fixing only the reported instance would have left its twin in place, so both now go through one Why bytes rather than sequencesI remove every C0 control and DEL instead of recognising ANSI sequences. Without Also added, as the finding suggested: a 500-character cut with an ellipsis. A reason is one line of a report, not a page of it. Regression testsSeven, and against
Verification
Sensitivity triageThis is the security fix, so the audit was repeated against the change itself. It removes characters from strings on their way to stdout and executes nothing new; the reason still never reaches the store, still decides nothing, and the cleaning applies to both untrusted sources. No further finding. Residual risksThe guarantee is "no control bytes", not "no misleading text". An agent can still write a plausible and false sentence — this PR exists because one did — and the cleaning does nothing about that. That is why the reason is displayed as a claim and nothing branches on it. Unchanged from the PR body: issue #15 is still open and the Status: RESOLVED — REV-001 closed at |
Re-review summaryReviewed PR 16 at head The accumulated change still confines the agent-provided reason to operator-facing reporting: it is not stored in telemetry and does not affect routing or verdict decisions. The new fix applies the same terminal-safe cleaning to executor detail, removes every C0 control and DEL byte while preserving readable text, and caps the displayed reason at 500 characters. Findings[REV-001] · medium · resolved · valid · blocks:yes — Untrusted reason text reaches the terminal unsanitizedThe finding is resolved in Validation covered the prior ESC/BEL/backspace reproduction, every C0 code plus DEL, executor detail, control-only input, and the length limit. No new findings were identified. Security triage and auditThis remains a sensitive trust-boundary change because agent output and executor diagnostics reach operator-facing terminal output. The current audit found no new execution, persistence, authorization, secret-exposure, or injection sink. The cleaned value is only rendered; it is not evaluated, dispatched, used for routing, or stored. Verification
Live Codex/Claude dispatches were not run in this environment; the repository's fake-agent and installed-runtime tests were available and passed. CIAll four current check runs for
Residual riskThe displayed reason remains an unverified agent claim and can still be misleading as prose; it is intentionally not treated as a fact. The existing PR-body reference to open issue #15 is unchanged and does not add a finding in this review. VerdictAPPROVED — |
Why
A canary stopped with this and nothing else:
The agent had explained itself in its own structured block. That explanation died with the process, so finding out what it said cost three more dispatches. The status was recorded correctly and the one thing an operator needs in order to act was dropped.
Now:
Scope
CycleReport.reasonis taken from the block'serror,summary,blocking_reasonorreason, in that order —errorfirst, because that is what a blocked skill fills in whilesummarymay describe the run rather than the failure. It is whitespace-collapsed to one line so the report stays readable at a glance.It travels with every ending, not only the bad ones: a run that reached
APPROVEDstill said something about how.Two things it deliberately is not
It is not stored. Telemetry holds references, counts and closed-vocabulary tokens — not prose. A test writes a reason containing a credential-shaped sentence and asserts no row anywhere contains it, while the
BLOCKEDstatus is still recorded.It is not a fact. The same canary reported "GitHub authentication is invalid and the GitHub API is unreachable" — and from the same sandbox, the same directory, minutes later,
gh api userreturneddatacas,gh issue view 15returned the issue, andgh auth statusshowed a valid token. The agent's report was well-formed and wrong.Showing it is what made that checkable. Believing it would have sent somebody to read a status page. So nothing branches on it, and a test asserts a completed stage still completes however alarming the prose beside it is.
Tests
Nine. The reason reaches the operator and appears in the report;
errorwins oversummary; a block without one behaves exactly as before; an unreadable block has no reason to give; a multi-line reason stays on one line; a non-string, empty or whitespace reason is not a reason; the prose never reaches the store; and the reason decides nothing.One of them found a real gap while being written: the reason was attached only where a stage stopped, so a cycle that reached
APPROVEDcarried none. That is why it now travels with every ending.Verification
python3 -m unittest discover -s tests—Ran 399 tests ... OK(was 390).python3 scripts/validate-package.py—VALID. Its privacy scan caught a real repository name in one of the new tests; replaced withowner/api.After this
Canary 4, one run. If it blocks again the reason will be on screen without paying for a second call, and only then is it worth investigating why
cc-implement-issuedeclares itself blocked. Issue #15 stays open until that is settled.