Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(chat): allow unknown turn and subagent costs

Steven Enamakel6132c9244f38
diff --git a/app/src/services/chatService.ts b/app/src/services/chatService.ts
index fb8672887f..7f6581c8c1 100644
--- a/app/src/services/chatService.ts
+++ b/app/src/services/chatService.ts
@@ -80,9 +80,16 @@ export interface SubagentUsageWire {
agent_id: string;
input_tokens: number;
output_tokens: number;
- cost_usd: number;
+ /** `null` when the child's cost is not known. */
+ cost_usd: number | null;
}
+/**
+ * Where a reported cost came from: every call billed by the provider, some
+ * call priced from published list rates, or not known at all.
+ */
+export type CostSource = 'charged' | 'estimated' | 'unknown';
+
/**
* Holistic token/cost/context totals for a completed turn, carried on
* `chat_done`. Every numeric is a turn total (parent agent + any sub-agents);
@@ -93,7 +100,13 @@ export interface TurnUsageWire {
input_tokens: number;
output_tokens: number;
cached_input_tokens: number;
- cost_usd: number;
+ /**
+ * The turn's cost, or `null` when the core does not know it (no reported
+ * charge and no catalogued price). Never a guessed rate.
+ */
+ cost_usd: number | null;
+ /** Absent from an older core, whose `cost_usd` is always a number. */
+ cost_source?: CostSource;
context_window: number;
/**
* Tokens the parent's context held after the turn's final model call: the
@@ -658,7 +671,8 @@ export interface SubagentProgressDetail {
input_tokens?: number;
output_tokens?: number;
cached_input_tokens?: number;
- cost_usd?: number;
+ /** `null` when the child's cost is not known. */
+ cost_usd?: number | null;
/**
* Provider-assigned id of the `spawn_subagent`/`spawn_async_subagent`/
* `delegate_*` tool call that started this delegation