#tool_call_id error
1 messages · Page 1 of 1 (latest)
does anyone know why this happens?
╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ Failed to convert result to primitive values: unknown error (POST │
│ "https://api.openai.com/v1/chat/completions": 400 Bad Request { │
│ "error": { │
│ "message": "An assistant message with 'tool_calls' must be followed by │
│ tool messages responding to each 'tool_call_id'. The following tool_call_ids │
│ did not have response messages: call_Xu853iQF578wIwVFSLFJSKL3, │
│ call_r1JBviBwTjdQMlIVCgmUSTjN, call_GJVL2SDCpbojmb98gm0U5Z7l", │
│ "type": "invalid_request_error", │
│ "param": "messages", │
│ "code": null │
│ } │
│ }) │
╰──────────────────────────────────────────────────────────────────────────────╯
! process "/runtime" did not complete successfully: exit code: 1
I haven't seen that one. My guess was that maybe one of the tools doesn't return something but I don't see anything like that in the code you sent me
I actually just ran into a similar error on gemini. I suspect there's a regression in llm.go. Looking into this now
The gemini error: Please ensure that the number of function response parts should be equal to number of function call parts of the function call turn.. cc @robust turret @limpid plume
maybe from https://github.com/dagger/dagger/commit/4610cdf3698806628dff90f851f3af8b49454da2 ? I'm not seeing how they'd get mismatched yet
ok I think I figured it out with some debug logging.
- llm requested 2 tool calls
- we run both tool calls
- first call finishes, we send response
- llm errors and says wtf bro where's my other tool call
will work on a fix in the morning if nobody else beats me to it
one more: https://dagger.cloud/dagger/traces/871543068a87dbf03142e8eea893dcaf
Error ──────────────────────────────────────────────────────────────────────╮
│ Failed to convert result to primitive values: unknown error (googleapi: │
│ Error 503:) │
╰──────────────────────────────────
a 503 on google's end would be unrelated. We can maybe add a retry in this case but I doubt it would help
I figured out why this is happening in gemini (i think) but not sure why it's happening in openai yet
here's the fix for gemini https://github.com/dagger/dagger/pull/9765
👋 I'm hitting this too on OpenAI (gpt-4o) on latest llm branch
I'm seeing this with Anthropic too 
! POST "https://api.anthropic.com/v1/messages": 400 Bad Request {"type":"error","error":{"type":"invalid_request_error","message":"messages.8: the following `tool_use` ids were not found in `tool_result` blocks: {'toolu_01DEvNWxzyfcLyBP3Ue5jVLr'}"}}
something getting dropped somewhere 
fwiw I have this only with claude-3-7-sonnet-20250219 (claude-3-5-sonnet-20241022 is fine)
Got another one with gpt-4o
! POST "https://api.openai.com/v1/chat/completions": 400 Bad Request {
│ ! "error": {
│ ! "message": "An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'. The following tool_call_ids did not have response messages: call_ahCDjR2X3X2Oak3O39gRX02Q, call_g30fMmHbAaxbf5btnvXTvVB2, call_bGWC6LHCLMKk4HI35NJ
│ ! "type": "invalid_request_error",
│ ! "param": "messages",
│ ! "code": null
│ ! }
│ ! }
@tough hare I think we should prioritize fixing this. My gues is that it comes from multi-model support
taking a look
what command / agentic command do you run to get it ?
it was a pretty long session, but it happened after retrieving objects of different types. let me get the trace
can't compile the engine in the hotel 😿
Spinning up a Cloud VM to fix all related issues, for the weekend
Will take a look tomorrow, I can repro -- probably what Kyle said
Thank you @tough hare ! 🙏
Yeah the fix I found for Gemini was a bug in that implementation. I had a look at the openai implementation at the time and didn't see how it could be possible but it's definitely happening somehow
Have the same error with Anthropic as @limpid plume :
select: POST "https://api.anthropic.com/v1/messages": 400 Bad Request {"type":"error","error":{"type":"invalid_request_error","message":"messages.1: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_016P742i7P1Md9tv1eFvjkWR. Each `tool_use` block must have a corresponding `tool_result` block in the next message."}}
And yesterday, everything worked fine. I'm not sure what exactly has changed. I tried updating from llm.9 to llm.10, but now I'm getting the error on both versions.
Tried to use claude-3-5-sonnet-20241022 and claude-3-7-sonnet-20250219 but no luck.
Can share a link to the trace but don't know how to make it public
i have this repro'd while working on llm tests, looking into it now
found the issue. this broke with the addition of prompt caching, from a refactor to deal with their pretty annoying API for it.
but, looks like they have a new simpler API as of 5 days ago: https://www.anthropic.com/news/token-saving-updates - looking into this now, maybe it's time we bump to 3.7 sonnet?
pushed a fix without getting into all that, since i know 3.7 has lower token limits, maybe not worth it yet
curious what you mean by "bump" in this case? Do you mean the default anthropic model?
yeah our default is still 3.5
i tried bumping it locally before but hit token limits real quick
so, it might still be a sane default for cost/token saving reasons
(you can also of course set it yourself with .model or the API)