Skip to content

Commit eb6bf36

Browse files
committed
fix(auth): limit inline key cooldowns to credential failures
1 parent 7cf7fbb commit eb6bf36

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎src/agents/auth-profiles/usage.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
isProfileInCooldown,
1616
markAuthProfileBlockedUntil,
1717
markAuthProfileFailure,
18+
markInlineProviderApiKeyFailure,
1819
maybeReprobeWhamBlockedProfiles,
1920
resolveProfilesUnavailableReason,
2021
resolveProfileUnusableUntilForDisplay,
@@ -1166,6 +1167,21 @@ describe("markAuthProfileFailure — locked update failure", () => {
11661167
});
11671168
});
11681169

1170+
describe("markInlineProviderApiKeyFailure", () => {
1171+
it("does not cool an inline key after a provider timeout", async () => {
1172+
const store = makeStore(undefined);
1173+
1174+
await markInlineProviderApiKeyFailure({
1175+
store,
1176+
provider: "anthropic",
1177+
reason: "timeout",
1178+
});
1179+
1180+
expect(store.usageStats).toBeUndefined();
1181+
expect(storeMocks.updateAuthProfileStoreWithLock).not.toHaveBeenCalled();
1182+
});
1183+
});
1184+
11691185
describe("markAuthProfileFailure — WHAM-aware Codex cooldowns", () => {
11701186
function mockWhamResponse(status: number, body?: unknown): void {
11711187
fetchMock.mockResolvedValueOnce(

‎src/agents/auth-profiles/usage.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,10 @@ export async function markInlineProviderApiKeyFailure(params: {
11501150
modelId?: string;
11511151
}): Promise<void> {
11521152
const { store, provider, reason, agentDir, runId, modelId } = params;
1153-
if (isAuthCooldownBypassedForProvider(provider)) {
1153+
if (
1154+
(reason !== "auth" && reason !== "auth_permanent" && reason !== "billing") ||
1155+
isAuthCooldownBypassedForProvider(provider)
1156+
) {
11541157
return;
11551158
}
11561159

0 commit comments

Comments
 (0)