Expand description
Session/agent state: atomic counters, token-velocity windows, rate limits, and action budgets (brief Modules B/D and the §8 “In-Memory State” layer).
The core abstraction is StateStore: check-and-spend operations that are
atomic even under concurrent tool calls from parallel sub-agents
(silent-error class D13.9 — a budget must never over-spend by racing).
InMemoryStore is the single-node reference; a Redis Cluster backend
compiles behind the redis feature for multi-node deployments and is
contract-tested against a live server when AV_REDIS_URL is set.
All arithmetic here is checked — budget/monetary code must fail loudly, never wrap.
Re-exports§
pub use budget::ActionBudget;pub use budget::BudgetDecision;pub use budget::BudgetSpec;pub use store::InMemoryStore;pub use store::Spend;pub use store::StateError;pub use store::StateStore;pub use velocity::TokenVelocity;
Modules§
- budget
- Action budgets (Module B): stateful tool limits — per-tool caps via
max_tool_calls(e.g.db_write: 3), payout ceilings viamax_payout_usd_micros— plus per-session token ceilings. - redis_
store - Redis-backed
StateStore(brief §8 “Redis Cluster” layer). - store
- The
StateStoretrait and the in-memory reference implementation. - velocity
- Token-velocity tracking: sliding-window tokens-per-second intended for
rate limiting. (The loop-breaker’s
N+ tokensarm uses its own cumulative per-session counter, not this window.)