diff --git a/src/agents/pi-embedded-runner/run.compaction-loop-guard.test.ts b/src/agents/pi-embedded-runner/run.compaction-loop-guard.test.ts index 41c80eab3ea..0d9233b3d65 100644 --- a/src/agents/pi-embedded-runner/run.compaction-loop-guard.test.ts +++ b/src/agents/pi-embedded-runner/run.compaction-loop-guard.test.ts @@ -50,16 +50,18 @@ function recordToolOutcome( runId?: string, ): void { const toolCallId = `${toolName}-${state.toolOutcomeSeq ?? 0}`; - recordToolCall(state, toolName, toolParams, toolCallId, undefined, { - ...(runId ? { runId } : {}), - }); - recordToolCallOutcome(state, { + const scope = runId ? { runId } : undefined; + recordToolCall(state, toolName, toolParams, toolCallId, undefined, scope); + const outcome: Parameters[1] = { toolName, toolParams, toolCallId, result, - ...(runId ? { runId } : {}), - }); + }; + if (runId) { + outcome.runId = runId; + } + recordToolCallOutcome(state, outcome); } describe("post-compaction loop guard wired into runEmbeddedPiAgent", () => {