Weird error with toolcalling on local model #4090

Open
opened 2026-02-16 17:42:34 -05:00 by yindo · 1 comment
Owner

Originally created by @pwilkin on GitHub (Jan 2, 2026).

Originally assigned to: @rekram1-node on GitHub.

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

Originally created by @pwilkin on GitHub (Jan 2, 2026). Originally assigned to: @rekram1-node on GitHub. ### 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
yindo added the bug label 2026-02-16 17:42:34 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 2, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #4255: OpenCode v1.0.25 Hangs Indefinitely with LM Studio + Qwen Models Due to Empty tool_calls Array - describes similar tool calling issues with local models and provides detailed investigation
  • #234: Tool Calling Issues with Open Source Models in OpenCode - documents compatibility challenges with tool calling on various local models
  • #1880: Opencode with GLM 4.5 String issue - related AI_InvalidResponseDataError with streaming responses
  • #5694: Local Ollama models are not agentic - reports tool calling failures with local Ollama models

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 2, 2026): This issue might be a duplicate of existing issues. Please check: - #4255: OpenCode v1.0.25 Hangs Indefinitely with LM Studio + Qwen Models Due to Empty tool_calls Array - describes similar tool calling issues with local models and provides detailed investigation - #234: Tool Calling Issues with Open Source Models in OpenCode - documents compatibility challenges with tool calling on various local models - #1880: Opencode with GLM 4.5 String issue - related AI_InvalidResponseDataError with streaming responses - #5694: Local Ollama models are not agentic - reports tool calling failures with local Ollama models Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4090