fix(providers): add official opencode client User-Agent to opencode-free - #2067
fix(providers): add official opencode client User-Agent to opencode-free#2067waw4303 wants to merge 1 commit into
Conversation
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This PR stays in draft until every box above is ticked. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe ChangesOpenCode CLI provider headers
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: 🟡 Moderate · up to The code change is narrowly scoped, but required CI, branch, findings, and readiness confirmations are still incomplete, so merge should wait until those gates are satisfied. Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
d6ec3b0 to
a5183ab
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
리뷰 · 우선순위 23 / 80draft 이고 readiness 체크 4칸이 전부 비어 있습니다. 변경은 헤더 교체는 레지스트리 시드와 adapter
이 패치는 desktop 클라이언트가 CLI 로 보이도록 헤더를 맞춥니다. 게이트웨이의 무료 티어 제한을 우회하는 방향이라, 헤더 문자열이 맞는지보다 이 프로바이더를 계속 desktop 으로 둘지 CLI 계약으로 공식 이전할지가 먼저입니다. 테스트는 기댓값만 갈아끼웠기 때문에 잘못된 헤더여도 초록이 됩니다. 해결방안: draft 체크리스트를 채우기 전에, opencode-free 를 CLI 계약으로 바꿀지 유지할지 결정하고 이 댓글은 grok-bot이 작성했습니다 |
OpenCode's Zen gateway requires the official client User-Agent prefix
('opencode') alongside the client marker, answering 429/403 to generic
fetch User-Agents. Keep the desktop tier identity and add the canonical
User-Agent header.
a5183ab to
6a79c42
Compare
|
Thanks for the thorough review! We investigated the official
|
|
Thank you @waw4303 — and thank you for revising this. Absorbed as #2160. Your revised head is the right call and I want to be explicit about why, because the reasoning came from outside this repository. Checking OmniRoute — an independent open-source project brokering the same Zen upstream — its userAgent: ... || "opencode",
client: ... || "desktop",and it got there by deliberately retreating from its own earlier One thing your patch could not have known about, which is why the replacement is larger than your diff: the registry edit alone would have reached nobody.
Every existing Your test assertions are carried over, plus five that fail if the delivery path is reverted. Full suite is 13519 pass / 0 fail. Closing this in favor of #2160, with the finding credited to you. Genuinely useful report — it surfaced a bug in the header mechanism itself, not just in one provider's values. |
Problem
Requests to OpenCode Free (
https://opencode.ai/zen/v1/chat/completions) currently fail with429 Too Many Requests/FreeUsageLimitError:{"type":"error","error":{"type":"FreeUsageLimitError","message":"Error from provider (Console): Rate limit exceeded. Please try again later."}}This occurs because the OpenCode API gateway rejects requests carrying generic/browser
User-Agentstrings alongsidex-opencode-client: desktop, requiring the official clientUser-Agentprefix (opencode) used by the official@opencode-ai/desktopand CLI applications.Solution
Add the canonical
User-Agent: opencodeheader tostaticHeadersforopencode-freeinsrc/providers/registry.ts, while preserving the existing desktop client identity (x-opencode-client: desktop) and avoiding fragile CLI-specific version strings or unnecessary project headers:User-Agent:opencode(matches the root client familyopencode/${version}from@opencode-ai/desktopbundleout/main/chunks/node-4IhTfWZ9.js)x-opencode-client:desktop(preserves the desktop tier identity and documentation consistency)Verification
@opencode-ai/desktop(v1.18.18) app bundle (USER_AGENT = "opencode/" + InstallationVersion).https://opencode.ai/zen/v1/chat/completionsacross header variations:User-Agent: opencode+x-opencode-client: desktop->200 OKx-opencode-client: desktop->429 FreeUsageLimitErrorbun test tests/opencode-free-provider.test.tspasses.bun test tests/management-provider-validation.test.tspasses.bun run typecheck(tsc --noEmit) passes cleanly.Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
User-Agent: opencodeheader to requests made through the OpenCode Free provider.