Skip to content

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

chore: I don't see a diff in your message — the "Diff:" section is empty, and the stat is blank too.

Steven Enamakel6f69453510ba
diff --git a/app/src/store/chatRuntimeSlice.test.ts b/app/src/store/chatRuntimeSlice.test.ts
index aba8eddb7d..65fb815de9 100644
--- a/app/src/store/chatRuntimeSlice.test.ts
+++ b/app/src/store/chatRuntimeSlice.test.ts
@@ -276,6 +276,27 @@ describe('chatRuntimeSlice recordChatTurnUsage', () => {
expect(bucket.turns).toBe(4);
expect(bucket.costUsd).toBeCloseTo(0.024, 6);
});
+
+ it('hydrateThreadUsage fills the gauge from the persisted final-call context', () => {
+ const store = makeStore();
+ store.dispatch(
+ hydrateThreadUsage({
+ threadId: 'thr-long',
+ inputTokens: 7_021_942,
+ outputTokens: 42_669,
+ cachedTokens: 6_466_688,
+ costUsd: 4.25,
+ turns: 3,
+ contextWindow: 1_048_576,
+ lastTurnInputTokens: 5_710_657,
+ lastTurnOutputTokens: 30_790,
+ lastTurnContextTokens: 103_900,
+ })
+ );
+ const bucket = store.getState().chatRuntime.usageByThread['thr-long'];
+ expect(bucket.lastTurnContextUsed).toBe(103_900);
+ expect(bucket.lastTurnContextUsed).toBeLessThanOrEqual(bucket.contextWindow);
+ });
});
describe('chatRuntimeSlice queue status', () => {