Skip to content

Commit a44370a

Browse files
committed
fix review comment
1 parent b2958fd commit a44370a

File tree

1 file changed

+10
-8
lines changed
  • packages/agents-core/src

1 file changed

+10
-8
lines changed

packages/agents-core/src/run.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,10 +1337,16 @@ export class Runner extends RunHooks<any, AgentOutputType<unknown>> {
13371337
callModelInputFilter,
13381338
};
13391339
const session = effectiveOptions.session;
1340-
const sessionOriginalInput =
1341-
input instanceof RunState
1342-
? undefined
1343-
: (input as string | AgentInputItem[]);
1340+
const resumingFromState = input instanceof RunState;
1341+
let sessionOriginalInput: string | AgentInputItem[] | undefined;
1342+
if (resumingFromState) {
1343+
if (session) {
1344+
sessionOriginalInput = [] as AgentInputItem[];
1345+
// Persist new outputs without duplicating the original turn when resuming with memory.
1346+
}
1347+
} else {
1348+
sessionOriginalInput = input as string | AgentInputItem[];
1349+
}
13441350

13451351
let preparedInput: typeof input = input;
13461352
if (!(preparedInput instanceof RunState)) {
@@ -1349,10 +1355,6 @@ export class Runner extends RunHooks<any, AgentOutputType<unknown>> {
13491355
session,
13501356
sessionInputCallback,
13511357
);
1352-
} else if (session) {
1353-
throw new UserError(
1354-
'Cannot provide a session when resuming from a previous RunState.',
1355-
);
13561358
}
13571359

13581360
const executeRun = async () => {

0 commit comments

Comments
 (0)