mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:30:43 +00:00
fix Codex OAuth status auth label
This commit is contained in:
@@ -2,6 +2,14 @@
|
||||
|
||||
Docs: https://docs.openclaw.ai
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Changes
|
||||
|
||||
### Fixes
|
||||
|
||||
- Status: show the `openai-codex` OAuth profile for `openai/gpt-*` sessions running through the native Codex runtime instead of reporting auth as unknown. (#76197) Thanks @mbelinky.
|
||||
|
||||
## 2026.5.2
|
||||
|
||||
### Highlights
|
||||
|
||||
@@ -534,6 +534,91 @@ describe("buildStatusReply subagent summary", () => {
|
||||
expect(normalized).not.toContain("Fast · codex");
|
||||
});
|
||||
|
||||
it("uses Codex OAuth auth labels for openai models running on the Codex harness", async () => {
|
||||
registerStatusCodexHarness();
|
||||
|
||||
await withTempHome(
|
||||
async (dir) => {
|
||||
const authPath = path.join(
|
||||
dir,
|
||||
".openclaw",
|
||||
"agents",
|
||||
"main",
|
||||
"agent",
|
||||
"auth-profiles.json",
|
||||
);
|
||||
fs.mkdirSync(path.dirname(authPath), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
authPath,
|
||||
JSON.stringify({
|
||||
version: 1,
|
||||
profiles: {
|
||||
"openai-codex:status": {
|
||||
type: "oauth",
|
||||
provider: "openai-codex",
|
||||
access: "access-token",
|
||||
refresh: "refresh-token",
|
||||
expires: Date.now() + 60_000,
|
||||
},
|
||||
},
|
||||
}),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const commonParams = {
|
||||
sessionEntry: {
|
||||
sessionId: "sess-status-codex-oauth",
|
||||
updatedAt: 0,
|
||||
},
|
||||
sessionKey: "agent:main:main",
|
||||
parentSessionKey: "agent:main:main",
|
||||
sessionScope: "per-sender" as const,
|
||||
statusChannel: "mobilechat",
|
||||
provider: "openai",
|
||||
model: "gpt-5.5",
|
||||
contextTokens: 32_000,
|
||||
resolvedFastMode: false,
|
||||
resolvedVerboseLevel: "off" as const,
|
||||
resolvedReasoningLevel: "off" as const,
|
||||
resolveDefaultThinkingLevel: async () => undefined,
|
||||
isGroup: false,
|
||||
defaultGroupActivation: () => "mention" as const,
|
||||
};
|
||||
|
||||
const codexText = await buildStatusText({
|
||||
cfg: {
|
||||
...baseCfg,
|
||||
agents: {
|
||||
defaults: {
|
||||
agentRuntime: { id: "codex", fallback: "none" },
|
||||
},
|
||||
},
|
||||
},
|
||||
...commonParams,
|
||||
});
|
||||
const piText = await buildStatusText({
|
||||
cfg: baseCfg,
|
||||
...commonParams,
|
||||
});
|
||||
|
||||
const normalizedCodex = normalizeTestText(codexText);
|
||||
const normalizedPi = normalizeTestText(piText);
|
||||
expect(normalizedCodex).toContain("Model: openai/gpt-5.5");
|
||||
expect(normalizedCodex).toContain("oauth (openai-codex:status)");
|
||||
expect(normalizedCodex).toContain("openai-codex:status");
|
||||
expect(normalizedPi).toContain("Model: openai/gpt-5.5");
|
||||
expect(normalizedPi).toContain("unknown");
|
||||
expect(normalizedPi).not.toContain("openai-codex:status");
|
||||
},
|
||||
{
|
||||
env: {
|
||||
OPENAI_API_KEY: undefined,
|
||||
OPENAI_OAUTH_TOKEN: undefined,
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("uses workspace-scoped auth evidence in /status auth labels", async () => {
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-status-auth-label-"));
|
||||
const workspaceDir = path.join(tempRoot, "workspace");
|
||||
|
||||
@@ -136,6 +136,18 @@ async function resolveStatusHarnessId(params: {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveStatusAuthProvider(params: {
|
||||
provider: string;
|
||||
effectiveHarness?: string;
|
||||
}): string {
|
||||
const harness = normalizeOptionalLowercaseString(params.effectiveHarness);
|
||||
const provider = normalizeOptionalLowercaseString(params.provider);
|
||||
if (harness === "codex" && provider === "openai") {
|
||||
return "openai-codex";
|
||||
}
|
||||
return params.provider;
|
||||
}
|
||||
|
||||
function formatAgentTaskCountsLine(agentId: string): string | undefined {
|
||||
const snapshot = buildTaskStatusSnapshot(listTasksForAgentIdForStatus(agentId));
|
||||
if (snapshot.totalCount === 0) {
|
||||
@@ -178,10 +190,23 @@ export async function buildStatusText(params: BuildStatusTextParams): Promise<st
|
||||
selectedModel: model,
|
||||
sessionEntry,
|
||||
});
|
||||
const effectiveHarness =
|
||||
params.resolvedHarness ??
|
||||
(await resolveStatusHarnessId({
|
||||
cfg,
|
||||
provider,
|
||||
model,
|
||||
agentId: statusAgentId,
|
||||
sessionKey,
|
||||
sessionEntry,
|
||||
}));
|
||||
const selectedModelAuth = Object.hasOwn(params, "modelAuthOverride")
|
||||
? params.modelAuthOverride
|
||||
: resolveModelAuthLabel({
|
||||
provider,
|
||||
provider: resolveStatusAuthProvider({
|
||||
provider,
|
||||
effectiveHarness,
|
||||
}),
|
||||
cfg,
|
||||
sessionEntry,
|
||||
agentDir: statusAgentDir,
|
||||
@@ -192,7 +217,10 @@ export async function buildStatusText(params: BuildStatusTextParams): Promise<st
|
||||
? params.activeModelAuthOverride
|
||||
: modelRefs.activeDiffers
|
||||
? resolveModelAuthLabel({
|
||||
provider: modelRefs.active.provider,
|
||||
provider: resolveStatusAuthProvider({
|
||||
provider: modelRefs.active.provider,
|
||||
effectiveHarness,
|
||||
}),
|
||||
cfg,
|
||||
sessionEntry,
|
||||
agentDir: statusAgentDir,
|
||||
@@ -297,16 +325,6 @@ export async function buildStatusText(params: BuildStatusTextParams): Promise<st
|
||||
agentId: statusAgentId,
|
||||
sessionEntry,
|
||||
}).enabled;
|
||||
const effectiveHarness =
|
||||
params.resolvedHarness ??
|
||||
(await resolveStatusHarnessId({
|
||||
cfg,
|
||||
provider,
|
||||
model,
|
||||
agentId: statusAgentId,
|
||||
sessionKey,
|
||||
sessionEntry,
|
||||
}));
|
||||
const agentFallbacksOverride = resolveAgentModelFallbacksOverride(cfg, statusAgentId);
|
||||
const { buildStatusMessage } = await loadStatusMessageRuntime();
|
||||
const explicitThinkingDefault =
|
||||
|
||||
Reference in New Issue
Block a user