From 7b7293ca26a2b5d989701fcc4ea9242cee06c009 Mon Sep 17 00:00:00 2001 From: enternal111 <48542794+enternal111@users.noreply.github.com> Date: Mon, 16 Nov 2026 15:36:54 +0800 Subject: [PATCH 1/2] fix: report the latest step tokens instead of accumulating across steps --- src/handlers/step.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handlers/step.ts b/src/handlers/step.ts index 3bf155c..96af31c 100644 --- a/src/handlers/step.ts +++ b/src/handlers/step.ts @@ -65,8 +65,8 @@ function accumulateTotals( if (!existing) return const next: SessionTotals = { ...existing, - tokens: existing.tokens + tokens, - cost: existing.cost + cost, + tokens, + cost, messages: existing.messages + (incrementMessages ? 1 : 0), } setBoundedMap(ctx.tracing.sessionTotals, sessionID, next) From 233d567d8d242dcd5c36d93f3dc150a48775e994 Mon Sep 17 00:00:00 2001 From: enternal111 <48542794+enternal111@users.noreply.github.com> Date: Mon, 16 Nov 2026 16:10:04 +0800 Subject: [PATCH 2/2] fix: keep per-step cost accumulation and preserve last known tokens --- src/handlers/step.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handlers/step.ts b/src/handlers/step.ts index 96af31c..feade3c 100644 --- a/src/handlers/step.ts +++ b/src/handlers/step.ts @@ -65,8 +65,8 @@ function accumulateTotals( if (!existing) return const next: SessionTotals = { ...existing, - tokens, - cost, + tokens: tokens > 0 ? tokens : existing.tokens, + cost: existing.cost + cost, messages: existing.messages + (incrementMessages ? 1 : 0), } setBoundedMap(ctx.tracing.sessionTotals, sessionID, next)