Repository navigation
fix(ai): preserve provider access restriction errors - #56022
Ehsan-hash wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Looks good. I reproduced #55995 with the issue's script: ACP from source, with a mock gateway answering every request with 403 FreeTierError or 403 RegionError. On the base, session/prompt returned -32000 Authentication required for both. With this change, both return -32603 Internal error: This model is not available in your country (errorName: provider.invalid-request), so the provider's message now reaches the client. The new check only applies to 403s with these two codes, so other 401/403 responses are still treated as authentication failures, and InvalidRequest is not retried. The provider-error tests (39), the ACP tests in packages/cli (100) and the packages/ai typecheck pass.
The public API is unchanged: this only changes how errors are classified inside the code.

Issue for this PR
Closes #55995
Type of change
What does this PR do?
Treat typed
RegionErrorandFreeTierErrorHTTP 403 refusals as existing invalid-request errors. ACP then preserves the provider's explanation instead of offering a login that cannot fix the refusal. Genuine 401 and other 403 authentication failures keep their existing behavior.AI-assisted implementation and testing, with independent agent review.
How did you verify your code works?
bun run check: lint and all 35 typechecks passed. Prettier andgit diff --checkpassed.No real model calls or Windows verification.
Screenshots / recordings
Not a UI change.
Checklist
Added by the opencode bot (AI-generated).
Related: #47949, #49201, #50366