Commit 44aa810
errors: improve rate limit error messages for AI agents
When the GitHub API returns a rate limit error, replace the raw Go HTTP
error string with a clean, actionable message so agents know exactly
how long to wait before retrying.
Before:
search code: GET https://api.github.com/search/code: 403 API rate
limit exceeded for user ID 12345. [rate reset in 2m59s]
After:
search code: GitHub API rate limit exceeded. Retry after 2m59s.
create issue: GitHub secondary rate limit exceeded. Retry after 47s.
create issue: GitHub secondary rate limit exceeded. Wait before retrying.
Edge cases: expired/zero reset time, nil RetryAfter, and errors
wrapped with errors.As all produce "Wait before retrying." rather
than a negative or confusing duration.
The original error is stored in context via addGitHubAPIErrorToContext
before the rate-limit check, so middleware is unaffected.
Fixes #2385.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 4bded57 commit 44aa810
2 files changed
Lines changed: 686 additions & 462 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
162 | 188 | | |
163 | 189 | | |
164 | 190 | | |
| |||
0 commit comments