Skip to content

Commit 269c2fb

Browse files
authored
fix(agents-core): persist streamed input before outputs (#424)
1 parent 876b055 commit 269c2fb

File tree

1 file changed

+3
-7
lines changed
  • packages/agents-core/src

1 file changed

+3
-7
lines changed

packages/agents-core/src/run.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,14 +1014,10 @@ export class Runner extends RunHooks<any, AgentOutputType<unknown>> {
10141014

10151015
const executeRun = async () => {
10161016
if (resolvedOptions.stream) {
1017-
const streamResult = await this.#runIndividualStream(
1018-
agent,
1019-
preparedInput,
1020-
resolvedOptions,
1021-
);
1022-
// for streaming runs, the outputs will be save later on
1017+
// Persist the user's input before streaming outputs so the session
1018+
// transcript preserves the turn order.
10231019
await saveStreamInputToSession(session, sessionOriginalInput);
1024-
return streamResult;
1020+
return this.#runIndividualStream(agent, preparedInput, resolvedOptions);
10251021
}
10261022
const runResult = await this.#runIndividualNonStream(
10271023
agent,

0 commit comments

Comments
 (0)