Skip to content

fix: surface rate limit errors with recovery options#505

Merged
bradygaster merged 1 commit intodevfrom
squad/464-rate-limit-ux
Mar 22, 2026
Merged

fix: surface rate limit errors with recovery options#505
bradygaster merged 1 commit intodevfrom
squad/464-rate-limit-ux

Conversation

@bradygaster
Copy link
Copy Markdown
Owner

Summary

Fixes #464 -- Squad CLI was showing generic 'Something went wrong processing your message' instead of the actual Copilot rate limit info, and squad doctor reported nothing useful.

Working as EECOM (Core Dev)

What Changed

Rate limit detection in the shell

  • The handleDispatch catch block now detects rate limit errors via instanceof RateLimitError OR message pattern (/rate.?limit|quota.*exceed|429/i)
  • When detected: shows rateLimitGuidance() with clear message + recovery steps instead of generic fallback
  • Also writes .squad/rate-limit-status.json so squad doctor can surface it later

New error-messages.ts exports

  • rateLimitGuidance({ retryAfter?, model? }) -- formats a clear, actionable error message
  • extractRetryAfter(message) -- parses durations from error strings

squad doctor improvement

  • New checkRateLimitStatus() check reads .squad/rate-limit-status.json
  • Reports warn when a recent rate limit was detected (< 4h ago), with link to fix

Recovery options offered to users

When a rate limit is hit, users see:
Rate limit reached for claude-sonnet-4.5. Copilot has temporarily throttled your requests.
Try again in 2 hours
Enable economy mode to switch to cheaper models: squad economy on
Or set a different model: add defaultModel to .squad/config.json

Tests

  • 11 new tests for rateLimitGuidance and extractRetryAfter
  • 3 new tests for checkRateLimitStatus in doctor

- Add rateLimitGuidance() and extractRetryAfter() to error-messages.ts
- Detect rate limit errors (instanceof RateLimitError or message pattern)
  in handleDispatch catch block instead of falling through to generic message
- Show actionable recovery: retry time, squad economy on, model override
- Write .squad/rate-limit-status.json on detection for squad doctor to read
- Add checkRateLimitStatus() to squad doctor — warns on recent rate limits,
  passes when stale (>4h), silent when no rate limit has been hit
- 36 new tests covering rateLimitGuidance, extractRetryAfter, and doctor check

Closes #464

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bradygaster bradygaster force-pushed the squad/464-rate-limit-ux branch from 3365c69 to 4fc5b08 Compare March 22, 2026 10:19
@bradygaster bradygaster merged commit e42709c into dev Mar 22, 2026
0 of 2 checks passed
@bradygaster bradygaster deleted the squad/464-rate-limit-ux branch March 22, 2026 10:19
bradygaster added a commit that referenced this pull request Mar 22, 2026
Orchestration log for 2026-03-22 session covering:
- #500 economy mode (PR #504)
- #502 node:sqlite fix (PR #506)
- #464 rate limit UX (PR #505)
- #500/#344 governance (PR #503)
- #329/#344 architecture plan (Flight, no PR yet)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
chrislomonico pushed a commit to clomonico/squad that referenced this pull request Mar 26, 2026
Wires upstream command into CLI entry point.

Closes bradygaster#505

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

feat: Inform the user that they hit a rate limit issue

1 participant