Skip to content

feat(errors): improve rate limit error messages for AI agents#2401

Open
Will-hxw wants to merge 1 commit intogithub:mainfrom
Will-hxw:feat/improve-rate-limit-error-messages
Open

feat(errors): improve rate limit error messages for AI agents#2401
Will-hxw wants to merge 1 commit intogithub:mainfrom
Will-hxw:feat/improve-rate-limit-error-messages

Conversation

@Will-hxw
Copy link
Copy Markdown

Summary

When the GitHub API returns a rate limit error, surface clear retry duration to the agent instead of burying it in raw HTTP strings.

  • For RateLimitError: show "Retry after Xs" with exact reset time
  • For AbuseRateLimitError: show "Retry after Xs" when RetryAfter is set, otherwise show "Wait before retrying"

Changes

Modified NewGitHubAPIErrorResponse in pkg/errors/error.go to detect rate limit error types using errors.As and return agent-friendly messages.

Example output

Before:

search code: GET https://api.github.com/search/code: 403 API rate limit exceeded for user ID 12345. [rate reset in 47s]

After:

search code: GitHub API rate limit exceeded. Retry after 47s.

Fixes #2385

When GitHub API returns a rate limit error, surface clear retry
duration to the agent instead of burying it in raw HTTP strings.

For RateLimitError: show "Retry after Xs"
For AbuseRateLimitError: show "Retry after Xs" when RetryAfter is set,
otherwise show "Wait before retrying"

Fixes github#2385
@Will-hxw Will-hxw requested a review from a team as a code owner April 28, 2026 22:44
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.

Improve rate limit error messages for AI agents

2 participants