Skip to content

Commit 466c306

Browse files
committed
fix: address duplicating session history issue mentioned by @chatgpt-codex-connector
1 parent e78336f commit 466c306

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/agents/run.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,15 +1301,19 @@ async def _start_streaming(
13011301
streamed_result._event_queue.put_nowait(AgentUpdatedStreamEvent(new_agent=current_agent))
13021302

13031303
try:
1304-
# Prepare input with session if enabled
1305-
prepared_input = await AgentRunner._prepare_input_with_session(
1306-
starting_input, session, run_config.session_input_callback
1307-
)
1304+
# Prepare input with session if enabled (skip if resuming from state)
1305+
if run_state is None:
1306+
prepared_input = await AgentRunner._prepare_input_with_session(
1307+
starting_input, session, run_config.session_input_callback
1308+
)
13081309

1309-
# Update the streamed result with the prepared input
1310-
streamed_result.input = prepared_input
1310+
# Update the streamed result with the prepared input
1311+
streamed_result.input = prepared_input
13111312

1312-
await AgentRunner._save_result_to_session(session, starting_input, [])
1313+
await AgentRunner._save_result_to_session(session, starting_input, [])
1314+
else:
1315+
# When resuming, starting_input is already prepared from RunState
1316+
prepared_input = starting_input
13131317

13141318
# If resuming from an interrupted state, execute approved tools first
13151319
if run_state is not None and run_state._current_step is not None:

0 commit comments

Comments
 (0)