From db57da50c994bdfd133b1ffce6cd40b6267f0abf Mon Sep 17 00:00:00 2001 From: Dwayne Date: Mon, 11 May 2026 11:47:01 -0400 Subject: [PATCH] fix: reintroduce partial-fragment drop for clean timeouts --- src/agents/pi-embedded-runner/run.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/agents/pi-embedded-runner/run.ts b/src/agents/pi-embedded-runner/run.ts index 2851eccec37..178df54422f 100644 --- a/src/agents/pi-embedded-runner/run.ts +++ b/src/agents/pi-embedded-runner/run.ts @@ -2500,6 +2500,15 @@ export async function runEmbeddedPiAgent( }); const timedOutDuringPrompt = timedOut && !timedOutDuringCompaction && !timedOutDuringToolExecution; + const hasPartialAssistantTextAfterPromptTimeout = + timedOutDuringPrompt && + (attempt.assistantTexts ?? []).some((text) => text.trim().length > 0) && + !attempt.clientToolCalls && + !attempt.yieldDetected && + !attempt.didSendViaMessagingTool && + !attempt.didSendDeterministicApprovalPrompt && + !attempt.lastToolError && + (attempt.toolMetas?.length ?? 0) === 0; const attemptToolSummary = buildTraceToolSummary({ toolMetas: attempt.toolMetas, hadFailure: Boolean(attempt.lastToolError), @@ -2523,7 +2532,7 @@ export async function runEmbeddedPiAgent( "Please try again, or increase `agents.defaults.timeoutSeconds` in your config."; const replayInvalid = resolveReplayInvalidForAttempt(null); const livenessState = resolveRunLivenessState({ - payloadCount: payloads.length, + payloadCount: hasPartialAssistantTextAfterPromptTimeout ? 0 : payloads.length, aborted, timedOut, attempt, @@ -2535,7 +2544,7 @@ export async function runEmbeddedPiAgent( }); return { payloads: [ - ...(payloadsWithToolMedia || []), + ...(hasPartialAssistantTextAfterPromptTimeout ? [] : (payloadsWithToolMedia || [])), { text: timeoutText, isError: true,