mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-16 00:00:46 +00:00
fix(status): show codex usage for codex harness
This commit is contained in:
committed by
Ayaan Zaidi
parent
4f437f0040
commit
757324e40f
@@ -600,12 +600,32 @@ describe("buildStatusReply subagent summary", () => {
|
||||
provider: "openai-codex",
|
||||
access: "access-token",
|
||||
refresh: "refresh-token",
|
||||
expires: Date.now() + 60_000,
|
||||
expires: Date.now() + 60 * 60_000,
|
||||
},
|
||||
},
|
||||
}),
|
||||
"utf8",
|
||||
);
|
||||
const usageResetBase = Math.floor(Date.now() / 1000);
|
||||
const usageFetch = vi.spyOn(globalThis, "fetch").mockImplementation(async () => {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
rate_limit: {
|
||||
primary_window: {
|
||||
limit_window_seconds: 18_000,
|
||||
used_percent: 9,
|
||||
reset_at: usageResetBase + 60 * 60,
|
||||
},
|
||||
secondary_window: {
|
||||
limit_window_seconds: 604_800,
|
||||
used_percent: 30,
|
||||
reset_at: usageResetBase + 3 * 24 * 60 * 60,
|
||||
},
|
||||
},
|
||||
}),
|
||||
{ status: 200, headers: { "content-type": "application/json" } },
|
||||
);
|
||||
});
|
||||
|
||||
const commonParams = {
|
||||
sessionEntry: {
|
||||
@@ -648,9 +668,13 @@ describe("buildStatusReply subagent summary", () => {
|
||||
expect(normalizedCodex).toContain("Model: openai/gpt-5.5");
|
||||
expect(normalizedCodex).toContain("oauth (openai-codex:status)");
|
||||
expect(normalizedCodex).toContain("openai-codex:status");
|
||||
expect(normalizedCodex).toContain("Usage: 5h 91% left");
|
||||
expect(normalizedCodex).toContain("Week 70% left");
|
||||
expect(normalizedImplicitCodex).toContain("Model: openai/gpt-5.5");
|
||||
expect(normalizedImplicitCodex).toContain("oauth (openai-codex:status)");
|
||||
expect(normalizedImplicitCodex).toContain("Runtime: OpenAI Codex");
|
||||
expect(normalizedImplicitCodex).toContain("Usage: 5h 91% left");
|
||||
expect(usageFetch).toHaveBeenCalled();
|
||||
},
|
||||
{
|
||||
env: {
|
||||
|
||||
@@ -167,6 +167,18 @@ function resolveStatusAuthProvider(params: {
|
||||
return params.provider;
|
||||
}
|
||||
|
||||
function resolveStatusUsageProvider(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) {
|
||||
@@ -257,9 +269,14 @@ export async function buildStatusText(params: BuildStatusTextParams): Promise<st
|
||||
includeExternalProfiles: false,
|
||||
})
|
||||
: selectedModelAuth;
|
||||
const usageStatusProvider = resolveStatusUsageProvider({
|
||||
provider: modelRefs.active.provider || provider,
|
||||
effectiveHarness,
|
||||
});
|
||||
const usageAuthLabel = modelRefs.activeDiffers ? activeModelAuth : selectedModelAuth;
|
||||
const currentUsageProvider = (() => {
|
||||
try {
|
||||
return resolveUsageProviderId(provider);
|
||||
return resolveUsageProviderId(usageStatusProvider);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
@@ -269,7 +286,7 @@ export async function buildStatusText(params: BuildStatusTextParams): Promise<st
|
||||
currentUsageProvider &&
|
||||
shouldLoadUsageSummary({
|
||||
provider: currentUsageProvider,
|
||||
selectedModelAuth,
|
||||
selectedModelAuth: usageAuthLabel,
|
||||
})
|
||||
) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user