fix: reintroduce partial-fragment drop for clean timeouts

This commit is contained in:
Dwayne
2026-05-11 11:47:01 -04:00
committed by Sally O'Malley
parent 18f4a2d987
commit db57da50c9

View File

@@ -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,