feat(FN-705): add rate-limit retry with exponential backoff for AI agents

- Add rate-limit retry utility with exponential backoff, jitter, and configurable limits
- Integrate retry logic into executor, triage, and merger agent sessions
- Export retryOnRateLimit from engine package index
- Remove unused DirectoryPicker component, stale CSS, and dead dashboard routes
- Update SetupWizardModal and usage tests to reflect cleanup
This commit is contained in:
gsxdsm
2026-04-02 13:39:04 -07:00
parent a4896f034e
commit 657c7bf238
8 changed files with 399 additions and 7 deletions

View File

@@ -6,6 +6,7 @@ import type { WorktreePool } from "./worktree-pool.js";
import { AgentLogger } from "./agent-logger.js";
import { mergerLog } from "./logger.js";
import { isUsageLimitError, checkSessionError, type UsageLimitPauser } from "./usage-limit-detector.js";
import { withRateLimitRetry } from "./rate-limit-retry.js";
import type { ToolDefinition } from "@mariozechner/pi-coding-agent";
import { Type } from "@sinclair/typebox";
@@ -1153,9 +1154,15 @@ async function runAiAgentForCommit(params: AiAgentParams): Promise<{ success: bo
simplifiedContext,
buildCommand,
});
await session.prompt(prompt);
checkSessionError(session);
await withRateLimitRetry(async () => {
await session.prompt(prompt);
checkSessionError(session);
}, {
onRetry: (attempt, delayMs, error) => {
const delaySec = Math.round(delayMs / 1000);
mergerLog.warn(`${taskId} rate limited — retry ${attempt} in ${delaySec}s: ${error.message}`);
},
});
// Check if build failed
if (buildFailed) {