Repository navigation
Description
TanStack AI version
0.44.1
Framework/Library version
Framework agnostic | @tanstack/ai-groq: 0.6.0
Describe the bug and the steps to reproduce it
When Groq rejects model-generated tool arguments against the provider-facing tool schema, it returns HTTP 400 with code: "tool_use_failed" before emitting a tool call. The structured error includes the attempted call in failed_generation:
{
"message": "Tool call validation failed: parameters for tool lookupUser did not match schema: additional properties 'role' not allowed",
"type": "invalid_request_error",
"code": "tool_use_failed",
"failed_generation": "{\"name\":\"lookupUser\",\"arguments\":{\"email\":\"[email protected]\",\"role\":\"admin\"}}"
}The Groq adapter delegates streaming to the OpenAI-compatible Chat Completions adapter: text.ts#L43-L62. Its tool converter enables strict mode for compatible schemas and sets additionalProperties: false: chat-completions-tool-converter.ts#L20-L82. Extra properties and other provider-side schema violations can therefore reject the request before TanStack receives a ToolCall.
The Chat Completions adapter catches the provider error and emits RUN_ERROR with the structured body in rawEvent: chat-completions-text.ts#L74-L136. Core treats every RUN_ERROR as terminal: index.ts#L1449-L1451 and index.ts#L1556-L1560. No tool result reaches the model, so it cannot repair the rejected arguments.
This differs from a tool call that reaches TanStack and then fails its Standard Schema. That failure becomes an output-error associated with the call and can continue through the agent loop: tool-calls.ts#L830-L850 and index.ts#L1873-L1923. Provider rejection happens before that validation path exists.
Expected behavior
A Groq tool_use_failed error with a parseable failed_generation should become a non-executed output-error associated with the attempted tool call. The next model iteration should receive the attempted call and Groq's validation message, including additional-property errors, so it can repair the arguments within the configured agent-loop limits.
The rejected tool must not execute, even if its arguments would pass local validation. Unrelated RUN_ERROR events and malformed or unparseable failed_generation values should remain terminal.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Activity
fix(ai): recover provider-rejected tool calls
fix(ai | ai-groq): recover provider-rejected tool calls (TanStack#1139)