fix: align timeout cooldown behavior docs/tests (#22622) (thanks @vageeshkumar)

This commit is contained in:
Peter Steinberger
2026-02-22 15:33:40 +01:00
parent 71d0b86352
commit 3e2849c578
3 changed files with 23 additions and 5 deletions

View File

@@ -331,6 +331,25 @@ describe("runEmbeddedPiAgent auth profile rotation", () => {
}
});
it("rotates on timeout without cooling down the timed-out profile", async () => {
await withAgentWorkspace(async ({ agentDir, workspaceDir }) => {
await writeAuthStore(agentDir);
mockFailedThenSuccessfulAttempt("request ended without sending any chunks");
await runAutoPinnedOpenAiTurn({
agentDir,
workspaceDir,
sessionKey: "agent:test:timeout-no-cooldown",
runId: "run:timeout-no-cooldown",
});
expect(runEmbeddedAttemptMock).toHaveBeenCalledTimes(2);
const usageStats = await readUsageStats(agentDir);
expect(typeof usageStats["openai:p2"]?.lastUsed).toBe("number");
expect(usageStats["openai:p1"]?.cooldownUntil).toBeUndefined();
});
});
it("does not rotate for compaction timeouts", async () => {
await withAgentWorkspace(async ({ agentDir, workspaceDir }) => {
await writeAuthStore(agentDir);

View File

@@ -949,8 +949,8 @@ export async function runEmbeddedPiAgent(
);
}
// Treat timeout as potential rate limit (Antigravity hangs on rate limit)
// But exclude post-prompt compaction timeouts (model succeeded; no profile issue)
// Rotate on timeout to try another account/model path in this turn,
// but exclude post-prompt compaction timeouts (model succeeded; no profile issue).
const shouldRotate =
(!aborted && failoverFailure) || (timedOut && !timedOutDuringCompaction);
@@ -973,9 +973,7 @@ export async function runEmbeddedPiAgent(
});
}
if (timedOut && !isProbeSession) {
log.warn(
`Profile ${lastProfileId} timed out (possible rate limit). Trying next account...`,
);
log.warn(`Profile ${lastProfileId} timed out. Trying next account...`);
}
if (cloudCodeAssistFormatError) {
log.warn(