fix(provider): ensure non-empty assistant content for openai-compatible (#33280) - #33899
fix(provider): ensure non-empty assistant content for openai-compatible (#33280)#33899Haohao-end wants to merge 1 commit into
Conversation
…le (anomalyco#33280) When an assistant message carries only tool calls the Vercel AI SDK emits content: "" on the wire. Proxies that sit between opencode and the upstream LLM (e.g. GLM-5.2 gateways) sanitise empty content by injecting a visible placeholder — "[System: Empty message content sanitised to satisfy protocol]" — which then leaks into the stored conversation on every tool-call turn. The fix prepends a single-space text part to assistant messages that have tool-call parts but no non-empty text part, but only for @ai-sdk/openai-compatible providers. This keeps the wire content non-empty without altering the model's intent or touching persisted session history.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Heads-up: related PR #38270 (for #37946) overlaps with this one — analysis posted at #38270 (comment). Short version: this PR's |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #33280
Type of change
What does this PR do?
When an assistant message contains only tool calls (no text), the Vercel AI SDK emits
content: ""on the wire. OpenAI-compatible proxies (e.g. GLM-5.2 via api.svips.org) sanitise empty content by injecting a visible placeholder —[System: Empty message content sanitised to satisfy protocol]— which then leaks into the stored conversation on every tool-call turn.The fix adds a targeted transform for
@ai-sdk/openai-compatiblethat prepends a single-space text part to assistant messages that have tool-call parts but no non-empty text part. This keeps the wire content non-empty so the proxy passes it through unchanged. The space is ephemeral — it only exists in the messages handed to the provider, not in persisted session history.How did you verify your code works?
Added 4 regression tests in
test/provider/transform.test.ts:All 4 tests pass. Existing anthropic/bedrock empty-content tests unchanged (9/9 pass). Typecheck clean.
Checklist