continuedev/continue · error · Error
No tool use found
Error message
No tool use found
What it means
While streaming an Anthropic response, an input_json_delta event (partial tool-call arguments JSON) arrived before any content_block_start established a tool_use block. The adapter tracks lastToolUseId/lastToolUseName from prior events; if either is unset, the stream is malformed and the adapter aborts. This almost always indicates an out-of-order or non-compliant event stream from the provider or a proxy.
Source
Thrown at packages/openai-adapters/src/apis/Anthropic.ts:411
} as any;
break;
case "message_delta":
const deltaEvent = rawEvent as RawMessageDeltaEvent;
usage.completion_tokens = deltaEvent.usage?.output_tokens ?? 0;
break;
case "content_block_delta":
// https://docs.anthropic.com/en/api/messages-streaming#delta-types
const blockDeltaEvent = rawEvent as RawContentBlockDeltaEvent;
switch (blockDeltaEvent.delta.type) {
case "text_delta":
yield chatChunk({
content: blockDeltaEvent.delta.text,
model,
});
break;
case "input_json_delta":
if (!lastToolUseId || !lastToolUseName) {
throw new Error("No tool use found");
}
yield chatChunkFromDelta({
model,
delta: {
tool_calls: [
{
id: lastToolUseId,
type: "function",
index: 0,
function: {
name: lastToolUseName,
arguments: blockDeltaEvent.delta.partial_json,
},
},
],
},
});
break;View on GitHub (pinned to 5522c6f44c)
Solutions
- Inspect the raw SSE stream to confirm a content_block_start for a tool_use block precedes input_json_delta
- Update or bypass any proxy/gateway between the client and Anthropic that rewrites stream events
- If mocking Anthropic streams in tests, emit content_block_start (tool_use) before any input_json_delta
- Pin/upgrade the openai-adapters package in case a schema change was fixed in a newer version
Example fix
// before (mock SSE missing block start)
const sse = `event: content_block_delta
data: {"type":"input_json_delta","partial_json":"{\"city\":"}
// after
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","id":"toolu_1","name":"get_weather","input":{}}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"input_json_delta","partial_json":"{\"city\":"}"} Defensive patterns
Strategy: try-catch
Try / catch
try { for await (const chunk of api.chatCompletionStream(body, signal)) {} }
catch (e) { if (e.message === 'No tool use found') { logger.error('Malformed Anthropic stream — check proxy/fixtures', e); } throw e; } Prevention
- When mocking Anthropic SSE, always emit content_block_start for tool_use before input_json_delta
- Test streams through the real Anthropic endpoint before shipping proxies that rewrite events
When it happens
Trigger: Streaming a chat completion with tool use through the Anthropic adapter where an input_json_delta event arrives without a preceding tool_use content_block_start (malformed SSE, buggy proxy, or mocked stream missing block-start events).
Common situations: Using an Anthropic-compatible gateway/proxy that reorders or drops content_block_start events; unit tests with hand-crafted SSE fixtures missing the tool_use block start; upstream API changes to the streaming event schema.
Related errors
- Error getting prompt: MCP Connection ${serverName} not found
- Error streaming response: ${data.error.message}
- Error streaming response: ${JSON.stringify(data.error)}
- Malformed JSON sent from server: ${json}
- Unsupported tool type in Anthropic: ${tool.type}
AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27).
Data as JSON: /api/errors/30ee36184310abb3.
Report an issue: GitHub.