Potential cause for tool calling failures

#22
by liebedan - opened

Hi,
I'm running a GGUF version of this model with llama.cpp and did some tests with VS Code and the GitHub Copilot Chat talking to this instance.
Like many other people on different sites I have huge issues with tool calls. But I might have found the root cause.

A quite simple prompt with a question about the code base triggers the VSC tool "grep_search". The thinking points that it wants to use it. And I see in llama.cpp logs that it actually generates the tool call, but in the VS Code Chat it just stops.

This is the generated tool call according to llama.cpp verbose logs:
Parsed message: {"role":"assistant","content":"\n","tool_calls":[{"type":"function","function":{"name":"grep_search","arguments":"{\"query\":\"garbage_schedule\",\"isRegexp\":True,\"includePattern\":\"*.py\"}"}}]}

Look at it closely! It puts True to the isRegexp argument. This is not valid JSON! (RFC8256) It is python-esque. JSON would be lowercase true. I suspect that VS Code silently fails the parsing and just stops. I had instances where the model left out this very argument, VS Code executed the tool call but it failed for the missing argument. In these cases the model retried with the argument and the same "silent error" happened.

According to the very detailed llama.cpp verbose looks there is no doubt the model generates this mistake:
slot process_toke: id 0 | task 4277 | n_decoded = 16, n_remaining = 772, next token: 27438 '=True'

It also makes sense to me that the developers might not run into these problems, when their harness simply tolerates "True" and "False" in JSON. Maybe others can try to validate this.

Any feedback would be appreciated!

Best Regards
Daniel

Liquid AI org
edited Jun 5

Thanks for reporting, @liebedan . You are on point. The fix https://github.com/ggml-org/llama.cpp/pull/24178 for llama.cpp is ready, and I hope it lands in upstream soon.

Thank you, @tarek-liquid ! That's good news. I feared such an issue could only be solved with fine-tuning. I'm looking forward to trying the merged changes to the tool parser.

Liquid AI org

The PR has been merged, and the issue is now resolved.

tarek-liquid changed discussion status to closed

Sign up or log in to comment