AgentWorkshop.Budget (AgentWorkshop v0.3.0)

Copy Markdown View Source

Cost budget enforcement for Workshop agents.

Configurable budgets at global and per-agent levels. When a budget is exceeded, ask/2 and cast/2 return {:error, :budget_exceeded}.

Usage

configure(max_cost_usd: 10.00)
agent(:impl, "Coder", max_cost_usd: 2.00)

budget()          # show global remaining
budget(:impl)     # show per-agent remaining
reset_budget()    # reset global tracking

Summary

Functions

Check if spending cost for agent would exceed any budget.

Clear budget limits (does not reset cost tracking — costs are in ETS agent entries).

Get budget info for a specific agent or global.

Set a per-agent budget limit.

Set a global budget limit.

Functions

check(agent_name, agent_cumulative_cost, additional_cost)

@spec check(atom(), float(), float()) :: :ok | {:error, :budget_exceeded, String.t()}

Check if spending cost for agent would exceed any budget.

Returns :ok or {:error, :budget_exceeded, reason}.

clear()

@spec clear() :: :ok

Clear budget limits (does not reset cost tracking — costs are in ETS agent entries).

info(agent_name)

@spec info(atom() | :global) :: map()

Get budget info for a specific agent or global.

set_agent(name, max_usd)

@spec set_agent(atom(), float()) :: :ok

Set a per-agent budget limit.

set_global(max_usd)

@spec set_global(float()) :: :ok

Set a global budget limit.