You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
🤖 Costs tab: follow-ups for open sub-agent spend #7862
Follow-ups from #7861, which adds open sub-agent spend to the Costs tab. Each item below shows less than the real spend, never more.
Live updates while a sub-agent streams. The parent's projection refreshes when a sub-agent's stream ends, not during it. A long sub-agent turn makes the parent total jump at the end. (Codex review on 🤖 fix: include open sub-agent spend in the Costs tab #7861.)
Prompt cache section and footer token count. Both read only the parent's own ledger, so open sub-agents are left out, and the numbers jump when a sub-agent is deleted. The overview tokens already include open sub-agents.
Headless spend of a sub-agent after its last stream. For example, a status title generated for a sub-agent does not refresh the ancestors' projection until the next trigger, such as activating the parent.
Lost roll-up delta. The backend sends session-usage-delta only when the parent has a live session, and the store gets it only while it is subscribed to the parent's chat. The parent ledger then stays stale until the next activation.
Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high
More follow-ups found by independent verifiers of #7861. All need corrupt or unusual persisted state, and none was seen in 6,715 real ledgers.
Built-in model keys. A model key named toString, constructor, valueOf or hasOwnProperty makes addModelUsage read the inherited function as existing usage and throw. recordUsage on main has the same path. Fix: Object.hasOwn or a null-prototype accumulator.
Unusable ledger, empty history, running stream. The projection shows nothing for that sub-agent until its stream settles. This is likely unreachable, because a sub-agent's prompt is in history before its stream starts (not verified).
Unusable ledger while a stream is ending. The in-memory rebuild marks only orphaned in-flight files as counted. A stream whose final message is already in history but whose key is not yet settled could count once twice for a few milliseconds, until the next refresh (not reproduced).
One more follow-up, found by the corrupt-shape sweep for #7866 (items 5 to 7):
A workspace's own ledger in a wrong shape.getSessionUsage and recordUsage read session-usage.json with JSON.parse and a cast. Valid JSON in a wrong shape (for example byModel: null, byModel: "x", a null model entry, settledInFlightKeys: {}, rolledUpFrom: null, version: 2) makes them throw, or return a value that fails the getSessionUsage IPC output schema. The Costs tab then shows nothing for that workspace, and every later recordUsage of it throws, so its spend is never recorded. A parse error rebuilds from history, but a shape error does not. Fix: parse the locked read with the same self-healing parser as the lock-free reads (parseLedgerKeepingValidModels), and treat an unusable ledger like a corrupt one (rebuild from history). This existed before 🤖 fix: include open sub-agent spend in the Costs tab #7861.
Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high
One more follow-up, deferred from #7868 (Codex review, round 5). It needs an unusable ledger, so it is rare:
A locked read repairs the ledger between a stream's history commit and its settle, and the stream has no in-flight key. The stream has no key only when every one of its in-flight writes failed. Then getSessionUsage (or a token-stats cache update) can rebuild an unusable ledger from history, which already holds the final message, and the later settle adds that message again. 🤖 fix: show and record spend when a workspace's own usage ledger has a wrong shape #7868 covers this window when recordUsage does the repair itself (its messageId option) and when the stream has an in-flight key (settledInFlightKeys). A fix for this case must persist which messages the repair counted, so it needs a new ledger field.
Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high
When a usage-changed refetch fails (a transient getSessionUsage or ancestor getSubagentUsage error), the store logs it and does not retry. The Costs tab stays stale until the next usage change of that workspace or a descendant, an activation, a Costs tab open, or an activity resubscribe. A fix would retry a failed usage-change refetch (bounded backoff), or keep a per-workspace "refresh pending" flag until a fetch succeeds. Source: Codex review thread on 🤖 fix: refresh the parent's Costs tab when a sub-agent's usage changes #7867, src/browser/stores/WorkspaceStore.tsrefreshUsageAfterChange.
refreshSessionUsage is latest-wins, not single flight: a burst of usage writes on one shown workspace whose chat is not subscribed (for example headless records) costs one getSessionUsage each. Trigger: a profile that shows getSessionUsage bursts.
Activity
ThomasK33 commentedon Nov 1, 2026
More follow-ups found by independent verifiers of #7861. All need corrupt or unusual persisted state, and none was seen in 6,715 real ledgers.
toString,constructor,valueOforhasOwnPropertymakesaddModelUsageread the inherited function as existing usage and throw.recordUsageon main has the same path. Fix:Object.hasOwnor a null-prototype accumulator.ThomasK33 commentedon Nov 1, 2026
One more follow-up, found by the corrupt-shape sweep for #7866 (items 5 to 7):
getSessionUsageandrecordUsagereadsession-usage.jsonwithJSON.parseand a cast. Valid JSON in a wrong shape (for examplebyModel: null,byModel: "x", anullmodel entry,settledInFlightKeys: {},rolledUpFrom: null,version: 2) makes them throw, or return a value that fails thegetSessionUsageIPC output schema. The Costs tab then shows nothing for that workspace, and every laterrecordUsageof it throws, so its spend is never recorded. A parse error rebuilds from history, but a shape error does not. Fix: parse the locked read with the same self-healing parser as the lock-free reads (parseLedgerKeepingValidModels), and treat an unusable ledger like a corrupt one (rebuild from history). This existed before 🤖 fix: include open sub-agent spend in the Costs tab #7861.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:highThomasK33 commentedon Nov 1, 2026
One more follow-up, deferred from #7868 (Codex review, round 5). It needs an unusable ledger, so it is rare:
getSessionUsage(or a token-stats cache update) can rebuild an unusable ledger from history, which already holds the final message, and the later settle adds that message again. 🤖 fix: show and record spend when a workspace's own usage ledger has a wrong shape #7868 covers this window whenrecordUsagedoes the repair itself (itsmessageIdoption) and when the stream has an in-flight key (settledInFlightKeys). A fix for this case must persist which messages the repair counted, so it needs a new ledger field.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high🤖 fix: include open sub-agent spend in the Costs tab (coder#7861)
🤖 fix: count open sub-agents in the prompt cache summary and footer t…
🤖 fix: count open sub-agent spend despite prototype-named model keys …
ThomasK33 commentedon Nov 1, 2026
Follow-up from #7867 (deferred, not fixed there):
usage-changedrefetch fails (a transientgetSessionUsageor ancestorgetSubagentUsageerror), the store logs it and does not retry. The Costs tab stays stale until the next usage change of that workspace or a descendant, an activation, a Costs tab open, or an activity resubscribe. A fix would retry a failed usage-change refetch (bounded backoff), or keep a per-workspace "refresh pending" flag until a fetch succeeds. Source: Codex review thread on 🤖 fix: refresh the parent's Costs tab when a sub-agent's usage changes #7867,src/browser/stores/WorkspaceStore.tsrefreshUsageAfterChange.refreshSessionUsageis latest-wins, not single flight: a burst of usage writes on one shown workspace whose chat is not subscribed (for example headless records) costs onegetSessionUsageeach. Trigger: a profile that showsgetSessionUsagebursts.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:xhigh• Cost:$51.03🤖 fix: refresh the parent's Costs tab when a sub-agent's usage changes (
ThomasK33 commentedon Nov 2, 2026
All eight items are fixed on main:
Item 9 and the two follow-ups deferred from #7867 moved to #7886. Other follow-ups found during this work: #7870, #7883, #7884. Closing.
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high🤖 fix: show and record spend when a workspace's own usage ledger has …