Skip to content

feat(opencode): add experimental OpenAI Responses WebSocket#29394

Draft
mugnimaestra wants to merge 3 commits into
anomalyco:devfrom
mugnimaestra:openai-websocket-transport-fresh
Draft

feat(opencode): add experimental OpenAI Responses WebSocket#29394
mugnimaestra wants to merge 3 commits into
anomalyco:devfrom
mugnimaestra:openai-websocket-transport-fresh

Conversation

@mugnimaestra
Copy link
Copy Markdown
Contributor

Issue for this PR

Refs #29079
Refs #14891

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds an opt-in Responses WebSocket path for the OpenAI native runtime:

  • OPENCODE_EXPERIMENTAL_OPENAI_WEBSOCKET gates the path.
  • Native OpenAI requests can select responsesWebSocket.
  • Codex OAuth exposes the same refreshed bearer/account headers and Codex base URL for WebSocket handshake auth.
  • WebSocket transport logs the opened URL for local verification without logging headers or bodies.

The path is off by default. The existing native flag and AI SDK fallback remain unchanged.

How did you verify your code works?

  • cd packages/opencode && bun typecheck
  • cd packages/llm && bun typecheck
  • cd packages/opencode && bun test test/session/llm-native.test.ts
  • cd packages/opencode && bun test test/effect/runtime-flags.test.ts
  • Built binary with OPENCODE_CHANNEL=latest bun ./script/build.ts --single
  • Live smoke using OpenAI OAuth:
    OPENCODE_EXPERIMENTAL_NATIVE_LLM=true OPENCODE_EXPERIMENTAL_OPENAI_WEBSOCKET=true ./packages/opencode/dist/opencode-darwin-arm64/bin/opencode --print-logs --log-level DEBUG run --model openai/gpt-5.4-mini-fast --format json "Reply with exactly: websocket-binary-final-ok"

Verified logs showed llm.runtime=native, llm.websocket.url=wss://chatgpt.com/backend-api/codex/responses, and output websocket-binary-final-ok.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@mugnimaestra mugnimaestra force-pushed the openai-websocket-transport-fresh branch from d1a7b89 to 7911908 Compare May 26, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant