Skip to main content

Basic Integration Pattern

After you install Dome, create a Dome instance once at startup, then scan the input before your Agent runs and the output before you return it:
Pass 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:
Dome is asynchronous internally. In a notebook, apply nest_asyncio before you call the synchronous methods:

Work With Scan Results

Both guard_input() and guard_output() return a ScanResult:
Use 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 a DomePayload 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 a BatchScanResult:
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:
The LangChain integration builds on these objects.

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 in errored_methods, and the on-error policy decides the outcome:
With 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

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.
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.
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:
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

  1. Create one Dome instance per process and reuse it.
  2. Start in shadow mode, Dome(config, enforce=False), and review triggered_methods before you enforce.
  3. Log errored_methods so Detector outages stay visible.
  4. Enable parallel execution for latency-sensitive paths, and keep early exit on unless you need full traces.
  5. 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
Last modified on August 12, 2026