Skip to content

Commit 07cc2d0

Browse files
fix(agents): skip auth gate for CLI-owned transport
1 parent 975ea61 commit 07cc2d0

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

‎src/agents/model-fallback.test.ts‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,54 @@ describe("runWithModelFallback", () => {
11001100
expect(result.attempts).toStrictEqual([]);
11011101
});
11021102

1103+
it("lets direct CLI providers bypass stale provider auth cooldowns", async () => {
1104+
const cfg = makeCfg({
1105+
agents: {
1106+
defaults: {
1107+
cliBackends: {
1108+
"claude-cli": { command: "claude" },
1109+
},
1110+
model: {
1111+
primary: "claude-cli/opus",
1112+
},
1113+
},
1114+
},
1115+
});
1116+
const tempDir = await makeAuthTempDir();
1117+
setAuthRuntimeStore(tempDir, {
1118+
version: AUTH_STORE_VERSION,
1119+
profiles: {
1120+
"claude-cli:default": {
1121+
type: "api_key",
1122+
provider: "claude-cli",
1123+
key: "test-key",
1124+
},
1125+
"openai:default": { type: "api_key", provider: "openai", key: "test-key" },
1126+
},
1127+
usageStats: {
1128+
"claude-cli:default": {
1129+
disabledUntil: Date.now() + 60_000,
1130+
disabledReason: "billing",
1131+
failureCounts: { rate_limit: 4 },
1132+
},
1133+
},
1134+
});
1135+
const run = vi.fn().mockResolvedValueOnce("direct cli ok");
1136+
1137+
const result = await runWithModelFallback({
1138+
cfg,
1139+
provider: "claude-cli",
1140+
model: "opus",
1141+
agentDir: tempDir,
1142+
run,
1143+
});
1144+
1145+
expect(result.result).toBe("direct cli ok");
1146+
expect(run).toHaveBeenCalledTimes(1);
1147+
expect(run.mock.calls[0]).toEqual(["claude-cli", "opus"]);
1148+
expect(result.attempts).toStrictEqual([]);
1149+
});
1150+
11031151
it("does not treat command-lane watchdog timeouts as model fallback failures", async () => {
11041152
const cfg = makeCfg();
11051153
const timeoutError = new CommandLaneTaskTimeoutError("cron-nested", 330_000);

‎src/agents/model-fallback.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ async function resolveModelFallbackCandidateHarnessAuthPrecheck(
520520
params.model,
521521
);
522522
if (isCliProvider(params.provider, params.cfg)) {
523-
return { skipsProviderAuthCooldown: false };
523+
return { skipsProviderAuthCooldown: true };
524524
}
525525
const agentRuntimeOverride = normalizeOptionalAgentRuntimeId(agentHarnessRuntimeOverride);
526526
const harnessPolicy = resolveAgentHarnessPolicy({

0 commit comments

Comments
 (0)