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 finalOutput = "";
|
||||||
let accumulatedTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
let accumulatedTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
||||||
let costUsd: number | undefined;
|
|
||||||
let tokensLogged = false;
|
let tokensLogged = false;
|
||||||
|
|
||||||
function buildUsage(): AgentUsage | undefined {
|
function buildUsage(): AgentUsage | undefined {
|
||||||
@@ -202,7 +201,6 @@ async function runClaude(params: RunParams): Promise<AgentResult> {
|
|||||||
outputTokens: accumulatedTokens.output,
|
outputTokens: accumulatedTokens.output,
|
||||||
cacheReadTokens: accumulatedTokens.cacheRead || undefined,
|
cacheReadTokens: accumulatedTokens.cacheRead || undefined,
|
||||||
cacheWriteTokens: accumulatedTokens.cacheWrite || undefined,
|
cacheWriteTokens: accumulatedTokens.cacheWrite || undefined,
|
||||||
costUsd,
|
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
@@ -291,28 +289,18 @@ async function runClaude(params: RunParams): Promise<AgentResult> {
|
|||||||
const totalInput = inputTokens + cacheRead + cacheWrite;
|
const totalInput = inputTokens + cacheRead + cacheWrite;
|
||||||
|
|
||||||
accumulatedTokens = { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
|
accumulatedTokens = { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
|
||||||
costUsd = event.total_cost_usd ?? undefined;
|
|
||||||
|
|
||||||
log.info(
|
log.info(`» ${params.label} result: subtype=${subtype}, turns=${numTurns}`);
|
||||||
`» ${params.label} result: subtype=${subtype}, turns=${numTurns}, cost=$${costUsd?.toFixed(4) ?? "?"}`
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!tokensLogged) {
|
if (!tokensLogged) {
|
||||||
log.table([
|
log.table([
|
||||||
[
|
[
|
||||||
{ data: "Cost", header: true },
|
|
||||||
{ data: "Input", header: true },
|
{ data: "Input", header: true },
|
||||||
{ data: "Cache Read", header: true },
|
{ data: "Cache Read", header: true },
|
||||||
{ data: "Cache Write", header: true },
|
{ data: "Cache Write", header: true },
|
||||||
{ data: "Output", header: true },
|
{ data: "Output", header: true },
|
||||||
],
|
],
|
||||||
[
|
[String(totalInput), String(cacheRead), String(cacheWrite), String(outputTokens)],
|
||||||
`$${costUsd?.toFixed(4) || "0.0000"}`,
|
|
||||||
String(totalInput),
|
|
||||||
String(cacheRead),
|
|
||||||
String(cacheWrite),
|
|
||||||
String(outputTokens),
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
tokensLogged = true;
|
tokensLogged = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107596,27 +107596,21 @@ function formatJsonValue(value2) {
|
|||||||
}
|
}
|
||||||
function formatUsageSummary(entries) {
|
function formatUsageSummary(entries) {
|
||||||
if (entries.length === 0) return "";
|
if (entries.length === 0) return "";
|
||||||
const hasCost = entries.some((e) => e.costUsd !== void 0);
|
const header = "| Agent | Input | Output | Cache Read | Cache Write |";
|
||||||
const header = hasCost ? "| Agent | Input | Output | Cache Read | Cache Write | Cost |" : "| Agent | Input | Output | Cache Read | Cache Write |";
|
const separatorRow = "| --- | ---: | ---: | ---: | ---: |";
|
||||||
const fmt = (n) => n.toLocaleString("en-US");
|
const fmt = (n) => n.toLocaleString("en-US");
|
||||||
const separatorRow = hasCost ? "| --- | ---: | ---: | ---: | ---: | ---: |" : "| --- | ---: | ---: | ---: | ---: |";
|
const rows = entries.map(
|
||||||
const rows = entries.map((e) => {
|
(e) => `| ${e.agent} | ${fmt(e.inputTokens)} | ${fmt(e.outputTokens)} | ${fmt(e.cacheReadTokens ?? 0)} | ${fmt(e.cacheWriteTokens ?? 0)} |`
|
||||||
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 totalsRows = [];
|
const totalsRows = [];
|
||||||
if (entries.length > 1) {
|
if (entries.length > 1) {
|
||||||
const totalInput = entries.reduce((sum, e) => sum + e.inputTokens, 0);
|
const totalInput = entries.reduce((sum, e) => sum + e.inputTokens, 0);
|
||||||
const totalOutput = entries.reduce((sum, e) => sum + e.outputTokens, 0);
|
const totalOutput = entries.reduce((sum, e) => sum + e.outputTokens, 0);
|
||||||
const totalCacheRead = entries.reduce((sum, e) => sum + (e.cacheReadTokens ?? 0), 0);
|
const totalCacheRead = entries.reduce((sum, e) => sum + (e.cacheReadTokens ?? 0), 0);
|
||||||
const totalCacheWrite = entries.reduce((sum, e) => sum + (e.cacheWriteTokens ?? 0), 0);
|
const totalCacheWrite = entries.reduce((sum, e) => sum + (e.cacheWriteTokens ?? 0), 0);
|
||||||
const totalBase = `| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`;
|
totalsRows.push(
|
||||||
if (hasCost) {
|
`| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`
|
||||||
const totalCost = entries.reduce((sum, e) => sum + (e.costUsd ?? 0), 0);
|
);
|
||||||
totalsRows.push(`${totalBase} **$${totalCost.toFixed(4)}** |`);
|
|
||||||
} else {
|
|
||||||
totalsRows.push(totalBase);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
"<details>",
|
"<details>",
|
||||||
@@ -149453,7 +149447,6 @@ async function runClaude(params) {
|
|||||||
const thinkingTimer = new ThinkingTimer();
|
const thinkingTimer = new ThinkingTimer();
|
||||||
let finalOutput = "";
|
let finalOutput = "";
|
||||||
let accumulatedTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
let accumulatedTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
||||||
let costUsd;
|
|
||||||
let tokensLogged = false;
|
let tokensLogged = false;
|
||||||
function buildUsage() {
|
function buildUsage() {
|
||||||
const totalInput = accumulatedTokens.input + accumulatedTokens.cacheRead + accumulatedTokens.cacheWrite;
|
const totalInput = accumulatedTokens.input + accumulatedTokens.cacheRead + accumulatedTokens.cacheWrite;
|
||||||
@@ -149462,8 +149455,7 @@ async function runClaude(params) {
|
|||||||
inputTokens: totalInput,
|
inputTokens: totalInput,
|
||||||
outputTokens: accumulatedTokens.output,
|
outputTokens: accumulatedTokens.output,
|
||||||
cacheReadTokens: accumulatedTokens.cacheRead || void 0,
|
cacheReadTokens: accumulatedTokens.cacheRead || void 0,
|
||||||
cacheWriteTokens: accumulatedTokens.cacheWrite || void 0,
|
cacheWriteTokens: accumulatedTokens.cacheWrite || void 0
|
||||||
costUsd
|
|
||||||
} : void 0;
|
} : void 0;
|
||||||
}
|
}
|
||||||
const handlers2 = {
|
const handlers2 = {
|
||||||
@@ -149526,26 +149518,16 @@ async function runClaude(params) {
|
|||||||
const outputTokens = usage?.output_tokens || 0;
|
const outputTokens = usage?.output_tokens || 0;
|
||||||
const totalInput = inputTokens + cacheRead + cacheWrite;
|
const totalInput = inputTokens + cacheRead + cacheWrite;
|
||||||
accumulatedTokens = { input: inputTokens, output: outputTokens, 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}`);
|
||||||
log.info(
|
|
||||||
`\xBB ${params.label} result: subtype=${subtype}, turns=${numTurns}, cost=$${costUsd?.toFixed(4) ?? "?"}`
|
|
||||||
);
|
|
||||||
if (!tokensLogged) {
|
if (!tokensLogged) {
|
||||||
log.table([
|
log.table([
|
||||||
[
|
[
|
||||||
{ data: "Cost", header: true },
|
|
||||||
{ data: "Input", header: true },
|
{ data: "Input", header: true },
|
||||||
{ data: "Cache Read", header: true },
|
{ data: "Cache Read", header: true },
|
||||||
{ data: "Cache Write", header: true },
|
{ data: "Cache Write", header: true },
|
||||||
{ data: "Output", header: true }
|
{ data: "Output", header: true }
|
||||||
],
|
],
|
||||||
[
|
[String(totalInput), String(cacheRead), String(cacheWrite), String(outputTokens)]
|
||||||
`$${costUsd?.toFixed(4) || "0.0000"}`,
|
|
||||||
String(totalInput),
|
|
||||||
String(cacheRead),
|
|
||||||
String(cacheWrite),
|
|
||||||
String(outputTokens)
|
|
||||||
]
|
|
||||||
]);
|
]);
|
||||||
tokensLogged = true;
|
tokensLogged = true;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-25
@@ -339,40 +339,24 @@ export function formatIndentedField(label: string, content: string): string {
|
|||||||
export function formatUsageSummary(entries: AgentUsage[]): string {
|
export function formatUsageSummary(entries: AgentUsage[]): string {
|
||||||
if (entries.length === 0) return "";
|
if (entries.length === 0) return "";
|
||||||
|
|
||||||
const hasCost = entries.some((e) => e.costUsd !== undefined);
|
const header = "| Agent | Input | Output | Cache Read | Cache Write |";
|
||||||
|
const separatorRow = "| --- | ---: | ---: | ---: | ---: |";
|
||||||
const header = hasCost
|
|
||||||
? "| Agent | Input | Output | Cache Read | Cache Write | Cost |"
|
|
||||||
: "| Agent | Input | Output | Cache Read | Cache Write |";
|
|
||||||
|
|
||||||
const fmt = (n: number) => n.toLocaleString("en-US");
|
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[] = [];
|
const totalsRows: string[] = [];
|
||||||
if (entries.length > 1) {
|
if (entries.length > 1) {
|
||||||
const totalInput = entries.reduce((sum, e) => sum + e.inputTokens, 0);
|
const totalInput = entries.reduce((sum, e) => sum + e.inputTokens, 0);
|
||||||
const totalOutput = entries.reduce((sum, e) => sum + e.outputTokens, 0);
|
const totalOutput = entries.reduce((sum, e) => sum + e.outputTokens, 0);
|
||||||
const totalCacheRead = entries.reduce((sum, e) => sum + (e.cacheReadTokens ?? 0), 0);
|
const totalCacheRead = entries.reduce((sum, e) => sum + (e.cacheReadTokens ?? 0), 0);
|
||||||
const totalCacheWrite = entries.reduce((sum, e) => sum + (e.cacheWriteTokens ?? 0), 0);
|
const totalCacheWrite = entries.reduce((sum, e) => sum + (e.cacheWriteTokens ?? 0), 0);
|
||||||
const totalBase = `| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`;
|
totalsRows.push(
|
||||||
|
`| **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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user