Repository navigation
fix(opencode): declare free-tier lowercase quartet tool fingerprint and canonical session identity - #24
Merged
b3nw merged 1 commit intoOct 10, 2026
Conversation
…nd canonical session identity
Match upstream OpenCode free-tier request contract and client fingerprint
requirements to resolve HTTP 403 FreeTierError ("OpenCode's free tier can
only be used from within OpenCode").
- Port upstream cheaper-inference/OmniRoute#15322 and #14013:
- Add open-sse/utils/opencodeFingerprint.ts: inject canonical lowercase
file-search quartet (`bash`, `glob`, `grep`, `read`) into body.tools,
canonicalize client casing on dispatch, and restore caller's tool spelling
in SSE/JSON responses.
- Add open-sse/executors/opencodeFreeTierContract.ts: gate free models on
zen surface, enforce streaming, and lazily rebuild JSON for non-streaming
callers.
- Update open-sse/utils/opencodeHeaders.ts: default User-Agent to
opencode/1.18.31 (>= 1.17) and synthesize canonical `ses_` and `msg_` IDs.
- Update OpencodeExecutor to apply free tier contract and restore names.
- Add unit tests in tests/unit/opencode-free-tier-fingerprint.test.ts (31 passing).
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.
Summary
Keyless OpenCode free-tier models answered
403 FreeTierError("OpenCode's free tier can only be used from within OpenCode") because upstream strictly enforces client fingerprinting on keyless free-tier requests (https://opencode.ai/zen/v1).Ports upstream diegosouzapw/OmniRoute#15322 and #14013:
bash,glob,grep,readto be present inbody.tools. Implementsopen-sse/utils/opencodeFingerprint.tsto inject missing quartet members, canonicalize client casing (e.g.Bash->bash), and restore the caller's tool spelling in outgoing SSE and JSON responses.open-sse/executors/opencodeFreeTierContract.tsto gate free models on thezensurface, force streaming, and lazily rebuild JSON for non-streaming downstream callers.open-sse/utils/opencodeHeaders.tsgenerates canonicalses_[0-9a-f]{12}[0-9A-Za-z]{14}session IDs andmsg_request IDs matching the OpenCode client contract.opencode/1.18.31and preserves client UAs satisfying the version rule (>= 1.17).Validation
npm run typecheck:core: Clean (0 errors).bash local-ops/scripts/github-pre-push-gate.sh: All leak scans and pre-push verification gates passed.tests/unit/opencode-free-tier-fingerprint.test.ts: 31/31 passed.tests/unit/opencode-cli-headers-synthesis-5997.test.ts: 9/9 passed.