fix(core): add vpn hint to free tier and rate limit errors by JayadityaGit · Pull Request #56475 · anomalyco/opencode · GitHub
Skip to content

fix(core): add vpn hint to free tier and rate limit errors - #56475

Closed
JayadityaGit wants to merge 2 commits into
anomalyco:devfrom
JayadityaGit:vpn-error-hints
Closed

JayadityaGit wants to merge 2 commits into
anomalyco:devfrom
JayadityaGit:vpn-error-hints

Conversation

@JayadityaGit

@JayadityaGit JayadityaGit commented Oct 17, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #56474

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When requests fail due to VPN or proxy IP filtering (\can only be used from within OpenCode) or shared IP rate limiting (\Rate limit exceeded), this PR appends \If you are using a VPN or proxy, try disconnecting it.\ to the error message in \ oSessionError. This prevents users from assuming their local client or auth is corrupted.

How did you verify your code works?

Added unit tests in \packages/core/test/session-error.test.ts\ verifying both error messages are enriched correctly, and ran \�un test packages/core/test/session-error.test.ts\ (11/11 tests pass).

Screenshots / recordings

N/A (terminal error message enhancement)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #56334, #56398, #56373, #56397, #56425, #56338, #56111, #56431

@github-actions

Copy link
Copy Markdown
Contributor

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The free-tier error now gets the hint as described, but the rate-limit match is too broad to merge as is.

I checked it by calling toSessionError on the base and on this PR with a free-tier AuthenticationError and with a non-OpenCode RateLimitError. I also ran bun test test/session-error.test.ts (passes) and bun run typecheck in packages/core (clean).

Public API: unchanged. Only the text of SessionError messages changes; no types, events or config keys change.

Concerns:

  • Applies to every provider. message.includes("Rate limit exceeded") runs on every provider's errors. A plain Anthropic/OpenRouter/OpenAI 429 such as Rate limit exceeded: … per-minute quota now ends with "If you are using a VPN or proxy, try disconnecting it.", which is misleading there. Please limit the hint to errors from the OpenCode gateway, matching on something structured such as a gateway error code in reason.body, the way tokenSharingMessages does, rather than on English message text. The gateway may also be a better place for this hint, since it owns both messages.
  • Model-visible text. The changed message is also what the model sees as the error, so any hint added here reaches the model too. Keep it tightly scoped.

Related: #56334, #56398, #56373, #56397, #56425, #56338, #56111, #56431

}

function vpnHint(message: string) {
if (message.includes("can only be used from within OpenCode") || message.includes("Rate limit exceeded")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

providerError runs for every provider, so "Rate limit exceeded" also matches ordinary 429s from Anthropic, OpenRouter, OpenAI and others. I checked: Rate limit exceeded: anthropic/claude per-minute quota becomes … per-minute quota. If you are using a VPN or proxy, try disconnecting it. Could this be limited to the OpenCode gateway's errors, e.g. by matching a gateway error code in reason.body like tokenSharingMessages does, instead of English message substrings?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing it out

@JayadityaGit

Copy link
Copy Markdown
Author
after

I did not know my vpn was the cause, i had to figure it out the cause, so i had added a small hint to the existing erros, so that it will be helpful to the future devs.

@JayadityaGit

JayadityaGit commented Oct 17, 2026 •

Copy link
Copy Markdown
Author

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.

Add VPN disconnection hint to free-tier and rate limit error messages

1 participant