Moonshotai/kimi-k2-instruct-0905 errors with tool calls

I’ve received an error

{
“error”: {
“message”: “Failed to call a function. Please adjust your prompt. See ‘failed_generation’ for more details.”,
“type”: “invalid_request_error”,
“code”: “tool_use_failed”,
“failed_generation”: “<|tool_calls_section_begin|><|tool_calls_section_begin|> función check_check_availability:0 = {“appointment_type”: “consultation”, “start_time”: “This Friday 8am”, “end_time”: “This Friday 11pm”}<|tool_call_end|><|tool_calls_section_end|>”
}
}

Is there any way I can reduce these errors from happening?

2 Likes

@yawnxyz I would love some support on this a lack of function call reliability is killing my use case

Hi!

Thanks for reporting the error; could you give me the entire curl for reproducing the error? Specifically I’d like to know model/temp/etc. so I can reproduce it.

Also, do you get this error every time, or a small subset of API calls?
Also, is your system prompt in Spanish by any chance?

No system prompt is not in spanish it is a subset of errors i.e. 90%+ are fine and its in a huge system that is constantly changing the request so I wouldbn’t be able to give you the exact curl request I am seeing it essentially try to function call but not quite doing the tool format the correct way

Same issue, and its consistently breaking at <|tool_calls_section_begin|>, this has been happening from 2 days.

There are several Groq model adding ".<|tool_calls_section_begin|>" and halting · Issue #2639 · sst/opencode · GitHub people who have stopped using Groq cloud because of this.

thanks for reporting everyone — really appreciate the opencode link too, I’ll investigate and flag this to engineering.

1 Like

hi @HugoPodw – we’re actively working on many pieces of work to improve tool calling, specifically a new effort with constrained decoding which we’re hoping that lands in the next couple months. that new feature should resolve your errors and i’ll let you know when that lands.

in the meantime, @shreyas and @asharifr – we’ve updated our tool call parsing to be more aggressive in detecting when a model tried to call a tool and failed, so you should get a 400 error in the above case and you can use client-side retries to re-run the request.

2 Likes