OpenCode Go rejects requests with 400 MissingSessionID (x-opencode-session not sent); no opencode provider in settings
Summary
Requests to OpenCode Go (https://opencode.ai/zen/go/v1) fail with 400 MissingSessionID because Vibe-Trading never sends the x-opencode-session header the service now requires. There is also no opencode entry in Web Settings, so the only way to use OpenCode today is to re-point another provider at its URL.
Reproduce
- Web Settings → provider
deepseek, base URLhttps://opencode.ai/zen/go/v1, modeldeepseek-v4.1-flash, an OpenCode Go key. - Send any chat message.
Execution failed: provider_stream_error provider=deepseek model=deepseek-v4.1-flash:
OpenAIInvalidRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'MissingSessionID',
'message': 'Error from provider (Console Go): Request is missing x-opencode-session and cannot be
routed efficiently. Please see https://opencode.ai/docs/go/#where-can-i-use-it'}}Cause
OpenCode's docs (https://opencode.ai/docs/go/) require a stable per-conversation session id in x-opencode-session (used for routing and prompt caching) and ask clients to identify themselves via User-Agent. opencode-go / opencode-zen (#444) only map OPENAI_API_KEY / OPENAI_BASE_URL; nothing in ChatOpenAIWithReasoning sets the header, and the names are not in llm_providers.json, so they never appear in the settings UI.
Proposal
- Add a canonical
opencodeprovider (OPENCODE_API_KEY/OPENCODE_BASE_URL, default Go root, Zen offered as an option) across the catalog, capabilities, swarm allowlist and CLI onboarding. - Bind the active session id in a
ContextVarfromAgentLoop.run()and have the OpenAI-compatible adapter addx-opencode-sessionwhenever the request targetsopencode.ai(by provider name or base-URL host), with a per-adapter UUID fallback outside a session.
This touches src/agent/loop.py (a thin bind/reset wrapper around run()) and src/providers/, which the PR template lists as protected areas, hence this issue first. A PR implementing the above, with tests and a manual verification against the live Go endpoint, is ready: https://github.com/HKUDS/Vibe-Trading/pull/1416.
Version: 0.1.15 (also reproduced against current main).
Source: HKUDS/Vibe-Trading