Securing a Graph
Callsecure_agent() with your uncompiled StateGraph. It detects LangGraph automatically and returns a SecureGraph that stands in for the compiled graph.
secure_agent() compiles the graph for you and best-effort wraps any tools it finds with permission checks. The returned SecureGraph supports the standard execution methods: invoke, ainvoke, stream, and astream. It also exposes .runtime (the underlying TrustRuntime) and .attestation (the identity-verification result).
Execution Flow
Oninvoke, a SecureGraph runs three stages:
1
Guard the input
Runs the input through Dome’s input Guards.
2
Execute the graph
Executes the underlying compiled graph.
3
Guard the output
Runs the graph output through Dome’s output Guards.
enforce mode, flagged input or output returns a guarded response of the form {"messages": [guarded_response]} instead of the model result. In warn mode, violations are logged and execution continues.
Streaming (
stream / astream) applies the output Guard on a best-effort basis after the stream completes, because streamed chunks cannot be retracted once emitted. For strict output enforcement, use invoke / ainvoke.Passing Compile Options
Extra keyword arguments flow through tograph.compile():
Next Steps
Trust Runtime
Identity, tool permissions, and attestation
LangChain
Content Guards for LangChain chains