Skip to content

fix: prevent duplicate re-persistence of tool output items in session store#3925

Open
AAliKKhan wants to merge 1 commit into
openai:mainfrom
AAliKKhan:fix/tool-output-duplicate-persist
Open

fix: prevent duplicate re-persistence of tool output items in session store#3925
AAliKKhan wants to merge 1 commit into
openai:mainfrom
AAliKKhan:fix/tool-output-duplicate-persist

Conversation

@AAliKKhan

Copy link
Copy Markdown
Contributor

In save_result_to_session, the missing_outputs scan searched the entire new_items list for tool_call_output_items not yet in new_run_items. This caused already-persisted tool outputs to be re-prepended on every streaming save call, leading to unbounded session storage growth. The fix limits the scan to the already-persisted portion of the list.

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

Copy link
Copy Markdown

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: b8b8bc9cc3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

missing_outputs = [
item
for item in new_items
for item in new_items[:already_persisted]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Stop re-saving already-persisted tool outputs

When a streaming turn has already saved a tool_call_output_item and a later save is called with the cumulative new_items list plus newly produced items, this slice iterates exactly over the already-persisted prefix; the condition then prepends that old tool output to new_run_items, so session.add_items() writes it again and the duplicate-growth bug remains. The scan needs to exclude already-persisted items rather than select them, or track saved items after conversion/persistence filtering.

AGENTS.md reference: AGENTS.md:L112-L112

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants