-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Avoid double truncation #6631
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
Avoid double truncation #6631
Conversation
aibrahim-oai
commented
Nov 13, 2025
- Avoid double truncation by giving 10% above the tool default constant
- Add tests that fails when const = 1
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
codex/codex-rs/core/src/context_manager/truncate.rs
Lines 128 to 134 in d96cc59
| let remaining = MODEL_FORMAT_MAX_BYTES.saturating_sub(result.len()); | |
| if remaining == 0 { | |
| return result; | |
| } | |
| let tail_part = take_last_bytes_at_char_boundary(tail_slice, remaining); | |
| result.push_str(tail_part); |
The new signature of truncate_formatted_exec_output accepts limit_bytes, but the tail assembly at lines 128‑133 still subtracts from the hard coded MODEL_FORMAT_MAX_BYTES. As a result the function never returns more than 10 KiB of body text even when the caller (e.g. ContextManager::process_item) passes the new 1.1× limits, so the additional headroom you introduced is never honored and tool outputs can still be double‑truncated. remaining (and therefore the tail slice) needs to be computed from limit_bytes, otherwise the change in history.rs has no effect.
ℹ️ 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".