Basic Integration Pattern
After you install Dome, create aDome instance once at startup, then scan the input before your Agent runs and the output before you return it:
guarded_response() to your Agent rather than the original query. A Guard such as privacy-presidio with anonymize enabled returns sanitized content, and using the sanitized value keeps the redaction in effect.
Creating a
Dome instance loads models and can take several seconds. Create it once at process startup and reuse it across requests.Asynchronous Integration Pattern
Every scan method has an asynchronous counterpart with the same arguments and return type:nest_asyncio before you call the synchronous methods:
Work With Scan Results
Bothguard_input() and guard_output() return a ScanResult:
flagged for the detection decision and enforced for the enforcement decision. In shadow mode, Dome(config, enforce=False), a flagged result reports enforced as False so you can measure a configuration before you block traffic with it.
Scan Prompt and Response Together
Pass aDomePayload when a Detector needs both sides of an exchange, such as hallucination and fact-checking Detectors:
text is mutually exclusive with prompt and response. Passing a plain string is equivalent to DomePayload(text=...).
Scan in Batches
Batch methods scan a list of items in one call and return aBatchScanResult:
BatchScanResult supports indexing, iteration, and len(). The asynchronous forms are async_guard_input_batch() and async_guard_output_batch(), and guard_output_batch() scans outputs. Detectors that call an external service limit their own concurrency through max_batch_concurrency.
Attach Identity to a Scan
Pass identifiers per call when one Dome instance serves several Agents, teams, or users. These values flow into Dome telemetry:Use Guardrails Separately
get_guardrails() returns the input and output Guardrail objects, which is useful when a framework expects each side as its own component:
Customize Blocked Messages
Blocked messages are set in the configuration, one per direction:Handle Errors
Dome catches Detector exceptions rather than propagating them. A Detector that fails or times out appears inerrored_methods, and the on-error policy decides the outcome:
Dome(enforce=True), the default policy is fail_closed, so a Detector that cannot be reached blocks the request. Set input-on-error or output-on-error explicitly when you want a different tradeoff. See Configure Guardrails.
Common Application Shapes
Streaming Responses
Streaming Responses
An output Guard cannot retract chunks that you already sent. Buffer the stream and scan the assembled response before you release it, or stream to the user and scan asynchronously when you only need detection rather than enforcement.
Multi-Turn Conversations
Multi-Turn Conversations
Scan each new user turn as it arrives rather than the whole transcript, so detection scores stay tied to the message that caused them. Include prior context only when a Detector needs it, through the
prompt and context fields of DomePayload.Retrieval-Augmented Generation
Retrieval-Augmented Generation
Treat retrieved documents as content you cannot trust. Scan them with the input Guardrail before they reach the model, and scan the generated answer with the output Guardrail:
Tool-Using Agents
Tool-Using Agents
Scan tool arguments with the input Guardrail and tool results with the output Guardrail. For identity-bound tool permissions, signed manifests, and attestation, use Trust Runtime instead of scanning tool traffic by hand.
Production Practices
- Create one
Domeinstance per process and reuse it. - Start in shadow mode,
Dome(config, enforce=False), and reviewtriggered_methodsbefore you enforce. - Log
errored_methodsso Detector outages stay visible. - Enable parallel execution for latency-sensitive paths, and keep early exit on unless you need full traces.
- Instrument Dome so blocks and latency are measurable. See Observability.
Work in Progress
The programmatic protection capabilities and Dome integrations are currently in private preview and subject to change.
Next Steps
Trust Runtime
Protect tool calls with identity, access control, and attestation
Configure Guardrails
Detailed Guard configuration
Framework Integrations
Wire Dome into your Agent framework
Observability
OpenTelemetry integration