Skip to content

fix: org cycle agent name bug + quota detection#638

Merged
kokevidaurre merged 1 commit intodevelopfrom
fix/org-cycle-bugs
Mar 27, 2026
Merged

fix: org cycle agent name bug + quota detection#638
kokevidaurre merged 1 commit intodevelopfrom
fix/org-cycle-bugs

Conversation

@kokevidaurre
Copy link
Copy Markdown
Contributor

Fixes swapped args (name showed as full path) and adds quota detection (stops cycle after 2 consecutive fast failures).

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>
@kokevidaurre kokevidaurre merged commit c57ba09 into develop Mar 27, 2026
11 checks passed
@kokevidaurre kokevidaurre deleted the fix/org-cycle-bugs branch March 27, 2026 17:06
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The magic number 10000 is used here and on line 109 to define a 'fast failure'. It would be better to extract this into a named constant at the top of the catch block for clarity and easier maintenance. For example: const FAST_FAILURE_THRESHOLD_MS = 10000;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant