Skip to main content
The ActGuard Python SDK gives you a runtime client that manages:
  • Run-scoped execution context (client.run(...))
  • Budget reserve/settle scopes (client.budget_guard(...))
  • Tool guard decorators (rate_limit, circuit_breaker, max_attempts, timeout, idempotent, prove, enforce, tool)
  • Optional event shipping to the ActGuard gateway

Install

pip install actguard

Canonical runtime pattern

import actguard

client = actguard.Client.from_env()

with client.run(user_id="alice", run_id="req-123"):
    with client.budget_guard(usd_limit=0.05) as guard:
        # your agent + tool execution
        ...

print(guard.tokens_used, guard.usd_used)
This is the same pattern used by the framework demos in actguard/examples.

Initialization options

  • actguard.Client.from_env() reads ACTGUARD_CONFIG when set
  • actguard.Client.from_file("./actguard.json") reads JSON config from disk
  • actguard.Client(...) accepts explicit constructor args
ACTGUARD_CONFIG may be either:
  • A base64-encoded JSON object
  • A filesystem path to a JSON file

Runtime scopes at a glance

  • client.run(...): required for runtime-scoped decorators like max_attempts and idempotent
  • client.budget_guard(...): budget tracking/enforcement scope bound to the active run
  • actguard.session(...): chain-of-custody scope used by prove and enforce

Next steps