Production hardening
This section covers what to turn on when you put an agent in front of real users on real infrastructure: spending caps, rate limits, per-user rights, secrets, audit trails, serving and evals. Everything here is opt-in; the framework’s defaults already work for single-tenant scripts and demos.
The whole section is organised around a single theme: safe
multi-tenancy. One shared Agent (and one Memory, one Budget,
one AuditLog) backing N users requires more than just passing
user_id= everywhere; it requires bounded state, per-user caps,
scoped permissions, observable extraction, and pluggable secret
resolution.
user_id.Rate limitingToken-bucket pacing per user_id. Throttle or raise.Per-user permissionsRoute policy decisions per user_id. Staff in BYPASS, users gated.Approval handlersSlack / ticket / human gate for PermissionDecision.ask_(...). No silent allows.Bounded in-process stateLRU + idle-TTL eviction for per-user state in StandardBudget and InMemoryMemory.Auto-extract observabilityLatency, failure rate, and cost attribution for the default-on extractor.Secrets resolutionPluggable Secrets protocol. Env / Dict / Vault / your custom backend.Audit log attributionTop-level user_id on every entry; HMAC covers it.Load testing isolationbench/multi_tenant.py. N users × M turns, isolation + budget assertions.Config fileBuild an Agent from TOML or a dict. Backends, budget, permissions, MCP.Serving over HTTPcreate_app(agent): /run, /stream, /resume. Plus the loom CLI.A2A protocolExpose an agent to other frameworks’ agents, or call theirs.EvalsScore runs offline against datasets, gate CI, sample live traffic.What you turn on, listed
| Concern | Opt-in |
|---|---|
| Per-user quota | BudgetConfig(per_user_max_*) |
| Per-user request rate | Agent(rate_limiter=TokenBucketRateLimiter(...)) |
| Tenant-specific permissions | PerUserPermissions(policies=, default=) |
| Human-in-the-loop for destructive tools | Agent(approval_handler=...) |
| Bounded in-process state | Defaults active; tune max_users / user_idle_ttl_seconds |
| Vault-backed API keys | Agent(tuning=Tuning(secrets=VaultSecrets(...))) |
| Auto-extract metrics | Agent(telemetry=OTelTelemetry(...)) |
| Per-user audit | FileAuditLog(...) (attribution is automatic) |
| Load-test isolation | bench/multi_tenant.py |
Pair this with the production checklist for the broader operational concerns (durable runtime, persistent memory, sandbox, etc.). Upgrading from 0.9? See Loomflow 0.9 → 0.10.