Skip to content

V2: "Invalid opencode-go/openai-compatible-chat stream event" on tool calls — all models (opencode-go + GPT provider) #40690

Closed

Description

@tlg8

What happened

After migrating from OpenCode V1 CLI to V2 (opencode2 v0.0.0-next-16804), every agent turn that involves tool calls (tool execution) fails with:

AI.Error: ProviderShared.stream: Invalid opencode-go/openai-compatible-chat stream event

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

9 occurrences of this error in the log.

Environment

  • OpenCode version: opencode2 v0.0.0-next-16804
  • Providers affected: opencode-go (all models), openai GPT provider (gpt-5.6 etc.)
  • OS: Ubuntu Linux 26.04
  • Migration: V1 → V2 CLI

Activity

  1. 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
  2. github-actions commented on Aug 5, 2026

    @github-actions
    Contributor

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

    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.

  3. tlg8 commented on Aug 5, 2026

    @tlg8
    Author

    Checked the flagged issues:

    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.

  4. opencode-agent commented on Aug 6, 2026

    @opencode-agent
    Contributor

    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.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions