feat: split session and subagent cost under the context meter

This commit is contained in:
Igor Velho
2026-08-24 15:53:16 +01:00
parent ce870b7134
commit 87509a2395
15 changed files with 68 additions and 7 deletions
@@ -20,6 +20,20 @@ describe('computeRollup', () => {
expect(result.subagentCount).toBe(3);
});
test('splits the total into the session own cost and the subagent share', () => {
const result = computeRollup(sessions, 'root');
expect(result.ownCost).toBe(1);
expect(result.subagentCost).toBe(10);
expect(result.ownCost + result.subagentCost).toBe(result.totalCost);
});
test('reports a zero subagent share for a session with no children', () => {
const result = computeRollup(sessions, 'a1');
expect(result.ownCost).toBe(5);
expect(result.subagentCost).toBe(0);
expect(result.totalCost).toBe(5);
});
test('maps each direct child to its own subtree cost', () => {
const result = computeRollup(sessions, 'root');
expect(result.perChildCost.get('a')).toBe(7);