Skip to content

[V2] xAI: Responses WebSocket fails after tool calls #48227

Description

@mrodhansen

Description

xAI sessions fail after the first tool call when Responses WebSockets are enabled. The initial response and tool execution succeed, but OpenCode's incremental response.create includes both instructions and previous_response_id.

xAI rejects that combination, then OpenCode masks the provider error as Invalid xAI Responses WebSocket event because xAI's error envelope has no top-level type.

A pass-through WebSocket probe captured:

{"error":{"message":"Request validation error: Argument not supported: instructions and previous_response_id together","type":"api_error"}}

This reproduces consistently on beta-19398 and dev-19405. dev-19390 passes and dev-19391 is the first failing published build, corresponding to #48140 (bdc143c1d5caa9571106233dd3014242f5c126ec), which enabled Responses WebSockets by default.

Expected: the tool result is sent and the model completes the response.

Actual: the continuation aborts with the generic WebSocket event error.

Disabling xAI WebSockets makes the identical request pass:

{"providers":{"xai":{"websocket":false}}}

Plugins

None configured

OpenCode version

0.0.0-beta-19398
Also reproduced on 0.0.0-dev-19405

Steps to reproduce

  1. Authenticate the xAI provider and use xai/grok-4.6 with the default WebSocket setting.
  2. Run:
    opencode2 run --standalone --model "xai/grok-4.6" -- "Run pwd with the shell tool, then reply with exactly DONE"
  3. The tool succeeds, then the continuation fails with:
    Invalid xAI Responses WebSocket event
    

Screenshot and/or share link

Not provided; the minimal standalone reproduction above is consistent.

Operating System

macOS 26 / Darwin 25.6.0 (arm64)

Terminal

WezTerm (TERM=xterm-256color)

Activity

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