You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
V2: "Invalid opencode-go/openai-compatible-chat stream event" on tool calls — all models (opencode-go + GPT provider) #40690
The error occurs at ../ai/src/protocols/shared.ts:91:7 and causes "Failed to drain Session".
This affects EVERY model — all opencode-go models (glm-5.2, qwen, deepseek) AND GPT provider models (gpt-5.6 and similar). Even /report in the TUI can't complete because the model response during that flow hits this same error.
This did not happen on V1 with the same providers/models.
Log excerpt
timestamp=2026-08-05T16:03:31.962Z level=ERROR run=093df16e message="Failed to drain Session" cause="AI.Error: ProviderShared.stream: Invalid opencode-go/openai-compatible-chat stream event
at n (../ai/src/protocols/shared.ts:91:7)
at ~effect/Utils/internal (../../node_modules/.bun/[email protected]/node_modules/effect/dist/Utils.js:89:16)
...
at SessionRunner.callModel (../core/src/session/runner/llm.ts:182:32)
...
at SessionRunner.drain (../core/src/session/runner/llm.ts:115:26)
..." role=server
changed the title [-]V2: "Invalid opencode-go/openai-compatible-chat stream event" on tool calls (GLM-5.2 with interleaved reasoning)[/-][+]V2: "Invalid opencode-go/openai-compatible-chat stream event" on tool calls — all models (opencode-go + GPT provider)[/+]on Aug 5, 2026
If your issue is distinct from these (e.g. it is specific to V2's opencode-go/openai-compatible-chat protocol path rather than a malformed chunk or named SSE event), please mention what you have already tried or ruled out so maintainers can distinguish the root cause quickly.
OpenAI-compatible cost chunk omits required stream fields #39061 (cost chunk missing fields): different — that's about Zen emitting {"choices":[],"cost":"0"} which omits required fields. My error fires on every tool call with every model, not just when a cost chunk arrives.
This is a systematic V2 protocol regression: the openai-compatible-chat stream parser in packages/ai/src/protocols/shared.ts:91 rejects stream events during tool calls across all models (glm-5.2, qwen, deepseek via opencode-go, and gpt-5.6 via GPT provider). V1 tolerated these; V2 does not. It happens on 100% of tool call turns — the TUI is effectively non-functional for agentic work.
Addressed by #40798. The native OpenAI-compatible Chat parser now accepts nullish usage and indexless tool-call deltas, resolves missing indexes through persistent call IDs plus parallel/sparse stream state, preserves provider-specific usage metadata, and validates terminal ordering without rejecting the affected tool-call streams. The PR directly names this issue and includes 64 focused OpenAI Chat, compatible-Chat, and ToolStream regressions plus the broader AI suite. Closing as resolved on the v2 branch.
Activity
[-]V2: "Invalid opencode-go/openai-compatible-chat stream event" on tool calls (GLM-5.2 with interleaved reasoning)[/-][+]V2: "Invalid opencode-go/openai-compatible-chat stream event" on tool calls — all models (opencode-go + GPT provider)[/+]github-actions commentedon Aug 5, 2026
This issue might be a duplicate of existing issues. Please check:
Invalid … stream eventerror classevent:field — custom server events crash Chat Completions stream with TypeValidationError #38106: AI SDK ignores SSEevent:field — custom server events crash Chat Completions stream with a validation error on tool-call turnsIf your issue is distinct from these (e.g. it is specific to V2's
opencode-go/openai-compatible-chatprotocol path rather than a malformed chunk or named SSE event), please mention what you have already tried or ruled out so maintainers can distinguish the root cause quickly.tlg8 commentedon Aug 5, 2026
Checked the flagged issues:
{"choices":[],"cost":"0"}which omits required fields. My error fires on every tool call with every model, not just when a cost chunk arrives.event:field — custom server events crash Chat Completions stream with TypeValidationError #38106 (named SSEevent:field): different — that's about custom providers sending non-chat-completion SSE frames. I'm using opencode-go (Zen) and GPT provider — no custom SSE events involved.This is a systematic V2 protocol regression: the
openai-compatible-chatstream parser inpackages/ai/src/protocols/shared.ts:91rejects stream events during tool calls across all models (glm-5.2, qwen, deepseek via opencode-go, and gpt-5.6 via GPT provider). V1 tolerated these; V2 does not. It happens on 100% of tool call turns — the TUI is effectively non-functional for agentic work.opencode-agent commentedon Aug 6, 2026
Addressed by #40798. The native OpenAI-compatible Chat parser now accepts nullish usage and indexless tool-call deltas, resolves missing indexes through persistent call IDs plus parallel/sparse stream state, preserves provider-specific usage metadata, and validates terminal ordering without rejecting the affected tool-call streams. The PR directly names this issue and includes 64 focused OpenAI Chat, compatible-Chat, and ToolStream regressions plus the broader AI suite. Closing as resolved on the v2 branch.