Skip to content

fix(fusion): count worker spend once and where the person sees it - #1130

Draft
sosidudku1 wants to merge 2 commits into
mainfrom
fix/fusion-spend-accounting
Draft

sosidudku1 wants to merge 2 commits into
mainfrom
fix/fusion-spend-accounting

Conversation

@sosidudku1

@sosidudku1 sosidudku1 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Four money-accounting fixes in Fusion, grouped because they touch the same spend paths.

Worker spend near the composer (ATO-1388). The $ readout only counted the main model. Each worker runs in a throwaway session, so its calls were recorded there and never reached the person's session. Now SessionUsageLedger.forward() links a worker session to its parent when the runtime mints it, and every call recorded under the worker lands on the parent with the usual rules: a model with no known price shows as $0.31+, a local worker counts as local. Escalation advice and the judge call the provider directly, past the seam that feeds the ledger, so fusion.delegate now passes its session id to escalationComplete and the runtime records those calls there. Nothing is written to turnUsageMeter, so the per-turn planner cap is unchanged. The re-run on the escalation model goes through runTurn in a worker session, so it is counted once by the forward.

Re-run counted twice (ATO-1319). After escalationReplace re-ran a task, the row carried the re-run's usage, which the header and the checkpoint priced again at the worker rate on top of the escalation spend already counted. The row now keeps the local attempt's usage; the re-run's cost stays in escalation spend.

Split subtasks on resume (ATO-1320). The checkpoint only had rows for top-level tasks, so a subtask's spend and side-effect tools were dropped. The recorder now walks the task tree's parent links (useParents) to the root row. It does not cut the id at /, since a root id may contain one. The root's own result is still written when the split closes.

Money cap help (ATO-1315). docs/user/overnight.md and task create --max-cost-usd help now say that paid Fusion workers are not in the cap and can take a run well over it, and point to llm.runMode.fusion.turnBudgetUsd. Whether to count them in the cap is still an open decision (ATO-1288).

Tests added: usage-meter.test.ts (forwarding), escalation.test.ts (re-run usage), run-checkpoint.test.ts (subtask on root).

Merge note. #1139 adds a describe block at the same spot in src/tools/fusion/escalation.test.ts. Whichever merges second: keep both blocks.

The production wiring is tested too: forwardWorkerUsage (used by bootstrap.ts) in usage-meter.test.ts, the escalation/judge record in runtime-tool-catalog.test.ts, and the session id on judge calls in judge.test.ts.

Not yet checked on the second Mac.

- The composer's $ readout now includes Fusion workers: a worker's
  throwaway session forwards its calls to the session that delegated,
  priced by the same rules (unpriced stays unpriced, local stays local).
  Escalation and judge calls, which go straight to the provider, are
  counted on the delegating session too. (ATO-1388)
- A task re-run on the escalation model keeps the local attempt's usage
  on its row, so the status header and the checkpoint no longer price
  the re-run a second time on top of its escalation spend. (ATO-1319)
- A split's subtask finds its root through the task tree's parent
  links, so its spend and side effects reach the run checkpoint and the
  resume budget. (ATO-1320)
- The overnight doc and `task create --max-cost-usd` help say that
  Fusion workers are not in the money cap and point to
  llm.runMode.fusion.turnBudgetUsd. (ATO-1315)
Move the worker-session forward into forwardWorkerUsage so it is
tested, and test that escalation and judge calls name the delegating
session and are recorded on it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant