Skip to content

fix(provider): generate fallback ID for tool calls missing 'id' in streaming - #25925

Closed
ctharvey wants to merge 1 commit into
anomalyco:devfrom
ctharvey:dev
Closed

fix(provider): generate fallback ID for tool calls missing 'id' in streaming#25925
ctharvey wants to merge 1 commit into
anomalyco:devfrom
ctharvey:dev

Conversation

@ctharvey

Copy link
Copy Markdown

Problem

Providers like NVIDIA (moonshotai/kimi-k2.5) omit the id field in streaming tool_calls deltas, causing InvalidResponseDataError: Expected 'id' to be a string. crashes. This breaks any MCP tool call when using these providers.

Root Cause

In openai-compatible-chat-language-model.ts:541, the streaming path threw InvalidResponseDataError when toolCallDelta.id == null. However, the non-streaming path already uses generateId() as a fallback (lines 247, 591, 634, 668).

Fix

Replace the throw with generateId() + console.warn, consistent with the existing pattern:

// Beforeif(toolCallDelta.id==null){thrownewInvalidResponseDataError({ ... })}// Afterif(toolCallDelta.id==null){toolCallDelta.id=generateId()console.warn(`[openai-compatible] Tool call missing 'id', generated fallback: ${toolCallDelta.id}`)}

generateId was already imported from @ai-sdk/provider-utils (line 17).

Testing

  • 3 new regression tests covering: single missing ID, preserved real ID, and multiple missing IDs
  • All 11 existing copilot provider tests still pass

Impact

  • Providers that include id — no behavior change
  • Providers that omit id — tool calls now succeed instead of crashing

… in streaming responses
Providers like NVIDIA/Kimi K2.5 omit the 'id' field in streaming tool_call
deltas, causing InvalidResponseDataError crashes. The non-streaming path
already uses generateId() as a fallback. This change brings the streaming
path in line with that pattern, generating a fallback ID and logging a
warning instead of throwing.
@github-actionsgithub-actionsBot added the needs:compliance This means the issue will auto-close after 2 hours. label May 5, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

Related PRs (not duplicates):

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actionsgithub-actionsBot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 6, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@ctharvey