-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Filter out reasoning items from previous turns #5857
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
Filter out reasoning items from previous turns #5857
Conversation
…ove_reasoning_before_last_turn and update logic/comments to clarify turn boundary handling
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.
ℹ️ 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".
…visible_history - Move filtering logic for prompt input from filter_model_visible_history to ConversationHistory::get_history_for_prompt. - Update all relevant call sites to use get_history_for_prompt instead of get_history and filtering. - Remove now-unused filter_model_visible_history.
…access Eliminate SessionState::history_snapshot and Session::history_snapshot; refactor call sites to use clone_history().get_history*() as appropriate. Update tests and compact task logic for consistency.
- Added get_history_for_prompt_drops_ghost_commits test to verify ghost commits are filtered out - Fixed test usage to call get_history_for_prompt instead of get_history
| sess.record_conversation_items(&turn_context, &pending_input) | ||
| .await; | ||
| sess.history_snapshot().await | ||
| sess.clone_history().await.get_history_for_prompt() |
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.
history_snapshot was doing the same effective clonning but clone_history give us more flexibility
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.
Can you add an integration test?
| else { | ||
| return; | ||
| }; | ||
| let mut index = 0usize; |
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.
This pattern is pretty strange but I guess retain_mut is not stable yet so good for now
| } | ||
|
|
||
| let history = sess.history_snapshot().await; | ||
| let history = sess.clone_history().await.get_history(); |
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.
NIT: The verbosity here is pretty strange. clone_history should conceptually return an "history"
Out of scope for this PR but there is something strange
…ring - Add inputs_of_type(&self, ty: &str) -> Vec<Value> to ResponsesRequest for type-based filtering of input items - Add cached_prompt_filters_reasoning_items_from_previous_turns test to prompt_caching.rs to verify prior reasoning items are filtered from cached prompts
Done. |
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.
AWESOME
Reduces request size and prevents 400 errors when switching between API orgs.
Based on Responses API behavior described in https://cookbook.openai.com/examples/responses_api/reasoning_items#caching