Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/agents/run_internal/session_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ async def save_result_to_session(
if run_state and new_items and new_run_items:
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 👍 / 👎.

if item.type == "tool_call_output_item" and item not in new_run_items
]
if missing_outputs:
Expand Down