fix(session): restore x-opencode-* headers so Zen free tier accepts requests - #1130
Merged
Conversation
…equests
The rebrand renamed the headers sent to opencode.ai/zen to x-teamcode-* and
changed the provider guard to startsWith("teamcode"), which never matches.
Zen now rejects every free-tier request with 400 MissingSessionID
("OpenCode's free tier can only be used in OpenCode").
Headers for opencode and opencode-go providers now match upstream
(x-opencode-session/request/client, x-opencode-project when available,
User-Agent opencode/<version>). Other providers keep the teamcode
User-Agent and also gain X-Session-Id, as upstream does.
Header assembly moved to LLMHeaders.build so it can be unit tested.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
Since the rebrand, every request to the OpenCode Zen free tier fails with:
Commit
1f037c3renamed the Zen headers tox-teamcode-*and changed the provider guard toproviderID.startsWith("teamcode"). No provider is namedteamcode, so the branch never runs and Zen receives onlyx-session-affinity.Fix
LLMHeaders.build(packages/teamcode/src/session/llm-headers.ts).opencodeandopencode-gosendx-opencode-session,x-opencode-request,x-opencode-client,x-opencode-project(when a project id exists) andUser-Agent: opencode/<version>, matching upstreamsst/opencode(session/llm/request.ts).User-Agent: teamcode/<version>and now also sendX-Session-Id, as upstream does.x-parent-session-idis forwarded for every provider.llm.tsfixed (unusedcfg, unnecessary non-null assertion, two unsafe type assertions). TheGitLabWorkflowLanguageModelassertion at line 223 is pre-existing and untouched.Verification
bun test test/session/llm-headers.test.ts test/session/llm.test.ts: 19 pass, 0 fail.tsc --noEmitclean forsession/llm*.teamcode run -m opencode/mimo-v2.5-free "..."completes withfinish=stopindev.log; before the patch the same model returned the 400 above.🤖 Generated with Claude Code