Repository navigation
Description
TanStack AI version
0.46.0
Framework/Library version
@tanstack/ai-groq: 0.6.3 | @tanstack/openai-base: 0.9.14
Describe the bug and the steps to reproduce it
The OpenAI-compatible Chat Completions adapter applies provider-specific rejected-tool-call recovery only when creating the response stream throws.
A Groq tool_use_failed error delivered after streaming begins is caught inside processStreamChunks() and converted directly to RUN_ERROR, without invoking the same recovery hook.
The outer chatStream() catch calls extractRejectedToolCall() and converts a reconstructable rejected call into a non-executable output-error: chat-completions-text.ts#L96-L162.
The inner stream-processing catch instead emits RUN_ERROR immediately: chat-completions-text.ts#L1138-L1166.
Groq can deliver provider errors as an error event while an established stream is being consumed. A tool_use_failed payload with a parseable failed_generation therefore terminates the run when delivered mid-stream, even though the same payload is recoverable when the initial request rejects before a stream exists.
Expected behavior
Provider-specific rejected-tool-call classification should apply consistently to errors raised while creating and consuming a response stream.
When Groq supplies a reconstructable tool call, the adapter should emit the same non-executable output-error sequence in both paths. The rejected tool must not execute, and the agent loop should receive Groq's error so it can repair the arguments within its configured iteration limits.
Unrelated provider errors and malformed or non-reconstructable failed_generation values should continue to emit terminal RUN_ERROR events. The two catch paths should share the recovery emission logic so their behavior cannot drift.
Related issues fixed
- Issue Groq
tool_use_failederrors terminate the agent loop instead of returning an error result #1138 and PR fix(ai | ai-groq): recover provider-rejected tool calls #1139 added the recovery hook for a provider rejection that occurs before a response stream exists. They do not apply that hook to errors raised while consuming an established stream.
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