Skip to content

Conversation

@gustavz
Copy link
Contributor

@gustavz gustavz commented Jan 12, 2026

Motivation

  • Prevent overly large shell outputs from overflowing SDK/Responses API limits by making max_output_length actually enforceable.
  • Support both structured ShellResult outputs and simple string outputs so tool authors can limit payload size from either side.

Description

  • Use the action max_output_length or the executor-returned ShellResult.max_output_length to determine truncation and store the resolved value in the raw payload.
  • Add _truncate_shell_outputs to trim structured ShellCommandOutput entries across stdout and stderr, and truncate the rendered output_text to max_output_length.
  • Apply truncation for both ShellResult and plain string executor returns, and include the resolved max_output_length in raw_item.
  • Modified files: src/agents/_run_impl.py and added a unit test in tests/test_shell_tool.py.

Testing

  • Ran the repository verification script bash .codex/skills/verify-changes/scripts/run.sh which runs formatting, linting, type-checking, and the test suite.
  • make format and linting passed with no remaining issues.
  • mypy completed without errors.
  • Test suite outcome: 1186 passed, 4 skipped.

Codex Task

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be201ee8a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@gustavz gustavz requested a review from rm-openai January 12, 2026 13:27
@seratch seratch marked this pull request as draft January 12, 2026 23:33
@seratch seratch added enhancement New feature or request feature:core labels Jan 12, 2026
@seratch seratch added this to the 0.6.x milestone Jan 12, 2026
@seratch seratch marked this pull request as ready for review January 13, 2026 21:18
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80f39d7fdd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1752 to +1756
max_output_length = (
result.max_output_length
if result.max_output_length is not None
else requested_max_output_length
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve action max_output_length=0

If a tool call sets max_output_length to 0 (e.g., to suppress output), _coerce_shell_call currently uses ... or ... to read the field, so 0 is coerced to None. That means requested_max_output_length is None here and this branch won’t truncate at all, even though the caller explicitly asked for zero-length output. This is a regression for the new enforcement path: a model-supplied max_output_length: 0 still leaks full output. Consider preserving zero via an explicit is not None check when parsing the action payload.

Useful? React with 👍 / 👎.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gustavz This look like an edge case, but can resolve it as well? Also, running codex -m gpt-5.2-codex + /review before pushing again, and resolving reviews if there is anything further would be appreciated

@seratch seratch marked this pull request as draft January 13, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants