Skip to content

fix(groq): handle Llama models embedding arguments in function name#987

Open
obalaweb wants to merge 1 commit intoprism-php:mainfrom
obalaweb:fix/groq-malformed-tool-name
Open

fix(groq): handle Llama models embedding arguments in function name#987
obalaweb wants to merge 1 commit intoprism-php:mainfrom
obalaweb:fix/groq-malformed-tool-name

Conversation

@obalaweb
Copy link
Copy Markdown

Fixes #983

Llama models running on Groq (e.g. llama-3.3-70b-versatile) occasionally return tool calls where the entire argument payload is concatenated into the function.name field:

"function": { "name": "get_transactions,{"from_date":"2026-03-06"}", "arguments": "" }

Prism passes this mangled string as the ToolCall name. On the follow-up turn Groq validates the assistant message's tool_calls against the original request.tools list and rejects the request because "get_transactions,{...}" was never registered as a tool:

Groq Error [400]: tool call validation failed: attempted to call tool
'get_transactions,{"from_date":"..."}' which was not in request.tools

Fix: in mapToolCalls(), detect the "name,{...}" pattern, validate the suffix is valid JSON, and split into a clean name + arguments string.

Llama models running on Groq (e.g. llama-3.3-70b-versatile) occasionally
return tool calls where the entire argument payload is concatenated into
the function.name field:

  "function": { "name": "get_transactions,{\"from_date\":\"2026-03-06\"}", "arguments": "" }

Prism passes this mangled string as the ToolCall name. On the follow-up
turn Groq validates the assistant message's tool_calls against the
original request.tools list and rejects the request because
"get_transactions,{...}" was never registered as a tool:

  Groq Error [400]: tool call validation failed: attempted to call tool
  'get_transactions,{"from_date":"..."}' which was not in request.tools

Fix: in mapToolCalls(), detect the "name,{...}" pattern, validate the
suffix is valid JSON, and split into a clean name + arguments string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Groq] Llama models embed arguments in function.name causing 400 on follow-up turn

1 participant