Prerequisites:
- Completed Developer Quickstart — agent registered, API key minted, rules deployed
- Agent token saved as
$DOME_AGENT_TOKEN - Gateway URL saved as
$DOME_GATEWAY_URL— must include the/gateways/{id}Gateway prefix (https://gateway.../gateways/{id}); a bare base URL fails closed - Control-plane URL saved as
$DOME_CONTROL_PLANE_URL - Python 3.12+
1. Add the SDK
2. Initialize once at startup
Construct the client during application startup. Share oneClient across threads — the gateway clients are thread-safe.
connect() prepares credentials and transport state. It does not block on local Cedar sync — only call client.start_policy_sync() if you also want in-process checks.
3. Route tool calls through the gateway
Replace direct tool invocations withclient.gateway.tools.call(). The gateway evaluates authorization, resolves credentials, and audits the call before the upstream backend ever runs.
act_as carries the end user the agent is acting on behalf of. Cedar rules read principal.act_as.email, principal.act_as.sub, and so on — refer to Authorization model.
4. Correlate a run with an activity
Wrap each agent run inclient.activity(...) so every gateway call and audit event shares an opaque activity ID.
5. Shut down cleanly
Callclose() on shutdown to release transports.
6. Verify in audit
Pull the run back withclient.audit.query(...) (or the CLI):
Next steps
Adapters
Skip manual wrapping — use the LangChain adapter for gateway tools and governed chat models.
Reference
Full configuration, act-as methods, errors, and audit reads.