-
-
Notifications
You must be signed in to change notification settings - Fork 290
[Groq] Llama models embed arguments in function.name causing 400 on follow-up turn #983
Description
Bug Report
Summary
Llama models on Groq occasionally return tool calls where the full argument
payload is concatenated into function.name instead of function.arguments.
Prism passes the mangled name through unchanged, and Groq rejects the
follow-up turn with a 400 because the name was never registered as a tool.
Steps to Reproduce
- Configure Prism with Groq + llama-3.3-70b-versatile
- Register a tool with parameters (e.g. date range filters)
- Ask a question that triggers a tool call with arguments
- The first response may succeed, but the follow-up turn fails with a 400
Groq Response (malformed)
{
"function": {
"name": "get_transactions,{"from_date":"2026-03-06","limit":"10"}",
"arguments": ""
}
}
Error
Groq Error [400]: invalid_request_error - tool call validation failed:
attempted to call tool
'get_transactions,{"from_date":"2026-03-06","limit":"10"}'
which was not in request.tools
Root Cause
The Llama model is generating a non-standard tool call format. Prism's
mapToolCalls() in the Groq handler passes function.name through as-is,
so the mangled string becomes the ToolCall name. When Prism sends the
assistant message back on the next turn, Groq validates the tool_calls
against the original request.tools and finds no match.
Expected Behaviour
Prism should detect and recover from this model quirk so the conversation
can continue normally.
Suggested Fix
In Providers/Groq/Handlers/Text.php::mapToolCalls(), detect the pattern
and split the name from the inline arguments:
if (is_string($name) && str_contains($name, ',{')) {
[$extractedName, $inlineArgs] = explode(',', $name, 2);
if (json_decode($inlineArgs) !== null) {
$name = $extractedName;
$arguments = $inlineArgs;
}
}
Environment
- Provider: Groq
- Model: llama-3.3-70b-versatile
- Prism: v0.99.22