Client runtime
actguard.Client is the runtime entry point. The active run state is stored in context and is required for runtime-scoped guards.
Budget scopes
client.budget_guard(...) creates a budget scope attached to the active run.
- Root and nested scopes are supported
- Usage is exposed on
guard.tokens_usedandguard.usd_used - Exceeding configured USD limits raises
BudgetExceededError - With
gateway_url+api_keyconfigured, root scope reserve/settle uses/api/v1/reserveand/api/v1/settle
budget_guard vs tool decorators
budget_guardenforces spend constraints before and during provider execution by creating reserve/settle-backed scope state for the run- Tool decorators (
rate_limit,circuit_breaker,max_attempts,timeout,idempotent,prove,enforce,tool) apply invocation guards and emit guard/tool observability events
budget_guardis budget enforcement- Tool decorators are invocation controls + observability
Tool runtime context
These decorators require an activeclient.run(...):
max_attemptsidempotent
MissingRuntimeContextError.
Chain-of-custody session
prove and enforce use session-scoped facts.
GuardError(code="NO_SESSION").
Event taxonomy
SDK event filtering modes:offsignificantverbose
run.startrun.endllm.usageguard.blockedguard.interventionbudget.limit_exceededbudget.blockedtool.invoketool.failure
tool.invokeevents are emitted only whenACTGUARD_EMIT_ALL_TOOL_RUNSis enabled (1,true,yes, oron)tool.failureemits automatically for non-guard tool failures- The SDK does not emit lifecycle events like
budget.reserved/budget.settled; those are gateway-side telemetry events - Event envelopes use
snake_casewire keys
Optional standalone usage
You can run the Python SDK in a lighter mode for per-run budgeting and tool guards without full management-plane setup.client.run(...)+ tool decorators work without gateway management APIsclient.budget_guard(...)can still run locally, but reserve/settle-backed enforcement requires gateway config (gateway_url+api_key)
Patching model providers
Enteringclient.budget_guard(...) triggers provider patching through integration modules:
- OpenAI
- Anthropic
- Google GenAI
