Skip to main content

Module budget

Module budget 

Source
Expand description

The token and cost budget of a run, and the checkpoints of running nodes.

A run’s budget (RunBudget) is one pair of counters shared by every frame and every child run. Model nodes that track their turns (crate::node::Node::tracks_turns) charge it after each model response (crate::node::NodeContext::charge), with its cost, so an agent loop is bounded per turn and a failed call is paid for too. The engine charges every other node the tokens it reports when it completes. The counters and the limits are in the snapshot and go on after resume.

A checkpoint (NodeProgress) is the progress a running node keeps for its next attempt: a retry after an error or a timeout gets it, and so does the attempt that runs after the run was preempted and resumed.

Structs§

BudgetState
A run’s budget as its snapshot keeps it: what was charged, and the limits the run started with (a request may have set lower ones than the engine’s, and a resumed run keeps them).
NodeProgress
The checkpoint of one execution of a node that tracks its turns (crate::node::Node::tracks_turns), shared by its attempts.
RunBudget
The budget of one run: limits, and what was charged against them.