Skip to content

Commit 47ba4ab

Browse files
authored
fix: preserve native Claude auth in status (#129364)
Native Claude CLI authentication now appears in status output and takes precedence over a selected API key for equivalent runtime aliases. Refs #129333.
1 parent 9b04f82 commit 47ba4ab

3 files changed

Lines changed: 20 additions & 22 deletions

File tree

‎src/agents/model-runtime-aliases.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ export function shouldPreferActiveRuntimeAliasAuthLabel(params: {
150150
return (
151151
selectedAuth === "unknown" ||
152152
(Boolean(selectedAuth?.startsWith("api-key")) &&
153-
(activeAuth.startsWith("oauth") || activeAuth.startsWith("token")))
153+
(activeAuth.startsWith("oauth") ||
154+
activeAuth.startsWith("token") ||
155+
activeAuth.startsWith("native")))
154156
);
155157
}
156158

‎src/auto-reply/reply/commands-status.test.ts‎

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,23 +1895,9 @@ describe("buildStatusReply subagent summary", () => {
18951895
);
18961896
});
18971897

1898-
it("uses Claude CLI OAuth auth labels for anthropic models running on the Claude CLI runtime", async () => {
1898+
it("uses native Claude CLI auth labels for anthropic models running on the Claude CLI runtime", async () => {
18991899
await withTempHome(
1900-
async (dir) => {
1901-
const authPath = path.join(dir, ".claude", ".credentials.json");
1902-
fs.mkdirSync(path.dirname(authPath), { recursive: true });
1903-
fs.writeFileSync(
1904-
authPath,
1905-
JSON.stringify({
1906-
claudeAiOauth: {
1907-
accessToken: "access-token",
1908-
refreshToken: "refresh-token",
1909-
expiresAt: Date.now() + 60_000,
1910-
},
1911-
}),
1912-
"utf8",
1913-
);
1914-
1900+
async () => {
19151901
const text = await buildStatusText({
19161902
cfg: {
19171903
...baseCfg,
@@ -1943,7 +1929,7 @@ describe("buildStatusReply subagent summary", () => {
19431929

19441930
const normalized = normalizeTestText(text);
19451931
expect(normalized).toContain("Model: anthropic/claude-opus-4-7");
1946-
expect(normalized).toContain("oauth (claude-cli)");
1932+
expect(normalized).toContain("native (claude-cli)");
19471933
},
19481934
{
19491935
env: {
@@ -1954,7 +1940,7 @@ describe("buildStatusReply subagent summary", () => {
19541940
);
19551941
});
19561942

1957-
it("prefers active Claude CLI OAuth over selected env API-key labels for runtime aliases", async () => {
1943+
it("prefers active native Claude CLI auth over selected env API-key labels for runtime aliases", async () => {
19581944
const text = await buildStatusText({
19591945
cfg: {
19601946
...baseCfg,
@@ -1993,12 +1979,12 @@ describe("buildStatusReply subagent summary", () => {
19931979
isGroup: false,
19941980
defaultGroupActivation: () => "mention",
19951981
modelAuthOverride: "api-key (env: ANTHROPIC_API_KEY)",
1996-
activeModelAuthOverride: "oauth (claude-cli)",
1982+
activeModelAuthOverride: "native (claude-cli)",
19971983
});
19981984

19991985
const normalized = normalizeTestText(text);
20001986
expect(normalized).toContain("Model: anthropic/claude-opus-4-7");
2001-
expect(normalized).toContain("oauth (claude-cli)");
1987+
expect(normalized).toContain("native (claude-cli)");
20021988
expect(normalized).not.toContain("api-key (env: ANTHROPIC_API_KEY)");
20031989
expect(normalized).not.toContain("Usage:");
20041990
});

‎src/status/status-message.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,14 @@ type StatusArgs = {
124124
now?: number;
125125
};
126126

127-
type NormalizedAuthMode = "api-key" | "oauth" | "token" | "aws-sdk" | "mixed" | "unknown";
127+
type NormalizedAuthMode =
128+
| "api-key"
129+
| "oauth"
130+
| "token"
131+
| "aws-sdk"
132+
| "native"
133+
| "mixed"
134+
| "unknown";
128135

129136
function normalizeAuthMode(value?: string): NormalizedAuthMode | undefined {
130137
const normalized = normalizeOptionalLowercaseString(value);
@@ -143,6 +150,9 @@ function normalizeAuthMode(value?: string): NormalizedAuthMode | undefined {
143150
if (normalized === "aws-sdk" || normalized.startsWith("aws-sdk ")) {
144151
return "aws-sdk";
145152
}
153+
if (normalized === "native" || normalized.startsWith("native ")) {
154+
return "native";
155+
}
146156
if (normalized === "mixed" || normalized.startsWith("mixed ")) {
147157
return "mixed";
148158
}

0 commit comments

Comments
 (0)