Skip to content

fix(session): restore x-opencode-* headers so Zen free tier accepts requests - #1130

Merged
ElioNeto merged 1 commit into
developfrom
fix/zen-opencode-headers
Sep 9, 2026
Merged

fix(session): restore x-opencode-* headers so Zen free tier accepts requests#1130
ElioNeto merged 1 commit into
developfrom
fix/zen-opencode-headers

Conversation

@ElioNeto

@ElioNeto ElioNeto commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Problem

Since the rebrand, every request to the OpenCode Zen free tier fails with:

400 MissingSessionID — "OpenCode's free tier can only be used in OpenCode"

Commit 1f037c3 renamed the Zen headers to x-teamcode-* and changed the provider guard to providerID.startsWith("teamcode"). No provider is named teamcode, so the branch never runs and Zen receives only x-session-affinity.

Fix

  • Header assembly moved to LLMHeaders.build (packages/teamcode/src/session/llm-headers.ts).
  • Providers opencode and opencode-go send x-opencode-session, x-opencode-request, x-opencode-client, x-opencode-project (when a project id exists) and User-Agent: opencode/<version>, matching upstream sst/opencode (session/llm/request.ts).
  • Other providers keep User-Agent: teamcode/<version> and now also send X-Session-Id, as upstream does.
  • x-parent-session-id is forwarded for every provider.
  • Lint warnings on touched code in llm.ts fixed (unused cfg, unnecessary non-null assertion, two unsafe type assertions). The GitLabWorkflowLanguageModel assertion 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 --noEmit clean for session/llm*.
  • Real request through the patched build: teamcode run -m opencode/mimo-v2.5-free "..." completes with finish=stop in dev.log; before the patch the same model returned the 400 above.

🤖 Generated with Claude Code

…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>
@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 2026

Copy link
Copy Markdown

@ElioNeto
ElioNeto marked this pull request as ready for review September 9, 2026 13:45
@ElioNeto
ElioNeto merged commit b828624 into develop Sep 9, 2026
4 checks passed
@ElioNeto
ElioNeto deleted the fix/zen-opencode-headers branch September 9, 2026 18:02
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.

2 participants