Skip to content

Bundled @ai-sdk/openai-compatible is a pre-3.0.0 copy — still throws "Expected 'function.name' to be a string" (fix exists upstream; interim plugin) #52462

Closed as not planned

Description

@nazerim

Description

Custom @ai-sdk/openai-compatible providers still abort turns with AI_InvalidResponseDataError: Expected 'function.name' to be a string. whenever the server opens a streaming tool_calls delta with function.name: null (common on DashScope token-plan with Qwen models; also vLLM qwen3_xml and some llama.cpp configs).

The upstream SDK has been fixed — vercel/ai#18440 → PR #18445. Verified by grepping published tarballs: the throw string ships in 1.x/2.x (sampled 1.0.0, 2.0.0, 2.0.7) and is gone from 3.0.0 onward (checked 3.0.0, 3.0.62); behaviorally confirmed by feeding the malformed stream to [email protected]'s doStream (no throw, correct buffered tool-call).

But opencode 1.18.34's compiled binary still contains the pre-fix code (/$bunfs/root/chunk-*.js: if(((w=F.function)==null?void 0:w.name)==null) throw new r({data:F,message:"Expected 'function.name' to be a string."})).

The prior reports point at each other and all closed — #26412 (duplicate), #24137 ("file against vercel/ai" — which then fixed it), #31295 (duplicate). Request: bump the bundled @ai-sdk/openai-compatible to a post-3.0.0 version. Same pattern as PR #49689, which bumps @ai-sdk/mistral "to unbreak streamed tool calls".

Plugins

toolcall-guard (my interim workaround — https://github.com/nazerim/toolcall-guard, MIT, plugin-only): fetch-wrapped stream guard, outbound history scrubber (replayed ChatML tokens re-arm the provider's parser every turn), and auto-continue for turns the provider silently truncates with a clean finish_reason:"stop". Without it (opencode run --pure) the repro throws.

OpenCode version

1.18.34. Local error history spans 1.18.16 (2026-08-12), 1.18.26 (2026-09-27 → 10-01) and 1.18.34 (2026-10-01); #26412 reports the identical throw on 1.14.41.

Steps to reproduce

Deterministic, synthetic SSE server — no real API key needed:

git clone https://github.com/nazerim/toolcall-guard && cd toolcall-guard
SCENARIO=late PORT=8787 node test/toolcall-guard-server.mjs &
OPENCODE_CONFIG=$PWD/test/toolcall-guard-test.opencode.json \
  opencode run --pure --auto -m guardtest/guardtest-model "say hi MARKER7788"
# → Error: Expected 'function.name' to be a string.

Drop --pure with plugins/toolcall-guard.js installed and the same stream is repaired (tool executes, turn survives).

Screenshot and/or share link

n/a — deterministic CLI repro above; error + stack land in the opencode log.

Operating System

macOS 26.6.2 (arm64, homebrew build)

Terminal

Ghostty

Activity

  1. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Please use the Bug Report issue template and include the report in its required Description field; the current body uses custom sections rather than the required template format.

    Please edit this issue to address the above within 72 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

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

  2. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

    Thanks for updating the report. It still does not use the Bug Report issue template: the body has custom sections but no required Description field. Please update it with the Bug Report template and put the concise problem description and reproduction context in that field. The needs:compliance label remains until then.

  3. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

    Thanks for updating the report. It now meets the Bug Report requirements.

  4. 0xsarawut-eth commented on Oct 1, 2026

    @0xsarawut-eth

    Description

    Coinbase.wallet/0xb9b7a70a785629f9914f46f2e649eb6120663666
    Custom @ai-sdk/openai-compatible providers still abort turns with AI_InvalidResponseDataError: Expected 'function.name' to be a string. whenever the server opens a streaming tool_calls delta with function.name: null (common on DashScope token-plan with Qwen models; also vLLM qwen3_xml and some llama.cpp configs).

    The upstream SDK has been fixed — vercel/ai#18440 → PR #18445. Verified by grepping published tarballs: the throw string ships in 1.x/2.x (sampled 1.0.0, 2.0.0, 2.0.7) and is gone from 3.0.0 onward (checked 3.0.0, 3.0.62); behaviorally confirmed by feeding the malformed stream to [email protected]'s doStream (no throw, correct buffered tool-call).

    But opencode 1.18.34's compiled binary still contains the pre-fix code (/$bunfs/root/chunk-*.js: if(((w=F.function)==null?void 0:w.name)==null) throw new r({data:F,message:"Expected 'function.name' to be a string."})).

    The prior reports point at each other and all closed — #26412 (duplicate), #24137 ("file against vercel/ai" — which then fixed it), #31295 (duplicate). Request: bump the bundled @ai-sdk/openai-compatible to a post-3.0.0 version. Same pattern as PR #49689, which bumps @ai-sdk/mistral "to unbreak streamed tool calls".

    Plugins

    toolcall-guard (my interim workaround — https://github.com/nazerim/toolcall-guard, MIT, plugin-only): fetch-wrapped stream guard, outbound history scrubber (replayed ChatML tokens re-arm the provider's parser every turn), and auto-continue for turns the provider silently truncates with a clean finish_reason:"stop". Without it (opencode run --pure) the repro throws.

    OpenCode version

    1.18.34. Local error history spans 1.18.16 (2026-08-12), 1.18.26 (2026-09-27 → 10-01) and 1.18.34 (2026-10-01); #26412 reports the identical throw on 1.14.41.

    Steps to reproduce

    Deterministic, synthetic SSE server — no real API key needed:

    git clone https://github.com/nazerim/toolcall-guard && cd toolcall-guard
    SCENARIO=late PORT=8787 node test/toolcall-guard-server.mjs &
    OPENCODE_CONFIG=$PWD/test/toolcall-guard-test.opencode.json \
      opencode run --pure --auto -m guardtest/guardtest-model "say hi MARKER7788"
    # → Error: Expected 'function.name' to be a string.

    Drop --pure with plugins/toolcall-guard.js installed and the same stream is repaired (tool executes, turn survives).

    Screenshot and/or share link

    n/a — deterministic CLI repro above; error + stack land in the opencode log.

    Operating System

    macOS 26.6.2 (arm64, homebrew build)

    Terminal

    Ghostty

  5. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions