Skip to main content
Watch: I Built an AI App Without Leaving Databricks

OpenCode error

OpenCode: AI_RetryError: Failed after 4 attempts. Last error: Too Many Requests

Error message
AI_RetryError: Failed after 4 attempts. Last error: Too Many Requests

Status: WorkaroundLast verified 3 documented fixes2 sources

What it means

OpenCode retried a request that the provider kept rejecting and gave up after the last attempt. A maintainer: "The retry message you see is taken directly from the response from the server". A Bedrock variant reads "AI_RetryError: Failed after 3 attempts, Last error: undefined: Too many tokens, please wait before trying again." (#545).

Causes

  • Provider rate limiting. A maintainer replied "You may be getting rate limited?" (#2398).
  • A low Bedrock rate limit allocation. A maintainer: "what is your rate limit allocated with bedrock? default is low but they will increase it" (#545).

How to fix it

  1. Fix 1.

    For GitHub Copilot, check your Copilot dashboard. You can also log out and log back in (maintainer, #2398).

    Terminal
    opencode auth logout
  2. Fix 2.

    For Amazon Bedrock, check your account's rate limit allocation and ask AWS to raise it if needed (maintainer, #545).

  3. Fix 3.

    Upgrade. The retry count was raised to 10 in v0.1.183 (maintainer, #545).

    Terminal
    opencode upgrade

More OpenCode errors

All 17 OpenCode errors

FAQ

What does "AI_RetryError: Failed after 4 attempts. Last error: Too Many Requests" mean in OpenCode?

OpenCode retried a request that the provider kept rejecting and gave up after the last attempt. A maintainer: "The retry message you see is taken directly from the response from the server". A Bedrock variant reads "AI_RetryError: Failed after 3 attempts, Last error: undefined: Too many tokens, please wait before trying again." (#545).

How do I fix "AI_RetryError: Failed after 4 attempts. Last error: Too Many Requests"?

There are 3 documented fixes. Start with the first: For GitHub Copilot, check your Copilot dashboard. You can also log out and log back in (maintainer, #2398).

Is this OpenCode error fixed?

Status: Workaround. No release removes the cause. The documented fixes work around it. Affected versions: Reported mid-2025 (v0.1.x to v1.0.126).

Sources

Last verified against 2 sources: official docs, maintainer replies and release notes.

Newsletter

Fixes for the tools you use, weekly

One email per week. New coding agent releases, what broke, and how developers are working around it.