Skip to content

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

feat(context-usage): show cost source in cost display

Steven Enamakel521e49778e0f
diff --git a/app/src/features/conversations/aui/ContextUsage.tsx b/app/src/features/conversations/aui/ContextUsage.tsx
index 388786193a..e62168f84d 100644
--- a/app/src/features/conversations/aui/ContextUsage.tsx
+++ b/app/src/features/conversations/aui/ContextUsage.tsx
@@ -52,6 +52,16 @@ const EMPTY_USAGE = emptySessionTokenUsage();
const formatUsd = (usd: number): string => (usd >= 1 ? `$${usd.toFixed(2)}` : `$${usd.toFixed(4)}`);
+/**
+ * A cost as the core reported it: the provider's charge as is, a list-price
+ * estimate marked `≈`, and nothing (`—`) when the cost is not known. An
+ * unknown cost is never shown as a number: the core declines to guess one.
+ */
+export function formatCost(usd: number, source: CostSource): string {
+ if (source === 'unknown') return '—';
+ return source === 'estimated' ? `≈ ${formatUsd(usd)}` : formatUsd(usd);
+}
+
type BreakdownState =
| { status: 'idle' }
| { status: 'loading' }
@@ -193,11 +203,12 @@ export function ContextUsage({
: 0;
const stats = [
{ label: t('token.popCacheHit'), value: `${cacheHit}%` },
- { label: t('token.costTitle'), value: formatUsd(usage.costUsd) },
+ { label: t('token.costTitle'), value: formatCost(usage.costUsd, usage.costSource) },
...Object.values(usage.subAgents).map(sub => ({
label: t('conversations.composer.context.subagentCost').replace('{agent}', sub.agentId),
- value: `${(sub.inputTokens + sub.outputTokens).toLocaleString('en-US')} · ${formatUsd(
- sub.costUsd
+ value: `${(sub.inputTokens + sub.outputTokens).toLocaleString('en-US')} · ${formatCost(
+ sub.costUsd,
+ sub.costSource
)}`,
})),
];