diff --git a/src/agents/pi-embedded-runner/run.ts b/src/agents/pi-embedded-runner/run.ts index 4a3032ba5eb..2011980dcb0 100644 --- a/src/agents/pi-embedded-runner/run.ts +++ b/src/agents/pi-embedded-runner/run.ts @@ -1138,9 +1138,6 @@ export async function runEmbeddedPiAgent( lastAssistant: sessionLastAssistant, currentAttemptAssistant, } = attempt; - // Field is optional in the public harness SDK contract; default to - // false here so internal code can rely on a strict boolean. Internal - // embedded-runner attempt sets this explicitly. See #52147. const timedOutDuringToolExecution = attempt.timedOutDuringToolExecution ?? false; if (sessionIdUsed && sessionIdUsed !== activeSessionId) { activeSessionId = sessionIdUsed; @@ -1247,9 +1244,6 @@ export async function runEmbeddedPiAgent( // ── Timeout-triggered compaction ────────────────────────────────── // When the LLM times out with high context usage, compact before // retrying to break the death spiral of repeated timeouts. - // Skip when the timeout fired during tool execution: the LLM had - // already responded, the prompt wasn't the problem, and compacting - // would lose the in-flight tool context. See #52147. if (timedOut && !timedOutDuringCompaction && !timedOutDuringToolExecution) { // Only consider prompt-side tokens here. API totals include output // tokens, which can make a long generation look like high context @@ -2084,11 +2078,6 @@ export async function runEmbeddedPiAgent( // Timeout aborts can leave the run without any assistant payloads. // Emit an explicit timeout error instead of silently completing, so // callers do not lose the turn as an orphaned user message. - // Skip when the timeout fired during tool execution: the assistant - // did produce a response (a tool call) that ran long; the generic - // "no response from model" payload would mislead the caller. The - // partial tool output already in the session is the correct artifact - // to surface. See #52147. if ( timedOut && !timedOutDuringCompaction && diff --git a/src/agents/pi-embedded-runner/run/attempt.ts b/src/agents/pi-embedded-runner/run/attempt.ts index f5d88246fd4..8ae7d8718bc 100644 --- a/src/agents/pi-embedded-runner/run/attempt.ts +++ b/src/agents/pi-embedded-runner/run/attempt.ts @@ -2252,11 +2252,6 @@ export async function runEmbeddedAttempt( aborted = true; if (isTimeout) { timedOut = true; - // Distinguish run-timer fires that occur while tool execution is in - // flight (LLM already responded; primary model is not at fault) from - // LLM-phase timeouts. Mirrors the `timedOutDuringCompaction` precedent - // (#46889) so the failover policy can skip pointless model fallback. - // Closes #52147. if (!timedOutDuringCompaction && countActiveToolExecutions(params.runId) > 0) { timedOutDuringToolExecution = true; } diff --git a/src/agents/pi-embedded-runner/run/types.ts b/src/agents/pi-embedded-runner/run/types.ts index 20cd456ac1c..b3113ddadde 100644 --- a/src/agents/pi-embedded-runner/run/types.ts +++ b/src/agents/pi-embedded-runner/run/types.ts @@ -58,16 +58,7 @@ export type EmbeddedRunAttemptResult = { idleTimedOut: boolean; /** True if the timeout occurred while compaction was in progress or pending. */ timedOutDuringCompaction: boolean; - /** - * True if the run-level timer fired while at least one tool execution was - * still in flight. The LLM had already responded; the timeout is unrelated - * to the primary model and must not trigger model fallback. Closes #52147. - * - * Optional for plugin-SDK back-compat: this type is re-exported as - * `AgentHarnessAttemptResult` and third-party harnesses cannot necessarily - * observe in-flight tool state. Treat absent as `false` at the runner - * boundary; internal embedded-runner code always sets it explicitly. - */ + /** Optional because this type is re-exported as `AgentHarnessAttemptResult`. */ timedOutDuringToolExecution?: boolean; promptError: unknown; /** diff --git a/src/agents/pi-embedded-subscribe.handlers.tools.ts b/src/agents/pi-embedded-subscribe.handlers.tools.ts index f4d1707165a..a1b313afdde 100644 --- a/src/agents/pi-embedded-subscribe.handlers.tools.ts +++ b/src/agents/pi-embedded-subscribe.handlers.tools.ts @@ -92,15 +92,6 @@ function buildToolStartKey(runId: string, toolCallId: string): string { return `${runId}:${toolCallId}`; } -/** - * Count tool executions currently in flight for a given run. - * - * Reads the existing `toolStartData` map: handleToolExecutionStart inserts on - * tool start, handleToolExecutionEnd deletes on completion. Used by the - * embedded run timer to detect whether a run-level timeout fired while tool - * execution was active (in which case the failover policy should not rotate - * to a fallback model — the LLM had already responded). - */ export function countActiveToolExecutions(runId: string): number { const prefix = `${runId}:`; let count = 0;