-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Trim compaction input #10374
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?
Trim compaction input #10374
Conversation
Move estimated token count logging to after sampling with token limit info and add Session::get_estimated_token_count helper. Simplify history test by removing unnecessary clone.
|
@codex review |
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: 24a1dd9626
ℹ️ 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".
| pub(crate) fn is_codex_generated_item(item: &ResponseItem) -> bool { | ||
| matches!( | ||
| item, | ||
| ResponseItem::FunctionCallOutput { .. } | ||
| | ResponseItem::CustomToolCall { .. } | ||
| | ResponseItem::CustomToolCallOutput { .. } | ||
| | ResponseItem::LocalShellCall { .. } | ||
| ) || matches!(item, ResponseItem::Message { role, .. } if role == "developer") |
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.
Treat tool calls as codex-generated for trimming
The new trimming logic in compact_remote.rs relies on is_codex_generated_item to decide which trailing items can be removed. That helper now treats tool outputs as codex-generated but omits ResponseItem::FunctionCall. If a session ends with a tool call that never produced an output (e.g., aborted/failed tool invocation), trimming will stop at that last FunctionCall, even though normalize_history() later synthesizes an output for it. In that scenario, the compaction request can still exceed the context window and fail, which defeats the new trimming safeguard. Consider classifying ResponseItem::FunctionCall as codex-generated (or normalize before trimming) so trailing tool calls without outputs are also removable.
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.
Actually this make sense as we will never send back this function call in the context anyway
jif-oai
left a comment
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.
Not a big fan but I guess this is necessary
Two fixes: