Skip to main content

UsagePolicy

UsagePolicy defines limits and behavior when limits are reached. Common fields:
  • max_steps
  • max_llm_calls
  • max_tool_calls
  • timeout_seconds
  • Optional max_tokens, max_cost_dollars
  • on_limit: "raise" or "return"

UsageTracker

UsageTracker holds counters and enforces limits:
  • check(operation) validates budget
  • record_step(step_kind) increments counters
  • record_usage(tokens, cost) accumulates usage metadata

Context helpers

Coevolved exposes context helpers for using a tracker without threading it through every function:
  • get_usage_tracker(), set_usage_tracker(...), clear_usage_tracker()
  • check_budget(operation="step")
  • record_step(step_kind=None)
  • record_usage(tokens=0, cost=0.0)

Next steps