Studio agent sessions (chat / book-create) don't send `x-opencode-session`, so OpenCode Go returns 400 MissingSessionID
Studio agent sessions (chat / book-create) don't send x-opencode-session, so OpenCode Go returns 400 MissingSessionID.
Env
InkOS 1.8.0 (latest, master same), Node v24, Windows.
OpenCode Go as a custom service: baseUrl=https://opencode.ai/zen/go/v1, apiFormat=chat, API key set. "Test connection" passes.
Problem
Starting a chat / book-create session in Studio fails:
400 Error from provider (Console Go): Request is missing x-opencode-session
and cannot be routed efficiently.The pipeline (inkos write next) works. OpenCode Go has required x-opencode-session on every inference request since 2026-09-03.
Root cause
The pipeline path createLLMClient() (packages/core/src/llm/provider.ts) reads config.headers ?? parseEnvHeaders() and puts them on the pi-ai model, so llm.headers / INKOS_LLM_HEADERS work there.
The Studio agent path builds its model via resolveServiceModel() (packages/core/src/llm/service-resolver.ts), which never sets headers. That model is used by runAgentSession → guardedPiStream, which only forwards options.headers. So configured headers are silently dropped on the agent path.
pi-ai's openai-completions does merge model-level headers (const headers = { ...model.headers }), so setting model.headers is sufficient.
Proof
Direct request to the endpoint: without header → 400 MissingSessionID; with x-opencode-session → 200 OK.
Suggested fix
service-resolver.ts: add optionalextraHeaders?: Record<string, string>toresolveServiceModeland include...(extraHeaders ? { headers: extraHeaders } : {})in the built model.packages/studio/src/api/server.ts: passconfig.llm.headersto the 3resolveServiceModel(...)calls.
(CLI/TUI agent paths already use client._piModel, which has headers, so only Studio needs this.)
Workaround
A local proxy in front of baseUrl that injects x-opencode-session (verified working).
Source: Narcooo/inkos