Skip to content

[Feature]: Auto-retry on MCP tool rate limit instead of terminating #16993

Closed

Description

@otto-apoc

Problem

When an MCP tool call hits a rate limit, opencode immediately terminates the current task instead of retrying automatically.

Error message seen:

You have exceeded the request rate limit. Please wait a short period before retrying your request or contact the support to increase your request rate limit.

This is especially disruptive because the agent aborts mid-task, requiring the user to manually re-trigger the entire workflow from scratch.

Expected Behavior

When an MCP tool call returns a rate limit error (e.g. HTTP 429 or a message matching the pattern above), opencode should:

  1. Automatically retry the tool call with exponential backoff instead of terminating
  2. Inform the user that a rate limit was hit and a retry is in progress (e.g. Rate limited by MCP tool, retrying in Xs...)
  3. Continue the task seamlessly after a successful retry

Current Behavior

opencode terminates the current generation/task immediately when an MCP tool responds with a rate limit error.

Context

  • This is similar to the existing retry logic for AI model provider rate limits (see More resilient retry policy for Amazon Bedrock rate limiting #452)
  • The same retry-with-backoff approach should be applied consistently to MCP tool calls
  • Users should not need to restart their entire task just because an external tool was temporarily rate limited

Suggested Implementation

Apply the existing retry/backoff logic (used for LLM provider rate limits) to MCP tool call errors as well — detecting rate limit signals in the tool response and retrying with appropriate delay before propagating the error to the agent.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 11, 2026
  2. otto-apoc commented on Mar 11, 2026

    @otto-apoc
    Author

    Closing: misidentified as MCP tool rate limit. The actual issue is model provider rate limiting.

  3. added 8 commits that reference this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions