Skip to content

[WRONG BRANCH] fix(zen): restore OpenCode Zen free tier (descending session ids, forced-SSE fold) - #7

Draft
Warexpor wants to merge 1 commit into
mainfrom
fix/zen-free-tier-session-id
Draft

Warexpor wants to merge 1 commit into
mainfrom
fix/zen-free-tier-session-id

Conversation

@Warexpor

Copy link
Copy Markdown
Owner

Summary

  • OpenCode Zen free models answered every request with 403 FreeTierError ("can only be used from within OpenCode"). Console now validates the x-opencode-session timestamp, and OpenCode mints session ids descending (inverted timestamp). ocx minted them ascending. Sessions are now minted descending, and an inbound session id in the wrong direction (or older than 30 days) is replaced.
  • A non-streaming /v1/responses client on a Zen free model got an HTML 500 (JSON Parse error: Unexpected identifier "data") because the forced upstream SSE was parsed as JSON. The adapter delivery and continuation paths now fold any text/event-stream answer through parseStream.
  • The Zen wire-header test was made hermetic against an ambient SOCKS5 ALL_PROXY, which routed the dispatch around the mocked fetch.

Verification

  • Live, against opencode.ai/zen through a scratch proxy (sandboxed HOME/OPENCODEX_HOME): chat and responses (stream and non-stream) return pong for big-pickle, cat-jam-free, mimo-v2.6-flash-free. Before the fix: 403 on all free models.
  • SOCKS5: works via ALL_PROXY=socks5h://127.0.0.1:10808 and via --socks5 127.0.0.1:10808 with no proxy env; a dead SOCKS port fails with ECONNREFUSED 127.0.0.1:1, proving traffic goes through it.
  • bun run typecheck, bun run structure:check: pass.
  • bun test tests/providers/opencode-zen* plus 15 delivery/continuation-related files: 306 pass / 0 fail. The new non-stream regression test fails without the fix.
  • Full suite not run (scoped by request); test:changed needs Bun 1.4.0, this machine has 1.4.2. Remaining coverage left to CI.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

…sponses clients

Console's free-tier gate now rejects an x-opencode-session minted ascending; OpenCode's
Identifier.create inverts the timestamp for sessions. Inbound session ids are checked in
the same direction and replaced otherwise. A non-streaming /v1/responses client on a Zen
free model received an HTML 500 because the forced upstream SSE was parsed as JSON; the
delivery and continuation paths now fold any event-stream answer through parseStream.
@github-actions

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 13, 2026
@github-actions github-actions Bot changed the title fix(zen): restore OpenCode Zen free tier (descending session ids, forced-SSE fold) [WRONG BRANCH] fix(zen): restore OpenCode Zen free tier (descending session ids, forced-SSE fold) Oct 13, 2026
@github-actions

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request is being kept as a draft automatically. Once every issue above is resolved, it will be marked ready for review again.

@github-actions
github-actions Bot marked this pull request as draft October 13, 2026 15:00

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant