Skip to content

fix(groq): accept string values for boolean/number tool parameters#986

Open
obalaweb wants to merge 1 commit intoprism-php:mainfrom
obalaweb:fix/groq-boolean-number-string-types
Open

fix(groq): accept string values for boolean/number tool parameters#986
obalaweb wants to merge 1 commit intoprism-php:mainfrom
obalaweb:fix/groq-boolean-number-string-types

Conversation

@obalaweb
Copy link
Copy Markdown

Fixes #984
Llama models on Groq (e.g. llama-3.3-70b-versatile) serialize all tool call arguments as JSON strings regardless of the declared schema type. Groq validates the model output against the schema we send and rejects any mismatch before returning it to the caller:

Groq Error [400]: tool call validation failed: parameters for tool
get_transactions did not match schema: errors: [
/is_cash_in: expected boolean, but got string,
/limit: expected number, but got string
]

Fix: wrap boolean, number, and integer property types in anyOf so that Groq accepts either the declared type or a plain string from the model. The caller is responsible for coercing string values to the expected PHP type before invoking the tool handler.

Llama models on Groq (e.g. llama-3.3-70b-versatile) serialize all tool
call arguments as JSON strings regardless of the declared schema type.
Groq validates the model output against the schema we send and rejects
any mismatch before returning it to the caller:

  Groq Error [400]: tool call validation failed: parameters for tool
  get_transactions did not match schema: errors: [
    `/is_cash_in`: expected boolean, but got string,
    `/limit`: expected number, but got string
  ]

Fix: wrap boolean, number, and integer property types in anyOf so that
Groq accepts either the declared type or a plain string from the model.
The caller is responsible for coercing string values to the expected
PHP type before invoking the tool handler.
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 return string values for boolean/number parameters, Groq rejects with 400

1 participant