Skip to content

fix(opencode): synthesize missing tool-call IDs in openai-compatible streaming - #47954

Open
lloeki wants to merge 1 commit into
anomalyco:devfrom
lloeki:openai-compatible-tool-ids
Open

fix(opencode): synthesize missing tool-call IDs in openai-compatible streaming#47954
lloeki wants to merge 1 commit into
anomalyco:devfrom
lloeki:openai-compatible-tool-ids

Conversation

@lloeki

@lloeki lloeki commented Sep 8, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #43199

Type of change

  • Bug fix

What does this PR do?

The @ai-sdk/openai-compatible streaming parser throws when a tool-call delta arrives without an id field. This crashes GLM-5.2 (served via Mistral's OpenAI-compatible endpoint) on any tool call.

The SDK is inconsistent: the non-streaming path (line 603) and the streaming flush path (line 880) already fall back to generateId() when id is missing. Only the streaming first-chunk path (line 769) throws. This patch replaces the throw with the same generateId() fallback, making all three paths consistent.

How did you verify your code works?

Added packages/core/test/provider-openai-compatible.test.ts with two tests:

  • Streams tool-call deltas without id — asserts no errors, synthesized IDs are stable across fragments, and tool-call accumulation works
  • Streams tool-call deltas with id — asserts provided IDs are preserved

Also verified live with GLM-5.2 on Mistral (tool calls succeed with the patch applied).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…streaming

The @ai-sdk/openai-compatible streaming parser throws when a tool-call
delta arrives without an id field. The non-streaming and flush paths
already fall back to generateId(). This makes the streaming first-chunk
path consistent.

Closes anomalyco#43199
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.

Tool calls throw errors for Mistral's GLM-5.2

1 participant