diff --git a/src/main/acp/discovery/acp-model-catalog-probe.ts b/src/main/acp/discovery/acp-model-catalog-probe.ts index 482cfdc54b0..578978c6806 100644 --- a/src/main/acp/discovery/acp-model-catalog-probe.ts +++ b/src/main/acp/discovery/acp-model-catalog-probe.ts @@ -192,11 +192,12 @@ const folderlessListing = (spec: AcpLaunchSpec) => // Agents (notably opencode) answer session/new with a transient -32603 while // their providers still open; without a retry one probe failure degrades the picker. -const TRANSIENT_AGENT_RETRY_DELAYS_MS = [250, 500, 1_000] as const +const TRANSIENT_AGENT_RETRY_DELAYS_MS = [250, 500] as const const isTransientAgentFailure = (error: unknown): boolean => error instanceof AcpAgentError && error.code === -32603 +/** Retries transient -32603 agent answers at most three attempts total, stopping on abort or agent switch. */ async function retryTransientAgentFailure( run: () => Promise, operation?: StructuredAgentResolutionOperation @@ -208,12 +209,13 @@ async function retryTransientAgentFailure( if (attempt >= TRANSIENT_AGENT_RETRY_DELAYS_MS.length || !isTransientAgentFailure(error)) { throw error } - assertStructuredAgentResolutionCurrent(operation) await sleep(TRANSIENT_AGENT_RETRY_DELAYS_MS[attempt], operation?.signal) + assertStructuredAgentResolutionCurrent(operation) } } } +/** Resolves on timeout or abort; the caller must re-check operation currency afterwards. */ async function sleep(ms: number, signal?: AbortSignal): Promise { if (signal?.aborted) { return