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,