fix(runtime): propagate OpenCode Go session identity - #4670
Conversation
Route the stable Maka Session identity through normal model calls, history compaction, and session-scoped auxiliary work. Give Connection Test and Daily Review one opaque identity per operation, and apply the provider header consistently across Chat, Messages, and Responses without overriding explicit configuration. Generated-by: OpenAI Codex
Astro-Han
left a comment
There was a problem hiding this comment.
Traced the production path and the change lands on the existing seams: ModelAdapterInput.sessionId and transportContextId already existed, and the four non-test getAIModel call sites (main, history compaction, every auxiliary call) are all covered, so identity still has exactly one source. Tests exercise the real owners (testConnection, getAIModel, ModelAdapter, Host composition) rather than a bypassed fixture. No P0/P1/P2 from me.
One thing I checked and want to record so nobody re-derives it: hasRequestCustomization is now true for every OpenCode Go request, and the openai / openai-codex arms of getAIModel use that flag to skip openAiResponsesTransportState.wrapFetch. That is not a regression here because opencode-go declares runtimeAdapter.kind: 'openai-compatible', and that arm does not read the flag. It would become one if the provider ever moved to the native OpenAI adapter.
P3: the header is scoped to opencode-go only. opencode and opencode-free share the OpenCode catalog and model ids. Could you say what the upstream evidence is that the Zen and Free endpoints do not need x-opencode-session? I could not verify that either way.
CI has not run at this head: the CI workflow run is sitting at action_required, so only the label job reports. Worth getting a green run before merge, especially with the upstream 2026-09-05 date in the issue.
|
Thanks for checking this. The scope comes directly from vercel/ai#20271. The reporter identifies the The maintainer also recommends persisting the application conversation ID for I found no upstream requirement for the separate Zen or Free endpoints, so I |
OpenCode Go requires every inference request to carry an `x-opencode-session` header with a stable conversation identity. Maka omitted it from model requests and from Connection Test probes, so the provider could reject them. The header is added at the shared request-customization boundary and carries the existing Maka Session identity through normal model requests and tool-loop steps, history compaction, session-scoped auxiliary calls (title, recap, memory extraction, goal evaluation), and the OpenAI Chat, Anthropic Messages, and Responses wires. Identity stays with the Runtime Host: `ModelAdapterInput.sessionId` and `transportContextId` were already the seams, and every non-test `getAIModel` call site is covered. Operations without a Session use one identity per operation: Connection Test generates one UUID and reuses it across its internal attempts, and Daily Review generates one call identity and reuses it for provider retries. The header is restricted to `opencode-go`. An explicitly configured `x-opencode-session` header wins, matched case-insensitively, and the generated value contains no user content or credential material. Fixes apache#4663 Generated-by: OpenAI Codex Generated-by: GLM-5.3-Flash (ZCode)
Summary
OpenCode Go requires every inference request to carry an
x-opencode-sessionheader with a stable conversation identity. Maka omitted the header from both normal model requests and direct Connection Test probes, which may cause those requests to be rejected by the provider.This change adds the header at the shared request-customization boundary and propagates the existing Maka Session identity through:
Operations without a Session use one identity per operation: Connection Test generates one UUID and reuses it across its internal attempts, while Daily Review generates one call identity and reuses it for provider retries.
The header is restricted to
opencode-go. An explicitly configuredx-opencode-sessionheader takes precedence case-insensitively, and no user content or credential material is included in the generated value.Fixes #4663
Related upstream report:
vercel/ai#20271
Verification
ModelAdapterdid not forward its Session identity.x-opencode-session.daily-reviewinstead of a unique per-operation identity.@maka/runtimefull suite: 3,189 passed, 13 skipped, 0 failed.build:testcompleted successfully after rebasing onto currentmain.git diff --check, and the ASF license-header audit passed.deepseek-v4-proat max reasoning. Its shared Daily Review identity finding was reproduced and fixed with a regression test.A full Runtime Host package run also exposed an unrelated timing failure in
owned Host exits promptly after its first connection closes: the Host did not settle within its fixed 500 ms local deadline. The affected model-composition suite passes in full after a clean root build.AI use
Select exactly one:
Tool(s) and scope: OpenAI Codex reproduced the missing-header paths, implemented the fix, added regression coverage, and ran the local verification. DeepSeek Harness performed an independent read-only review that identified the Daily Review identity collision fixed in the final patch. The commit contains a
Generated-by: OpenAI Codextrailer.Checklist
Does this PR entail a change in behavior?