Skip to content

Commit e2355c0

Browse files
PR Batch Testerclaude
andcommitted
fix(server): a Claude 403 no longer tells you to log in again
The Claude CLI labels a 403 (for example an organization without access to the model) authentication_failed, so T3 showed "Claude could not authenticate, run `claude auth login`". Logging in can't fix a permission error. A 403 now shows the CLI's own text. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent cd41c4a commit e2355c0

2 files changed

Lines changed: 49 additions & 5 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,6 +2805,45 @@ describe("ClaudeAdapterV2 background wake turns", () => {
28052805
}).pipe(Effect.provide(Layer.merge(IdAllocator.layer, NodeServices.layer))),
28062806
);
28072807

2808+
it.effect("shows a 403 permission error instead of the login hint", () =>
2809+
Effect.gen(function* () {
2810+
const harness = yield* makeWakeHarness;
2811+
const now = yield* DateTime.now;
2812+
yield* harness.runtime.startTurn(
2813+
makeClaudeTestTurnInput({
2814+
threadId: harness.threadId,
2815+
providerThread: harness.providerThread,
2816+
now,
2817+
attemptId: RunAttemptId.make("attempt-claude-permission-denied"),
2818+
text: "Continue.",
2819+
attachments: [],
2820+
}),
2821+
);
2822+
// Claude CLI 2.1.288 labels a 403 authentication_failed too.
2823+
const cliText =
2824+
"Failed to authenticate. API Error: 403 Your organization does not have access to this model.";
2825+
yield* Queue.offerAll(harness.sdkMessages, [
2826+
makeAssistantErrorFrame({
2827+
uuid: "00000000-0000-4000-8000-000000000608",
2828+
error: "authentication_failed",
2829+
}),
2830+
makeResultFrame({
2831+
uuid: "00000000-0000-4000-8000-000000000609",
2832+
result: cliText,
2833+
isError: true,
2834+
apiErrorStatus: 403,
2835+
terminalReason: "api_error",
2836+
}),
2837+
]);
2838+
2839+
const terminal = yield* Queue.take(harness.terminalReceipts);
2840+
assert.equal(terminal.status, "failed");
2841+
if (terminal.status !== "failed") return;
2842+
assert.equal(terminal.failure.message, cliText);
2843+
assert.equal(terminal.failure.code, "api_error_403");
2844+
}).pipe(Effect.provide(Layer.merge(IdAllocator.layer, NodeServices.layer))),
2845+
);
2846+
28082847
it.effect.each([
28092848
{ recovered: false, expected: "Claude usage limit reached" },
28102849
{ recovered: true, expected: "Claude gave up after repeated API errors" },

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6475,11 +6475,16 @@ export function makeClaudeAdapterV2(
64756475
(message.terminal_reason == null ||
64766476
message.terminal_reason === "api_error" ||
64776477
message.terminal_reason === "blocking_limit");
6478-
const failureHint =
6479-
context.authenticationFailureMessage ??
6480-
(usageLimited
6481-
? "Claude usage limit reached. Send the message again once the limit resets."
6482-
: undefined);
6478+
// The CLI also labels a 403 authentication_failed. Logging in again
6479+
// can't grant a permission, so show the CLI's own text instead.
6480+
const permissionDenied =
6481+
message.subtype === "success" && message.api_error_status === 403;
6482+
const failureHint = permissionDenied
6483+
? message.result
6484+
: (context.authenticationFailureMessage ??
6485+
(usageLimited
6486+
? "Claude usage limit reached. Send the message again once the limit resets."
6487+
: undefined));
64836488
const resetTimes = Array.from(context.rateLimitResetTimes.values());
64846489
const resetAt =
64856490
resetTimes.length > 0 && resetTimes.every((time) => time !== null)

0 commit comments

Comments
 (0)