diff --git a/src/tests/v2/v2.test.ts b/src/tests/v2/v2.test.ts index 14c9446b..398aae4f 100644 --- a/src/tests/v2/v2.test.ts +++ b/src/tests/v2/v2.test.ts @@ -2433,7 +2433,7 @@ describe("ACP v2 core", () => { expect(client.sessionUpdates.at(-1)).toMatchObject({ state: "idle", stopReason: "error", - error: { code: -32000 }, + error: { code: -32000, message: "Authentication required" }, }); }); @@ -2442,7 +2442,7 @@ describe("ACP v2 core", () => { "an authentication failure as authRequired", "authentication_failed", "Failed to authenticate. API Error: 401", - { code: -32000 }, + { code: -32000, message: "Authentication required: Failed to authenticate. API Error: 401" }, ], [ "another failure with its error kind", diff --git a/src/v2/outcome.ts b/src/v2/outcome.ts index 26077e82..23cdb663 100644 --- a/src/v2/outcome.ts +++ b/src/v2/outcome.ts @@ -91,7 +91,11 @@ export function idleOutcome( providerFailureCategory(kind) === "auth_required"); return failed( authFailure - ? RequestError.authRequired() + ? // Claude Code's `/login` instruction is for its terminal, so that text + // is left out. Any other says why the login failed, e.g. "Failed to + // authenticate: this login reached its time limit and cannot be + // renewed." + RequestError.authRequired(undefined, ended.loginRequired ? undefined : ended.error) : RequestError.internalError(kind ? { errorKind: kind } : undefined, ended.error), ); }