Skip to content

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

feat(conversations): show context usage in aui

Steven Enamakelee7485c9d145
diff --git a/app/src/features/conversations/aui/ContextUsage.tsx b/app/src/features/conversations/aui/ContextUsage.tsx
index b7f7c05293..4836b54d35 100644
--- a/app/src/features/conversations/aui/ContextUsage.tsx
+++ b/app/src/features/conversations/aui/ContextUsage.tsx
@@ -85,9 +85,13 @@ export function contextBreakdownSegments(
systemPrompt += section.est_tokens;
}
}
+ // Partition the context the last turn ended with. Every reply the turn
+ // produced is in that context (each one is input to the next call), so the
+ // turn's output is a share of it and the rest is the conversation.
+ const output = Math.min(usage.lastTurnOutputTokens, usage.lastTurnContextUsed);
const yourInput = Math.max(
0,
- usage.lastTurnInputTokens - systemPrompt - toolSchemas - hiddenToolUsage
+ usage.lastTurnContextUsed - output - systemPrompt - toolSchemas - hiddenToolUsage
);
return [
{