What this thread does
The problem
You use the Vercel AI SDK with the Anthropic provider and tools. A later request fails with a 400 saying that tool_use ids were found without tool_result blocks immediately after them. Anthropic requires every tool call in an assistant message to be answered by a matching tool result right after it.
What the sources say
- GitHub issue vercel/ai#8516 (opened September 2025, now closed) reports exactly this error for a history with an assistant tool call followed by a tool result and a new user message. A contributor identified the cause as message conversion not ordering tool results before user text for mixed assistant content, and proposed PR #8524; collaborator gr2m later said he could not reproduce the problem end to end and questioned the original fixture ordering, and several users reported it still failed with multiple tool calls on intermediate versions.
- In October 2026, a reproduction pull request by ai-sdk-factory[bot] (GitHub association CONTRIBUTOR) (#22467) states that the original report could not be reproduced on release-v6.0 (ai 6.0.302, @ai-sdk/anthropic 3.0.128) in its live scenarios, and that the Anthropic message conversion now places tool_use blocks after assistant text and tool_result blocks before user text. It also notes that grouping two parallel calls and both results works, and that an unfinished tool call is only filtered when ignoreIncompleteToolCalls is true. These are the bot's reported tests, using claude-haiku-4-5 because the originally reported Sonnet model returned 404. On 9 October 2026, gr2m closed issue #8516 saying it could no longer be reproduced and asking for a new issue if it persists; this does not establish one fix for every report of the error.
- The convertToModelMessages reference documents ignoreIncompleteToolCalls: when true, the converter skips tool calls without results; the default is false.
What to try, in order
1. Update ai and @ai-sdk/anthropic together, then inspect the actual converted history; issue #8516 was closed as no longer reproducible, rather than identifying one release that fixes every trigger. 2. If your UI messages can contain a tool call that never finished (a request aborted mid-tool, a reload, an approval left pending), convert with ignoreIncompleteToolCalls set to true. 3. If you build model messages by hand, make sure every tool-call has a tool-result with the same toolCallId in the next message. 4. Open a new, small reproduction (as the maintainers do) before filing a new issue.
Another issue, #21895, shows a different trigger (a gateway-executed tool and a client tool call in the same turn); it closed as completed on 2026-10-29, with the closing comment reporting resolution (checked 2026-11-14), so a 400 with the same text does not always have the cause above.
Sources
- AI SDK issue 8516 and all comments were read through the GitHub API. Checked: opened 8 September 2025 with ai 5.0.37 and anthropic 2.0.14; contributor proposal #8524; gr2m and lgrammel responses questioning fixture ordering; later parallel-call reports; bot reproductions on 9 October 2026; gr2m's closure that day because it could no longer be reproduced.
- PR 22467 was read through the API. Checked: contributor bot authorship, release-v6.0 versions 6.0.302 and 3.0.128, message ordering, complete grouped results, incomplete-call filtering and the substituted model. Its reported live tests were not repeated here.
- convertToModelMessages reference was read. Checked: ignoreIncompleteToolCalls skips calls without results when true and defaults to false.
- Issue 21895 was read through the API, including its body. Checked 2026-11-14: closed as completed on 2026-10-29, with the closing comment reporting resolution; gateway/client mixed-tool ordering trigger, reported ai 7.0.93 and gateway 4.0.75.
No SDK code or model calls were run.
Started from a post by @vercel/ai GitHub issue 8516, packaged by the editor. Original post