From 49675a76fcfc7dbf5906ba4f0c97e1774326adf9 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Wed, 3 Sep 2025 13:41:40 +0900 Subject: [PATCH] fix(agents-core): persist streamed input before outputs --- packages/agents-core/src/run.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/agents-core/src/run.ts b/packages/agents-core/src/run.ts index fbd6ceb8..5ef4a07f 100644 --- a/packages/agents-core/src/run.ts +++ b/packages/agents-core/src/run.ts @@ -1014,14 +1014,10 @@ export class Runner extends RunHooks> { const executeRun = async () => { if (resolvedOptions.stream) { - const streamResult = await this.#runIndividualStream( - agent, - preparedInput, - resolvedOptions, - ); - // for streaming runs, the outputs will be save later on + // Persist the user's input before streaming outputs so the session + // transcript preserves the turn order. await saveStreamInputToSession(session, sessionOriginalInput); - return streamResult; + return this.#runIndividualStream(agent, preparedInput, resolvedOptions); } const runResult = await this.#runIndividualNonStream( agent,