Repository navigation
Weird error with toolcalling on local model #6649
Copy link
Copy link
Closed
Description
Description
I was testing a local model (IQuest-Coder-40B-Instruct) to check how well it handles agentic coding. However, in OpenCode I'm getting:
AI_InvalidResponseDataError: Expected 'function.name' to be a string.
I thought it was the model being obtuse or maybe my parser not working correctly (I'm using an experimental parser for Llama.cpp), so I put an MITM proxy to capture the deltas. Here are the logs:
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"role":"assistant","content":null}}],"created":1767366981,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"id":"TeCh7VHcc8zpP5G4zN5f0NKRppnBIOwT","type":"function","function":{"arguments":""}}]}}],"created":1767366982,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"id":"TeCh7VHcc8zpP5G4zN5f0NKRppnBIOwT","type":"function","function":{"name":"bash","arguments":"{"}}]}}],"created":1767366985,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\""}}]}}],"created":1767366988,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"command"}}]}}],"created":1767366988,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]}}],"created":1767366989,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" \""}}]}}],"created":1767366990,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"ls"}}]}}],"created":1767366990,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" -"}}]}}],"created":1767366991,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"la"}}]}}],"created":1767366991,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\","}}]}}],"created":1767366992,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" \""}}]}}],"created":1767366992,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"description"}}]}}],"created":1767366993,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\":"}}]}}],"created":1767366994,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" \""}}]}}],"created":1767366994,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"List"}}]}}],"created":1767366996,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" files"}}]}}],"created":1767366997,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" in"}}]}}],"created":1767366997,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" current"}}]}}],"created":1767366998,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":" directory"}}]}}],"created":1767366998,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":null,"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"}"}}]}}],"created":1767367000,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[{"finish_reason":"tool_calls","index":0,"delta":{}}],"created":1767367005,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk"}
data: {"choices":[],"created":1767367005,"id":"chatcmpl-q7mP1rgtuJhfQWiVh6lrBQsS4SZcuwKT","model":"IQuest-Coder-V1-40B-Instruct-IQ4_XS.gguf","system_fingerprint":"b7638-73c7088d3","object":"chat.completion.chunk","usage":{"completion_tokens":31,"prompt_tokens":11020,"total_tokens":11051},"timings":{"cache_n":10245,"prompt_n":775,"prompt_ms":225787.145,"prompt_per_token_ms":291.3382516129032,"prompt_per_second":3.432436332901061,"predicted_n":31,"predicted_ms":23536.925,"predicted_per_token_ms":759.2556451612903,"predicted_per_second":1.3170794400712922}}
data: [DONE]
This looks to be a perfectly valid tool call - why isn't it getting accepted?
OpenCode version
1.0.223
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
Ubuntu 25.10
Terminal
Terminology
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Jan 2, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
thdxr commentedon Mar 25, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.
nunodonato commentedon Apr 16, 2026
also getting this with qwen3.5 and xml tool parser
wattmto commentedon Apr 28, 2026
Since vercel/ai#14760 was merged, it might be fixed once it's released and pulled into OpenCode.
dfischer-mw commentedon May 12, 2026
Was it tho? Getting same error still.
pwilkin commentedon May 12, 2026
FWIW, the reason for this was the sending of a tool call block without the function name in the first chunk. This is not incorrect per OpenAI spec, but I nevertheless patched the llama.cpp parser not to do that (it now waits until it has function name and always sends it in the first chunk).
Acsriot94 commentedon May 28, 2026
Getting this error constnatly.