can1357/oh-my-pi · warning · ToolError

completion() request aborted.

Error message

completion() request aborted.

What it means

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.

Source

Thrown at packages/coding-agent/src/eval/completion-bridge.ts:177

				systemPrompt,
				messages: [{ role: "user", content: [{ type: "text", text: prompt }], timestamp: Date.now() }],
				tools,
			},
			{
				apiKey: registry.resolver(model, options.session.getSessionId?.() ?? undefined),
				signal: options.signal,
				reasoning: reasoningForTier(finalTier, model),
				toolChoice: schema ? { type: "tool", name: STRUCTURED_TOOL_NAME } : undefined,
			},
			{ telemetry, oneshotKind: "eval_completion" },
		),
	);

	if (response.stopReason === "error") {
		throw new ToolError(response.errorMessage ?? "completion() request failed.");
	}
	if (response.stopReason === "aborted") {
		throw new ToolError("completion() request aborted.");
	}

	let resultText: string;
	if (schema) {
		const call = extractToolCall(response, STRUCTURED_TOOL_NAME);
		let value: unknown;
		if (call) {
			value = call.arguments;
		} else {
			const text = extractTextContent(response);
			if (!text) throw new ToolError("completion() returned no structured response.");
			try {
				value = parseJsonPayload(text);
			} catch {
				throw new ToolError("completion() did not return a structured response matching the schema.");
			}
		}
		resultText = JSON.stringify(value);

View on GitHub (pinned to 9690622007)

Solutions

  1. Rerun the cell with a larger timeout if the model legitimately needs more time.
  2. Use a faster tier (`model: "smol"`) or a shorter prompt to keep the call within the budget.
  3. Check whether the abort originated from your own harness signal wiring (e.g. a signal aborted too eagerly).
  4. If aborts are expected, catch this ToolError and treat the completion as skipped rather than a failure.

Example fix

// before: crash on cancel
const out = await completion(longPrompt);
// after: tolerate cancellation
let out;
try {
  out = await completion(longPrompt);
} catch (e) {
  if (String(e).includes("aborted")) out = "(skipped)";
  else throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (options.signal?.aborted) return; // skip the call entirely

Try / catch

try {
  const out = await completion(prompt, { signal });
} catch (e) {
  if (String(e).includes("aborted")) return null; // treat as cancelled
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/b748f592e76b1105. Report an issue: GitHub.