fix: org cycle agent name bug + quota detection#638
Merged
kokevidaurre merged 1 commit intodevelopfrom Mar 27, 2026
Merged
Conversation
Bug 1: runAgent was called with (path, name) instead of (name, path).
Caused agent names to show as full file paths in observability.
Bug 2: when Claude hits quota limit ("hit your limit", exit code 1),
org cycle now detects it (two consecutive fast failures <10s) and
stops instead of trying all remaining squads.
Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces quota and rate limit detection within the runCommand function, allowing the execution cycle to stop early if limits are reached. The feedback suggests consolidating the calculation of failure duration to ensure consistency across the logic and recommends extracting the magic number used for the failure threshold into a named constant for better maintainability.
Comment on lines
98
to
+101
| results.push({ squad: s.squad, agent: s.lead, status: 'failed', durationMs: Date.now() - runStart }); | ||
| writeLine(` ${colors.red}${s.squad}/${s.lead} failed: ${e instanceof Error ? e.message : String(e)}${RESET}`); | ||
|
|
||
| // Detect quota limit — if agent fails in <10s, likely quota/rate limit | ||
| const failDuration = Date.now() - runStart; |
There was a problem hiding this comment.
To ensure consistency and avoid multiple Date.now() calls which could yield slightly different results, it's better to calculate the duration once and reuse it for both the results array and the subsequent quota check.
Suggested change
| results.push({ squad: s.squad, agent: s.lead, status: 'failed', durationMs: Date.now() - runStart }); | |
| writeLine(` ${colors.red}${s.squad}/${s.lead} failed: ${e instanceof Error ? e.message : String(e)}${RESET}`); | |
| // Detect quota limit — if agent fails in <10s, likely quota/rate limit | |
| const failDuration = Date.now() - runStart; | |
| const failDuration = Date.now() - runStart; | |
| results.push({ squad: s.squad, agent: s.lead, status: 'failed', durationMs: failDuration }); | |
| // Detect quota limit — if agent fails in <10s, likely quota/rate limit |
|
|
||
| // Detect quota limit — if agent fails in <10s, likely quota/rate limit | ||
| const failDuration = Date.now() - runStart; | ||
| const isQuotaLikely = failDuration < 10000 && errMsg.includes('code 1'); |
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.
Fixes swapped args (name showed as full path) and adds quota detection (stops cycle after 2 consecutive fast failures).