remove cost logging from agent runs; extract secrets into own tab
- stop capturing/displaying total_cost_usd from Claude CLI (theoretical cost is misleading for subscription users) - remove Cost column from action logs table and GitHub Job Summary - extract SecretsCard into its own sidebar tab with KeyRound icon - remove children prop from AgentSettingsSection Made-with: Cursor
This commit is contained in:
committed by
pullfrog[bot]
parent
cd9c3382c7
commit
f1400ffb7c
+2
-14
@@ -189,7 +189,6 @@ async function runClaude(params: RunParams): Promise<AgentResult> {
|
||||
|
||||
let finalOutput = "";
|
||||
let accumulatedTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
||||
let costUsd: number | undefined;
|
||||
let tokensLogged = false;
|
||||
|
||||
function buildUsage(): AgentUsage | undefined {
|
||||
@@ -202,7 +201,6 @@ async function runClaude(params: RunParams): Promise<AgentResult> {
|
||||
outputTokens: accumulatedTokens.output,
|
||||
cacheReadTokens: accumulatedTokens.cacheRead || undefined,
|
||||
cacheWriteTokens: accumulatedTokens.cacheWrite || undefined,
|
||||
costUsd,
|
||||
}
|
||||
: undefined;
|
||||
}
|
||||
@@ -291,28 +289,18 @@ async function runClaude(params: RunParams): Promise<AgentResult> {
|
||||
const totalInput = inputTokens + cacheRead + cacheWrite;
|
||||
|
||||
accumulatedTokens = { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
|
||||
costUsd = event.total_cost_usd ?? undefined;
|
||||
|
||||
log.info(
|
||||
`» ${params.label} result: subtype=${subtype}, turns=${numTurns}, cost=$${costUsd?.toFixed(4) ?? "?"}`
|
||||
);
|
||||
log.info(`» ${params.label} result: subtype=${subtype}, turns=${numTurns}`);
|
||||
|
||||
if (!tokensLogged) {
|
||||
log.table([
|
||||
[
|
||||
{ data: "Cost", header: true },
|
||||
{ data: "Input", header: true },
|
||||
{ data: "Cache Read", header: true },
|
||||
{ data: "Cache Write", header: true },
|
||||
{ data: "Output", header: true },
|
||||
],
|
||||
[
|
||||
`$${costUsd?.toFixed(4) || "0.0000"}`,
|
||||
String(totalInput),
|
||||
String(cacheRead),
|
||||
String(cacheWrite),
|
||||
String(outputTokens),
|
||||
],
|
||||
[String(totalInput), String(cacheRead), String(cacheWrite), String(outputTokens)],
|
||||
]);
|
||||
tokensLogged = true;
|
||||
}
|
||||
|
||||
@@ -107596,27 +107596,21 @@ function formatJsonValue(value2) {
|
||||
}
|
||||
function formatUsageSummary(entries) {
|
||||
if (entries.length === 0) return "";
|
||||
const hasCost = entries.some((e) => e.costUsd !== void 0);
|
||||
const header = hasCost ? "| Agent | Input | Output | Cache Read | Cache Write | Cost |" : "| Agent | Input | Output | Cache Read | Cache Write |";
|
||||
const header = "| Agent | Input | Output | Cache Read | Cache Write |";
|
||||
const separatorRow = "| --- | ---: | ---: | ---: | ---: |";
|
||||
const fmt = (n) => n.toLocaleString("en-US");
|
||||
const separatorRow = hasCost ? "| --- | ---: | ---: | ---: | ---: | ---: |" : "| --- | ---: | ---: | ---: | ---: |";
|
||||
const rows = entries.map((e) => {
|
||||
const base = `| ${e.agent} | ${fmt(e.inputTokens)} | ${fmt(e.outputTokens)} | ${fmt(e.cacheReadTokens ?? 0)} | ${fmt(e.cacheWriteTokens ?? 0)} |`;
|
||||
return hasCost ? `${base} ${e.costUsd !== void 0 ? `$${e.costUsd.toFixed(4)}` : "-"} |` : base;
|
||||
});
|
||||
const rows = entries.map(
|
||||
(e) => `| ${e.agent} | ${fmt(e.inputTokens)} | ${fmt(e.outputTokens)} | ${fmt(e.cacheReadTokens ?? 0)} | ${fmt(e.cacheWriteTokens ?? 0)} |`
|
||||
);
|
||||
const totalsRows = [];
|
||||
if (entries.length > 1) {
|
||||
const totalInput = entries.reduce((sum, e) => sum + e.inputTokens, 0);
|
||||
const totalOutput = entries.reduce((sum, e) => sum + e.outputTokens, 0);
|
||||
const totalCacheRead = entries.reduce((sum, e) => sum + (e.cacheReadTokens ?? 0), 0);
|
||||
const totalCacheWrite = entries.reduce((sum, e) => sum + (e.cacheWriteTokens ?? 0), 0);
|
||||
const totalBase = `| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`;
|
||||
if (hasCost) {
|
||||
const totalCost = entries.reduce((sum, e) => sum + (e.costUsd ?? 0), 0);
|
||||
totalsRows.push(`${totalBase} **$${totalCost.toFixed(4)}** |`);
|
||||
} else {
|
||||
totalsRows.push(totalBase);
|
||||
}
|
||||
totalsRows.push(
|
||||
`| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`
|
||||
);
|
||||
}
|
||||
return [
|
||||
"<details>",
|
||||
@@ -149453,7 +149447,6 @@ async function runClaude(params) {
|
||||
const thinkingTimer = new ThinkingTimer();
|
||||
let finalOutput = "";
|
||||
let accumulatedTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
||||
let costUsd;
|
||||
let tokensLogged = false;
|
||||
function buildUsage() {
|
||||
const totalInput = accumulatedTokens.input + accumulatedTokens.cacheRead + accumulatedTokens.cacheWrite;
|
||||
@@ -149462,8 +149455,7 @@ async function runClaude(params) {
|
||||
inputTokens: totalInput,
|
||||
outputTokens: accumulatedTokens.output,
|
||||
cacheReadTokens: accumulatedTokens.cacheRead || void 0,
|
||||
cacheWriteTokens: accumulatedTokens.cacheWrite || void 0,
|
||||
costUsd
|
||||
cacheWriteTokens: accumulatedTokens.cacheWrite || void 0
|
||||
} : void 0;
|
||||
}
|
||||
const handlers2 = {
|
||||
@@ -149526,26 +149518,16 @@ async function runClaude(params) {
|
||||
const outputTokens = usage?.output_tokens || 0;
|
||||
const totalInput = inputTokens + cacheRead + cacheWrite;
|
||||
accumulatedTokens = { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
|
||||
costUsd = event.total_cost_usd ?? void 0;
|
||||
log.info(
|
||||
`\xBB ${params.label} result: subtype=${subtype}, turns=${numTurns}, cost=$${costUsd?.toFixed(4) ?? "?"}`
|
||||
);
|
||||
log.info(`\xBB ${params.label} result: subtype=${subtype}, turns=${numTurns}`);
|
||||
if (!tokensLogged) {
|
||||
log.table([
|
||||
[
|
||||
{ data: "Cost", header: true },
|
||||
{ data: "Input", header: true },
|
||||
{ data: "Cache Read", header: true },
|
||||
{ data: "Cache Write", header: true },
|
||||
{ data: "Output", header: true }
|
||||
],
|
||||
[
|
||||
`$${costUsd?.toFixed(4) || "0.0000"}`,
|
||||
String(totalInput),
|
||||
String(cacheRead),
|
||||
String(cacheWrite),
|
||||
String(outputTokens)
|
||||
]
|
||||
[String(totalInput), String(cacheRead), String(cacheWrite), String(outputTokens)]
|
||||
]);
|
||||
tokensLogged = true;
|
||||
}
|
||||
|
||||
+9
-25
@@ -339,40 +339,24 @@ export function formatIndentedField(label: string, content: string): string {
|
||||
export function formatUsageSummary(entries: AgentUsage[]): string {
|
||||
if (entries.length === 0) return "";
|
||||
|
||||
const hasCost = entries.some((e) => e.costUsd !== undefined);
|
||||
|
||||
const header = hasCost
|
||||
? "| Agent | Input | Output | Cache Read | Cache Write | Cost |"
|
||||
: "| Agent | Input | Output | Cache Read | Cache Write |";
|
||||
|
||||
const header = "| Agent | Input | Output | Cache Read | Cache Write |";
|
||||
const separatorRow = "| --- | ---: | ---: | ---: | ---: |";
|
||||
const fmt = (n: number) => n.toLocaleString("en-US");
|
||||
|
||||
const separatorRow = hasCost
|
||||
? "| --- | ---: | ---: | ---: | ---: | ---: |"
|
||||
: "| --- | ---: | ---: | ---: | ---: |";
|
||||
const rows = entries.map(
|
||||
(e) =>
|
||||
`| ${e.agent} | ${fmt(e.inputTokens)} | ${fmt(e.outputTokens)} | ${fmt(e.cacheReadTokens ?? 0)} | ${fmt(e.cacheWriteTokens ?? 0)} |`
|
||||
);
|
||||
|
||||
const rows = entries.map((e) => {
|
||||
const base = `| ${e.agent} | ${fmt(e.inputTokens)} | ${fmt(e.outputTokens)} | ${fmt(e.cacheReadTokens ?? 0)} | ${fmt(e.cacheWriteTokens ?? 0)} |`;
|
||||
return hasCost
|
||||
? `${base} ${e.costUsd !== undefined ? `$${e.costUsd.toFixed(4)}` : "-"} |`
|
||||
: base;
|
||||
});
|
||||
|
||||
// totals row (only useful when there are multiple entries)
|
||||
const totalsRows: string[] = [];
|
||||
if (entries.length > 1) {
|
||||
const totalInput = entries.reduce((sum, e) => sum + e.inputTokens, 0);
|
||||
const totalOutput = entries.reduce((sum, e) => sum + e.outputTokens, 0);
|
||||
const totalCacheRead = entries.reduce((sum, e) => sum + (e.cacheReadTokens ?? 0), 0);
|
||||
const totalCacheWrite = entries.reduce((sum, e) => sum + (e.cacheWriteTokens ?? 0), 0);
|
||||
const totalBase = `| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`;
|
||||
|
||||
if (hasCost) {
|
||||
const totalCost = entries.reduce((sum, e) => sum + (e.costUsd ?? 0), 0);
|
||||
totalsRows.push(`${totalBase} **$${totalCost.toFixed(4)}** |`);
|
||||
} else {
|
||||
totalsRows.push(totalBase);
|
||||
}
|
||||
totalsRows.push(
|
||||
`| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user