style(agents): trim tool-timeout comments

This commit is contained in:
Ayaan Zaidi
2026-05-02 19:20:12 +05:30
parent fbad17bf4f
commit 731f640bca
4 changed files with 1 additions and 35 deletions

View File

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

View File

@@ -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;
}

View File

@@ -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;
/**

View File

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