Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(usage): distinguish subagent context from cumulative tokens #14223

Closedkvnloo(GitHub profile, opens in a new tab)wants to merge 7 commits intomain fromrefs/pull/14223/headopened View on GitHub

Showing 7 changed files with 13 additions and 10 deletions (loading 4).

x
0 of 7 viewed, 7 left
5 additions and 0 deletionsapps/server/src/provider/Layers/ClaudeAdapter.test.tsModified
View file
@@ -4382,6 +4382,11 @@
"Code reviewer checked the migration edge cases.",
assert.equal(progressEvent.payload.description, "Running background teammate");
+ assert.deepEqual(progressEvent.payload.typedUsage, {
+ contextTokens: 123,
+ toolUses: 4,
+ durationMs: 987,
+ });
}).pipe(
Effect.provideService(Random.Random, makeDeterministicRandomService()),
6 additions and 6 deletionsapps/server/src/provider/Layers/ClaudeAdapter.tsModified
View file
@@ -1296,17 +1296,17 @@
- * SDK task usage ({total_tokens, tool_uses, duration_ms}, sometimes with
- * input/output/cache breakdowns) → the typed contract shape. Unknown or
- * malformed input yields undefined rather than a partial guess.
+ * Claude task_progress/task_notification `total_tokens` is the task's
+ * current context occupancy, not lifetime processed work. It can shrink after
+ * compaction, so expose it as contextTokens and never as cumulative totalTokens.
function normalizeTaskUsage(usage: unknown): RuntimeTaskUsage | undefined {
if (typeof usage !== "object" || usage === null) {
return undefined;