Skip to content

fix(codex): store command output whole in result_summary - #127

Open
joeysbase wants to merge 1 commit into
mainfrom
fix/codex-tool-result-truncation
Open

fix(codex): store command output whole in result_summary#127
joeysbase wants to merge 1 commit into
mainfrom
fix/codex-tool-result-truncation

Conversation

@joeysbase

Copy link
Copy Markdown
Contributor

Problem

The Codex agent truncated command output with f"Output: {output[:100]}" when building CommandTelemetry.result_summary. Because result_tokens is derived from result_summary length (ceil(len/4)), this pinned ~77% of Bash results near a ~31-token floor and under-reported every Codex tool result, skewing the cost model.

This also violated the codebase-wide untruncated-result_summary contract (the Claude agent already stores full output; test_resolve_pending_command_does_not_truncate_long_result_summary asserts a 5000-char summary survives). Codex was the outlier.

Change

  • codex_agent.py: store command output whole in result_summary (display trimming belongs in renderers/reports, not capture).
  • CE043 lint rule (tests/lint/rules/ce043_no_command_output_truncation.py, wired into runner.py): forbids constant-slice truncation of captured command output (output[:N], .stdout[:N], …) inside agents/, so the contract can't silently regress. Scoped to agents/, with a # noqa: CE043 escape hatch.
  • Regression test (test_command_output_recorded_whole_not_truncated) + full lint-rule unit tests.

Code-review fixes applied on top

  • streaming/renderers.py: cap the Rich live-feed ToolEnd preview at _MAX_RESULT_LEN so a now-whole result_summary can't flood the console; the reported char count still shows the true full length (+ regression test).
  • models/telemetry.py: narrow the result_tokens docstring — the untruncated contract covers captured command stdout/stderr, not the intentionally-brief one-line summaries of non-command tool items (_summarize_tool_item).
  • experiments/default.yaml: max_turns raised to 100 (intentional, for larger task runs) with the comment clarified as a hard safety ceiling; task_timeout/turn_timeout remain the practical guards.

Verification

make verify green — ruff, pyright (0 errors), custom lint (incl. CE043), 4210 tests, coverage 91.72%.

🤖 Generated with Claude Code

…ew fixes)

The Codex agent truncated command output with `output[:100]` when building
CommandTelemetry.result_summary, so result_tokens (derived from its length)
under-reported every Bash result and skewed the cost model. Store the output
whole and add lint rule CE043 to forbid re-introducing output truncation in
agents/.

Code-review fixes applied on top:
- streaming/renderers.py: cap the Rich live-feed ToolEnd preview at
  _MAX_RESULT_LEN so a now-whole result_summary can't flood the console; the
  reported char count still shows the true full length (+ regression test).
- models/telemetry.py: narrow the result_tokens docstring — the untruncated
  contract covers captured command stdout/stderr, not the intentionally-brief
  one-line summaries of non-command tool items (_summarize_tool_item).
- experiments/default.yaml: clarify the max_turns:100 comment as a hard safety
  ceiling above the typical 3-18 range (task_timeout/turn_timeout are the
  practical guards).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

Claude finished @joeysbase's task in 1m 36s —— View job


Code Review in Progress

Todo List:

  • Read .github/code_review.md for review standards
  • Read CLAUDE.md for project conventions
  • Get full diff with git diff origin/main...HEAD
  • Review each changed file with full context
  • Check cross-file consistency
  • Analyze what's missing
  • Provide comprehensive review feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant