Skip to content

Weird error with toolcalling on local model #6649

Closed

Description

@pwilkin

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

Activity

  1. github-actions commented on Jan 2, 2026

    @github-actions
    Contributor

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

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

  2. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  3. nunodonato commented on Apr 16, 2026

    @nunodonato

    also getting this with qwen3.5 and xml tool parser

  4. wattmto commented on Apr 28, 2026

    @wattmto

    Since vercel/ai#14760 was merged, it might be fixed once it's released and pulled into OpenCode.

  5. removed
    bugSomething isn't working
    on May 3, 2026
  6. dfischer-mw commented on May 12, 2026

    @dfischer-mw

    Since vercel/ai#14760 was merged, it might be fixed once it's released and pulled into OpenCode.

    Was it tho? Getting same error still.

  7. pwilkin commented on May 12, 2026

    @pwilkin
    Author

    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).

  8. Acsriot94 commented on May 28, 2026

    @Acsriot94

    Getting this error constnatly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions