anomalyco / anomalyco/opencode

[FEATURE]: Warn users before free tier quota exhaustion instead of silent 429

Open
#42,765 3 comments 3 reactions 1 assignee View on GitHub

@MrMushrooooom is already working on this.

Since Aug 15, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Verification Checklist
  • I have searched existing issues and this is not a duplicate
  • I understand this is a feature request, not a bug report
Problem

When using free models (-free suffix) on OpenCode Zen, users hit FreeUsageLimitError (429) with no prior warning. The only feedback is a sudden "Free usage exceeded, subscribe to Go" dialog. This is especially painful for users behind shared IPs (CGNAT, corporate networks), where the quota may be exhausted by other users on the same IP.

Related issues: #15585 #42029 #42128 #33495

Proposal

Add rate-limit response headers to zen API responses so clients can display a warning when quota is running low.

Only include headers when remaining quota is below a threshold (e.g., <20% remaining). This way:

  • Users get advance notice before hitting 429
  • The exact total limit is never exposed
  • The official team retains full control over the numbers
HTTP/1.1 200 OK
X-RateLimit-Remaining: 8
X-RateLimit-Reset: 1786800000

When above the threshold, no headers are returned (current behavior unchanged).

Why not expose on every request?

This keeps the daily limit opaque while still solving the core UX problem: users know they're running low and can plan accordingly, without learning the exact cap.

Implementation scope
File Change
packages/console/app/src/routes/zen/util/ipRateLimiter.ts Return counts from check()
packages/console/app/src/routes/zen/util/handler.ts Write headers when remaining < threshold
packages/opencode/src/session/retry.ts Parse headers for early warning (optional)
Verification
  • curl -v zen endpoint, verify headers appear when quota is low
  • Confirm no headers when quota is high (no info leak)
Note on duplicates

This may overlap with #40588 and #41684. Happy to consolidate there instead if preferred.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.