Repository navigation
feat: Cooperative Rate Limiting & Predictive Circuit Breaker (#515) - #518
Merged
bradygaster merged 4 commits intoMar 23, 2026
Merged
bradygaster merged 4 commits into
bradygaster merged 4 commits into
Conversation
…ub#515) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
tamirdresher
pushed a commit
to tamirdresher/squad
that referenced
this pull request
Mar 22, 2026
…#515) Integrates PredictiveCircuitBreaker from squad-sdk into Ralph's watch loop: - Pre-round rate limit check via gh api rate_limit - Traffic light gating (GREEN/AMBER/RED) - Predictive circuit opening before 429 - Exponential backoff on rate limit errors - Half-open recovery with 2-success threshold - State persistence to .squad/ralph-circuit-breaker.json - Adds ghRateLimitCheck() and isRateLimitError() to gh-cli.ts Depends on github#518 for the SDK module. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 22, 2026
- Add non-null assertions for array indexing in PredictiveCircuitBreaker - Add ./ralph/rate-limiting export entry to SDK package.json Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
tamirdresher
pushed a commit
to tamirdresher/squad
that referenced
this pull request
Mar 22, 2026
…#515) Integrates PredictiveCircuitBreaker from squad-sdk into Ralph's watch loop: - Pre-round rate limit check via gh api rate_limit - Traffic light gating (GREEN/AMBER/RED) - Predictive circuit opening before 429 - Exponential backoff on rate limit errors - Half-open recovery with 2-success threshold - State persistence to .squad/ralph-circuit-breaker.json - Adds ghRateLimitCheck() and isRateLimitError() to gh-cli.ts Depends on github#518 for the SDK module. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- canUseQuota() is now a pure read — returns boolean, no side effects - consumeQuota() handles stale lease reclamation and usage tracking - Correct JSDoc: prediction uses first-to-last delta rate, not linear regression - Update tests: add consumeQuota test suite, fix canUseQuota purity assertions Fixes Q review findings on PR github#518: side-effect bug in canUseQuota() and inaccurate 'linear regression' JSDoc claim.
bradygaster
approved these changes
Mar 23, 2026
bradygaster
left a comment
Collaborator
There was a problem hiding this comment.
Well-designed rate limiting module — the traffic light pattern and priority-based retry windows are production-quality. Clean types, good test coverage (23 cases).\n\nMinor fix needed: test imports use relative paths (../packages/squad-sdk/src/ralph/rate-limiting.js) instead of package subpath imports (@bradygaster/squad-sdk/ralph/rate-limiting). The rest of our test suite uses subpath imports — please update for consistency.\n\nAlso: \writeFile\ is imported but never used in
ate-limiting.ts\ — small cleanup.\n\nOther than that, this is great work. Ready to merge after those tweaks. ✅
…ile import - Changed test import from relative path to @bradygaster/squad-sdk/ralph/rate-limiting - Removed unused writeFile import from rate-limiting.ts 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
Consolidated 15 remaining issues into a single PR. Redesigns help UX with grouped categories, surfaces all /help commands, aligns docs with actual CLI behavior, adds first-run welcome, standardizes naming. Closes github#510, Closes github#513, Closes github#514, Closes github#515, Closes github#516, Closes github#517, Closes github#518, Closes github#521, Closes github#522, Closes github#523, Closes github#524, Closes github#525, Closes github#527, Closes github#528, Closes github#529 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #515
Adds cooperative rate limiting patterns for multi-agent Squad deployments.
Changes
New SDK module:
packages/squad-sdk/src/ralph/rate-limiting.tsPredictiveCircuitBreakerclass: Opens circuit BEFORE 429 using linear regressiongetTrafficLight(): GREEN/AMBER/RED throttling from API headersshouldProceed(): Priority-based agent schedulinggetRetryDelay(): Non-overlapping jitter windows by agent prioritycanUseQuota(): Cooperative token pool managementloadRatePool(): Shared rate-pool.json readerNew template:
.squad-templates/cooperative-rate-limiting.mdTests:
test/rate-limiting.test.ts(23 test cases)Changeset included
Context
Builds on the existing circuit breaker template (#450) with patterns for multi-instance coordination. Based on production experience running 7+ concurrent agents on AKS.