Skip to content

Conversation

habema
Copy link
Contributor

@habema habema commented Sep 9, 2025

Resolves #1699, and fixes session history duplication introduced in #1550.

Problem:
When using sessions, the second Runner.run() call was saving combined input (history + new user input) instead of just the new user input, causing session history to be re-saved and duplicated.

Root cause:
Line 442 was saving original_input which contained the combined session history, not the actual user input.

Fix:
Separate original_user_input from prepared_input (which includes session history). Save only the new user input to prevent duplication.

# Before:
prepared_input = await self._prepare_input_with_session(input, session)
await self._save_result_to_session(session, prepared_input, [])  # ❌ saves history too

# After:  
original_user_input = input
prepared_input = await self._prepare_input_with_session(input, session)
await self._save_result_to_session(session, original_user_input, [])  # ✅ saves only new input

Verification: Session items go from 6 → 4 in the same repro script as the original issue (2 turns × 2 items each, no duplicates).

@seratch seratch added bug Something isn't working feature:sessions labels Sep 9, 2025
@seratch seratch merged commit 3556d7b into openai:main Sep 9, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:sessions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session history duplication after PR #1550 merge

2 participants