Skip to content

Commit db57da5

Browse files
doedewaldtsallyom
authored andcommitted
fix: reintroduce partial-fragment drop for clean timeouts
1 parent 18f4a2d commit db57da5

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • src/agents/pi-embedded-runner

src/agents/pi-embedded-runner/run.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,6 +2500,15 @@ export async function runEmbeddedPiAgent(
25002500
});
25012501
const timedOutDuringPrompt =
25022502
timedOut && !timedOutDuringCompaction && !timedOutDuringToolExecution;
2503+
const hasPartialAssistantTextAfterPromptTimeout =
2504+
timedOutDuringPrompt &&
2505+
(attempt.assistantTexts ?? []).some((text) => text.trim().length > 0) &&
2506+
!attempt.clientToolCalls &&
2507+
!attempt.yieldDetected &&
2508+
!attempt.didSendViaMessagingTool &&
2509+
!attempt.didSendDeterministicApprovalPrompt &&
2510+
!attempt.lastToolError &&
2511+
(attempt.toolMetas?.length ?? 0) === 0;
25032512
const attemptToolSummary = buildTraceToolSummary({
25042513
toolMetas: attempt.toolMetas,
25052514
hadFailure: Boolean(attempt.lastToolError),
@@ -2523,7 +2532,7 @@ export async function runEmbeddedPiAgent(
25232532
"Please try again, or increase `agents.defaults.timeoutSeconds` in your config.";
25242533
const replayInvalid = resolveReplayInvalidForAttempt(null);
25252534
const livenessState = resolveRunLivenessState({
2526-
payloadCount: payloads.length,
2535+
payloadCount: hasPartialAssistantTextAfterPromptTimeout ? 0 : payloads.length,
25272536
aborted,
25282537
timedOut,
25292538
attempt,
@@ -2535,7 +2544,7 @@ export async function runEmbeddedPiAgent(
25352544
});
25362545
return {
25372546
payloads: [
2538-
...(payloadsWithToolMedia || []),
2547+
...(hasPartialAssistantTextAfterPromptTimeout ? [] : (payloadsWithToolMedia || [])),
25392548
{
25402549
text: timeoutText,
25412550
isError: true,

0 commit comments

Comments
 (0)