Skip to content

Mid-stream Groq tool_use_failed errors bypass rejected-tool-call recovery #1172

Closed

Description

@kolaworld

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

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://stackblitz.com/edit/vitejs-vite-9dzdnp2a?file=package.json,index.html,src%2Fmain.ts

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

  1. added
    waiting-on: maintainer
    on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting-on: maintainer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions