{"record":{"id":"30ee36184310abb3","repo":"continuedev/continue","slug":"no-tool-use-found-30ee36","errorCode":null,"errorMessage":"No tool use found","messagePattern":"No tool use found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/openai-adapters/src/apis/Anthropic.ts","lineNumber":411,"sourceCode":"          } as any;\n          break;\n        case \"message_delta\":\n          const deltaEvent = rawEvent as RawMessageDeltaEvent;\n          usage.completion_tokens = deltaEvent.usage?.output_tokens ?? 0;\n          break;\n        case \"content_block_delta\":\n          // https://docs.anthropic.com/en/api/messages-streaming#delta-types\n          const blockDeltaEvent = rawEvent as RawContentBlockDeltaEvent;\n          switch (blockDeltaEvent.delta.type) {\n            case \"text_delta\":\n              yield chatChunk({\n                content: blockDeltaEvent.delta.text,\n                model,\n              });\n              break;\n            case \"input_json_delta\":\n              if (!lastToolUseId || !lastToolUseName) {\n                throw new Error(\"No tool use found\");\n              }\n              yield chatChunkFromDelta({\n                model,\n                delta: {\n                  tool_calls: [\n                    {\n                      id: lastToolUseId,\n                      type: \"function\",\n                      index: 0,\n                      function: {\n                        name: lastToolUseName,\n                        arguments: blockDeltaEvent.delta.partial_json,\n                      },\n                    },\n                  ],\n                },\n              });\n              break;","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/Anthropic.ts#L393-L429","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before (mock SSE missing block start)\nconst sse = `event: content_block_delta\ndata: {\"type\":\"input_json_delta\",\"partial_json\":\"{\\\"city\\\":\"}\n\n// after\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"tool_use\",\"id\":\"toolu_1\",\"name\":\"get_weather\",\"input\":{}}}\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"{\\\"city\\\":\"}\"}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { for await (const chunk of api.chatCompletionStream(body, signal)) {} }\ncatch (e) { if (e.message === 'No tool use found') { logger.error('Malformed Anthropic stream — check proxy/fixtures', e); } throw e; }","preventionTips":["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"],"tags":["anthropic","streaming","tool-calls","sse"],"backgroundTag":"malformed-event-stream","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}