{"record":{"id":"b748f592e76b1105","repo":"can1357/oh-my-pi","slug":"completion-request-aborted","errorCode":null,"errorMessage":"completion() request aborted.","messagePattern":"completion\\(\\) request aborted\\.","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"warning","filePath":"packages/coding-agent/src/eval/completion-bridge.ts","lineNumber":177,"sourceCode":"\t\t\t\tsystemPrompt,\n\t\t\t\tmessages: [{ role: \"user\", content: [{ type: \"text\", text: prompt }], timestamp: Date.now() }],\n\t\t\t\ttools,\n\t\t\t},\n\t\t\t{\n\t\t\t\tapiKey: registry.resolver(model, options.session.getSessionId?.() ?? undefined),\n\t\t\t\tsignal: options.signal,\n\t\t\t\treasoning: reasoningForTier(finalTier, model),\n\t\t\t\ttoolChoice: schema ? { type: \"tool\", name: STRUCTURED_TOOL_NAME } : undefined,\n\t\t\t},\n\t\t\t{ telemetry, oneshotKind: \"eval_completion\" },\n\t\t),\n\t);\n\n\tif (response.stopReason === \"error\") {\n\t\tthrow new ToolError(response.errorMessage ?? \"completion() request failed.\");\n\t}\n\tif (response.stopReason === \"aborted\") {\n\t\tthrow new ToolError(\"completion() request aborted.\");\n\t}\n\n\tlet resultText: string;\n\tif (schema) {\n\t\tconst call = extractToolCall(response, STRUCTURED_TOOL_NAME);\n\t\tlet value: unknown;\n\t\tif (call) {\n\t\t\tvalue = call.arguments;\n\t\t} else {\n\t\t\tconst text = extractTextContent(response);\n\t\t\tif (!text) throw new ToolError(\"completion() returned no structured response.\");\n\t\t\ttry {\n\t\t\t\tvalue = parseJsonPayload(text);\n\t\t\t} catch {\n\t\t\t\tthrow new ToolError(\"completion() did not return a structured response matching the schema.\");\n\t\t\t}\n\t\t}\n\t\tresultText = JSON.stringify(value);","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/eval/completion-bridge.ts#L159-L195","documentation":"When the completion request is aborted (its AbortSignal fired) the response comes back with `stopReason === \"aborted\"`, and the bridge throws this ToolError instead of returning a result. It signals deliberate cancellation — a timeout, a user abort, or eval harness teardown — not a provider failure.","triggerScenarios":"The AbortSignal passed in `EvalCompletionBridgeOptions.signal` fires while `completion()` is in flight (eval cell timeout, harness shutdown, user cancel), and the in-flight request resolves with an \"aborted\" stop reason.","commonSituations":"Eval cell exceeded its timeout budget while the model was slow; user pressed Ctrl-C / cancelled the eval run; the bridge's timeout-pause window ended; harness disposed the session mid-completion.","solutions":["Rerun the cell with a larger timeout if the model legitimately needs more time.","Use a faster tier (`model: \"smol\"`) or a shorter prompt to keep the call within the budget.","Check whether the abort originated from your own harness signal wiring (e.g. a signal aborted too eagerly).","If aborts are expected, catch this ToolError and treat the completion as skipped rather than a failure."],"exampleFix":"// before: crash on cancel\nconst out = await completion(longPrompt);\n// after: tolerate cancellation\nlet out;\ntry {\n  out = await completion(longPrompt);\n} catch (e) {\n  if (String(e).includes(\"aborted\")) out = \"(skipped)\";\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (options.signal?.aborted) return; // skip the call entirely","typeGuard":null,"tryCatchPattern":"try {\n  const out = await completion(prompt, { signal });\n} catch (e) {\n  if (String(e).includes(\"aborted\")) return null; // treat as cancelled\n  throw e;\n}","preventionTips":["Give completion() a timeout budget larger than expected model latency.","Use the smol tier for latency-sensitive cells.","Use a dedicated AbortController per call so unrelated cancels don't propagate."],"tags":["abort","timeout","cancellation"],"backgroundTag":"request-aborted","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}