Skip to content

Custom OpenAI-compatible provider: "Expected 'function.name' to be a string" on streaming tool call chunks #26412

@mazingerzzz

Description

@mazingerzzz

Environment

  • OpenCode: 1.14.41
  • Provider: @ai-sdk/openai-compatible (custom, vLLM backend)
  • OS: Linux (Debian)

Description

When using a custom OpenAI-compatible provider with a vLLM backend, any tool call (Read, Edit, Bash…) fails immediately with:

Expected 'function.name' to be a string.

Root cause (confirmed via curl)

The OpenAI streaming spec sends function.name only in the first delta chunk; subsequent chunks carry "name": null. This is correct per the OpenAI API reference. OpenCode's AI SDK validates each chunk independently and rejects null as invalid.

Raw streaming response from the backend (reproduced with curl):

# Chunk 1 — name is a string ✓
data: {"choices":[{"delta":{"tool_calls":[{"index":0,"function":{"name":"read_file","arguments":""}}]}}]}

# Chunk 2 — name is null per OpenAI spec → OpenCode crashes here
data: {"choices":[{"delta":{"tool_calls":[{"index":0,"function":{"name":null,"arguments":"{\"path\": \"test"}}]}}]}

# Chunk 3
data: {"choices":[{"delta":{"tool_calls":[{"index":0,"function":{"name":null,"arguments":".py\""}}]}}]}

Adding "compatibility": "compatible" to the provider options has no effect.

Steps to reproduce

  1. Configure a custom provider with npm: "@ai-sdk/openai-compatible" pointing to any OpenAI-compatible backend that streams tool calls (vLLM, LM Studio, llama.cpp server, etc.)
  2. Ask the model to read or edit a file
  3. Error is thrown on the second streaming chunk

Expected behavior

function.name: null in non-first chunks should be accepted — the client should accumulate the name from the first chunk, as the OpenAI Python SDK and most other clients do.

Workaround

None found via provider options. Using Anthropic native providers is unaffected (different code path).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions