-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Enforce max_output_length for shell tool outputs #2299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Enforce max_output_length for shell tool outputs #2299
Conversation
There was a problem hiding this 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".
There was a problem hiding this 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".
| max_output_length = ( | ||
| result.max_output_length | ||
| if result.max_output_length is not None | ||
| else requested_max_output_length | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
There was a problem hiding this comment.
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
Motivation
max_output_lengthactually enforceable.ShellResultoutputs and simple string outputs so tool authors can limit payload size from either side.Description
max_output_lengthor the executor-returnedShellResult.max_output_lengthto determine truncation and store the resolved value in the raw payload._truncate_shell_outputsto trim structuredShellCommandOutputentries acrossstdoutandstderr, and truncate the renderedoutput_texttomax_output_length.ShellResultand plain string executor returns, and include the resolvedmax_output_lengthinraw_item.src/agents/_run_impl.pyand added a unit test intests/test_shell_tool.py.Testing
bash .codex/skills/verify-changes/scripts/run.shwhich runs formatting, linting, type-checking, and the test suite.make formatand linting passed with no remaining issues.mypycompleted without errors.1186 passed, 4 skipped.Codex Task