can1357/oh-my-pi · error

Sharpshooter extraction model error

Error message

Sharpshooter extraction model error

What it means

runSharpshooterExtraction performs an LLM call and checks the response's stopReason. When the provider reports `stopReason === "error"`, this error is thrown with the provider's errorMessage, or the generic fallback message if none was supplied. It signals the extraction request itself failed rather than producing tool-call output.

Source

Thrown at packages/coding-agent/src/sharpshooter/extract.ts:232

	const input = prompt.render(extractInputTemplate, { ...envelope });
	const response = await retryTransientCompletion(() =>
		completeSimple(
			model,
			{
				systemPrompt: [prompt.render(extractSystemTemplate)],
				messages: [{ role: "user", content: [{ type: "text", text: input }], timestamp: Date.now() }],
				tools: [recordDeltasTool],
			},
			{
				apiKey: modelRegistry.resolver(model),
				maxTokens: 2048,
				reasoning: clampThinkingLevelForModel(model, Effort.Low),
				toolChoice: "required",
			},
		),
	);
	if (response.stopReason === "error") {
		throw new Error(response.errorMessage || "Sharpshooter extraction model error");
	}

	for (const block of response.content) {
		if (block.type !== "toolCall" || block.name !== recordDeltasTool.name) continue;
		const args = block.arguments;
		if (!args || typeof args !== "object" || !("deltas" in args) || !Array.isArray(args.deltas)) {
			logger.debug("Sharpshooter extraction rejected malformed record_deltas call");
			continue;
		}
		for (const candidate of args.deltas) {
			const delta = admitDelta(candidate, envelope.prompt, session.sessionId);
			if (!delta) continue;
			if (session.isDisposed) return;
			await appendSharpshooterDelta(agentDir, session.sessionManager.getCwd(), delta);
		}
	}
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Inspect response.errorMessage (it is embedded in the thrown message when present) for the provider's actual cause.
  2. Verify provider credentials and quota for the extraction model.
  3. Retry with backoff if the message indicates a transient (429/5xx) failure.
  4. Reduce session size if the request exceeded context limits.

Example fix

// handle extraction failure gracefully
try {
  await runSharpshooterExtraction(...);
} catch (err) {
  logger.warn("sharpshooter extraction failed; keeping existing memory", { err });
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!process.env.API_KEY) throw new Error("extraction model credentials missing before run");

Type guard

null

Try / catch

try {
  await runSharpshooterExtraction(session);
} catch (err) {
  logger.warn("sharpshooter extraction failed", { err });
  // fall back to keeping existing memory files
}

Prevention

When it happens

Trigger: API/network failure, auth rejection, rate limit, content filter, or provider 5xx during the sharpshooter extraction completion — anything the client maps to stopReason "error".

Common situations: Expired or missing API key; provider outage; context window exceeded by a huge session; rate limiting during batch consolidation.

Related errors


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