govern() one-liner.
with_compliance() — CrewAI
Wraps a CrewAICrew with a transparent compliance proxy. The returned object exposes the same interface as the original crew — call kickoff() or akickoff() as you normally would.
Signature
Parameters
A CrewAI
Crew instance.Path to the
.drako.yaml configuration file.Write an audit log entry after every task completes.
Call
verify_agent_identity for every agent before the first kickoff().Evaluate policy before each task and before each individual tool call.
What it does
The wrapper intercepts the full crew lifecycle:- Pre-kickoff — verifies the identity of every agent (when
auto_verify=True) and caches their DIDs. - Tool wrapping — replaces each tool’s
_run()method with a governed version (whenauto_policy=True). The governed_run()runs the following pipeline before calling the original method:- Pre-action hooks (
/api/v1/hooks/execute) - Gate 1: intent fingerprint creation (
/api/v1/intent/create) - Policy evaluation (
/api/v1/trust/evaluate) - Gate 2: intent fingerprint verification (
/api/v1/intent/verify) - FinOps cache lookup (if enabled in config)
- FinOps model routing (if enabled in config)
- Pre-action hooks (
- Post-task — records an audit log entry via the task callback (when
auto_audit=True). - On error — fires
on_errorhooks.
"PENDING_APPROVAL", "escalated") pause the agent and return a human-readable message including the approval ID. Blocked decisions ("BLOCKED", "rejected", False) return a [Drako] Action blocked: ... string instead of executing.
The
fail_closed behaviour is read automatically from governance.on_backend_unreachable in your .drako.yaml. When set to "block", a backend network error will block the tool. The default ("allow") is fail-open.Example
with_langgraph_compliance() — LangGraph
Wraps a compiled LangGraph graph by injecting aDrakoCheckpointer that intercepts every state transition.
Signature
Parameters
A compiled LangGraph object (result of
StateGraph(...).compile()).Path to the
.drako.yaml configuration file.An existing LangGraph checkpointer to delegate
put/get calls to after compliance checks. Pass your MemorySaver or SqliteSaver here to combine Drako with built-in checkpointing.Write an audit log entry on every state transition.
Evaluate policy on every state transition. The
source node name from the checkpoint metadata is used as the action label.What it does
The wrapper returns a_LangGraphProxy that forwards invoke(), ainvoke(), stream(), and astream() to the original graph, injecting the DrakoCheckpointer into the LangGraph config dict on each call.
The DrakoCheckpointer fires on every put / aput (state write):
- Evaluates policy for the transition node (when
auto_policy=True). - Records an audit log entry with the node name and checkpoint timestamp (when
auto_audit=True). - Delegates to
inner_checkpointerif one was provided.
auto_verify is always False for LangGraph because graph nodes do not have named agent identities by default.Example
with_autogen_compliance() — AutoGen
Adds a silentDrakoObserver agent to an AutoGen GroupChat. The observer audits every message without generating replies.
Signature
Parameters
An AutoGen
GroupChat instance.Path to the
.drako.yaml configuration file.Record an audit log entry for every message exchange.
Evaluate policy before processing each message. The sender’s name is used as the action label.
What it does
The wrapper returns an_AutoGenGroupChatProxy that:
- Agent verification — calls
verify_agent_identityfor every agent in the chat beforerun()starts. - Message interception — the
DrakoObservercallson_message()for each exchange, evaluating policy and writing audit log entries. - Transparent proxy — all other attributes are forwarded to the underlying
GroupChat.
Example
Common kwargs
All three wrapper functions accept the following shared parameters:| Parameter | Type | Default | Description |
|---|---|---|---|
config_path | str | ".drako.yaml" | Path to the Drako config file. |
auto_audit | bool | True | Write audit log entries. |
auto_policy | bool | True | Evaluate policy before actions. |
auto_verify is also supported by with_compliance() and with_autogen_compliance() but is not applicable to LangGraph (always False).
Framework examples side-by-side
- CrewAI
- LangGraph
- AutoGen