DEV Community

Riley Lin
Riley Lin

Posted on

Keep Agent Progress Out of Your Build Log

An agent run produces two outputs with different trust levels: progress and the final message. The non-interactive mode documentation states that by default Codex writes progress to stderr and sends the final agent message to stdout. With the --json option, stdout becomes a JSON Lines event stream, one JSON object per line. That documented split is the contract to test. The risk is not only the final answer; it is any job configuration that merges streams or uploads every artifact under the workspace.

Stream Default content Intended reader Retention decision
stdout final message, or JSON Lines with --json the next pipeline step retain as the reviewed deliverable
stderr progress and tool activity a human debugging a failure retain rarely, with a short window
filesystem files the run wrote reviewers via diff retain with review

Draw the boundaries before changing YAML

Three boundaries matter: workspace to prompt context, process to stream, and stream to retained storage. The third is where retention policy is applied, so make it explicit. A reviewer who approves prompt context may not see artifact upload rules.

Separate the streams, then verify

Send stdout and stderr to distinct, attempt-specific destinations. Do not merge stderr into stdout. This is a configuration change, not a prompt change. Verification criteria: after a run, the final artifact should contain only the final message, or with --json the reviewed event stream; the progress artifact should contain progress; no merged artifact should exist. Inspect the artifact manifest, not only the local directory, because upload rules can include files you did not intend. If the final artifact contains progress text, the streams were merged or mislabeled. If the progress artifact is uploaded, the retention boundary is wrong.

Treat JSON Lines as a sequence

If --json is used, stdout is a JSON Lines stream. Each retained line should parse as JSON. Before filtering, capture one raw run and read the event types. Retain only event types you can identify in the current documentation and explain to a reviewer. Verification: every retained line parses; every retained event type is on an allowlist; an unknown type fails review rather than being silently dropped or retained. A filter based on a guessed field is not a control.

Redact, then test with a canary

Place redaction between the process and the artifact store. A filter can strip known token prefixes and absolute home paths, but it cannot prove that no secret was copied from a file the agent read. Test with a canary.

Inputs: a unique fake token, such as CANARY_7f3a9c, in a non-secret workspace file that the agent may read; a job that writes final and progress artifacts; and an artifact manifest. Observation: search every retained artifact for the token. Use a search that fails closed: if a file cannot be read, the check fails. Interpretation: a token in the final artifact means the model echoed context into the final message; a token in the progress artifact means stderr was retained; a token in neither is evidence for this run and this token only. It does not prove absence of other secrets. Run against a scratch repository first, and record which assumption failed.

Failure modes to test

  • Shell tracing can print expanded variables to stderr. If tracing is on, include stderr in the canary search.
  • Artifact globs can upload progress logs. Verify the upload allowlist and manifest; local separation is not enough.
  • Retries can create multiple runs. The AWS Builders' Library note on timeouts, retries and backoff with jitter notes that backoff and jitter do not prove the preceding call had no side effects. If a timeout triggers a retry, the second attempt may observe files left by the first. Use attempt-keyed directories and verify one final artifact and one progress artifact per attempt. A mismatch is two attempt directories but one merged log, or a log from attempt 1 overwritten by attempt 2.
  • Provider retention is out of scope: stream routing does not change what leaves your network.
  • Credential scope is separate: a broad token can leak through a channel you did not model.

Tradeoffs

Separating streams costs convenience during an incident. A short retention window with a size cap for stderr may be acceptable; stdout remains the reviewed deliverable. If logs are already centrally scrubbed, measure the marginal benefit before refactoring. This approach does not address an interactive session where output stays on a developer's machine and never reaches an artifact store.

Verify the contract with the canary, then re-verify after runner-image or CI-default changes, because those can change outside your repository. Keep the check in the same job that runs the agent so a broken boundary fails the build instead of quietly filling a bucket.


AI assistance: this draft was generated with AI assistance. The checks described here are proposed and were not executed; no test results are claimed. A human should verify the current non-interactive mode documentation, the event schema, and the destination platform's policy before publishing.

This article was created with AI assistance.

Top comments (0)