mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 19:23:13 +02:00
The bug: three persist sites accumulated cost instead of snapshotting it like tokens. This caused cost to be inflated 1x-72x on multi-persist sessions because the same cumulative usage was added repeatedly. Root cause: persistSessionUsageUpdate, updateSessionStoreAfterAgentRun, and the cron isolated-agent run path all used: estimatedCostUsd = existingCost + runCost But runCost was already computed from cumulative run usage, so this added the same cost repeatedly on redundant persists. Fix: snapshot cost directly like tokens already do: estimatedCostUsd = runCost Files affected: - src/auto-reply/reply/session-usage.ts - src/agents/command/session-store.ts - src/cron/isolated-agent/run.ts Tests added: - session-store.test.ts: verify cost is snapshotted, not accumulated - session.test.ts: updated existing test to verify snapshot behavior Fixes #69347