intellibrix v1.0.0
    Preparing search index...

    Class UsageAccumulator

    Accumulates token usage (and, optionally, cost) across model calls. runAgentLoop owns a per-run accumulator; a Brick or Structure can hold a long-lived one and pass .child() into each call so totals roll up across calls (and across bricks, for a Structure).

    Index
    • Adds one model step's usage to the running totals (and to any parent this accumulator is a .child() of). modelKey (e.g. "anthropic:claude-sonnet-5") is looked up in the price table to compute cost; an unknown key makes .totals.cost undefined rather than throwing.

      Parameters

      • usage: Usage
      • OptionalmodelKey: string

      Returns void

    • Creates a new accumulator whose .add() calls roll up into this one, for per-call/per-brick totals that still contribute to a parent's grand total.

      Returns UsageAccumulator