#tool_call_id error

1 messages · Page 1 of 1 (latest)

shrewd umbra
#

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
soft girder
#

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

soft girder
#

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

soft girder
#

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

shrewd umbra
#

one more: https://dagger.cloud/dagger/traces/871543068a87dbf03142e8eea893dcaf

Error ──────────────────────────────────────────────────────────────────────╮                                                          
│ Failed to convert result to primitive values: unknown error (googleapi:      │                                                          
│ Error 503:)                                                                  │                                                          
╰──────────────────────────────────
soft girder
soft girder
limpid plume
#

👋 I'm hitting this too on OpenAI (gpt-4o) on latest llm branch

robust turret
#

I'm seeing this with Anthropic too thinkspin

 ! 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'}"}}
soft girder
#

something getting dropped somewhere thinkies

coral ridge
limpid plume
#

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

tough hare
limpid plume
#

it was a pretty long session, but it happened after retrieving objects of different types. let me get the trace

tough hare
#

can't compile the engine in the hotel 😿

tough hare
#

Spinning up a Cloud VM to fix all related issues, for the weekend

tough hare
#

Will take a look tomorrow, I can repro -- probably what Kyle said

limpid plume
#

Thank you @tough hare ! 🙏

soft girder
soft tendon
#

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

robust turret
#

i have this repro'd while working on llm tests, looking into it now

robust turret
#

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

limpid plume
robust turret
#

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)