Skip to content

Graphorin API reference v0.7.0


Graphorin API reference / @graphorin/agent / / foldChildRunUsage

Function: foldChildRunUsage()

ts
function foldChildRunUsage(
   state, 
   usageAcc, 
   childState, 
   childName): void;

Defined in: packages/agent/src/runtime/messages.ts:256

Fold a completed (or failed - tokens were spent either way) child run's usage into the parent run's accounting: state.usage, state.usageByModel and the run's UsageAccumulator (W-033). Children carrying a per-model breakdown fold model-by-model (each child model entry counts as one attempt on the parent); a child without usageByModel folds its aggregate under the synthetic id sub-agent:<name>, skipped entirely when all-zero so phantom entries never appear.

Must be called exactly once per child run at exactly one seam - a second call double-counts (pinned by test).

Parameters

ParameterType
stateRunState
usageAcc| UsageAccumulator | undefined
childStateRunState
childNamestring

Returns

void