Input & Output Guardrails
Risk-score incoming messages and mask PII in agent responses using Agency Swarm’s native guardrail decorators.
BaseTool Mixin
Intercept individual tool calls before they execute by mixing Vaultak checks into any BaseTool subclass.
Install
vtk_).
Guardrail Approach
Agency Swarm’s@input_guardrail and @output_guardrail decorators let you intercept messages at the agency boundary without touching any tool code.
- Input guardrail — risk-scores each incoming message before the agent processes it; blocks if the score meets or exceeds your threshold.
- Output guardrail — masks PII in agent responses before they reach the user.
asyncio.to_thread() is required because Vaultak SDK calls are synchronous and guardrail functions are async. This keeps the event loop non-blocking.Tool-Level Approach
For per-tool risk scoring, subclassBaseTool through the VaultakMixin. The mixin intercepts run(), calls Vaultak before execution, and masks PII in string outputs afterward.
Inherit
VaultakMixin before BaseTool so Python’s MRO calls VaultakMixin.run() first, then chains to your tool’s run() via super().Combined Example
Use both approaches together for defence-in-depth: guardrails screen all messages, the mixin secures individual high-risk tools.Stricter thresholds for sensitive agencies
For agencies with access to databases, payment systems, or external APIs, lower the threshold to block medium-risk actions:Configuration reference
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | — | Your Vaultak API key — required |
agent_name | str | "agency-swarm-agent" | Label shown in the Vaultak dashboard |
RISK_THRESHOLD | float | 7.0 | Score (0-10) at or above which actions are blocked |
What gets monitored
| Event | Vaultak action |
|---|---|
| Incoming message (input guardrail) | Risk-scored; blocked via tripwire_triggered=True if score >= threshold |
| Policy check | Validated against your dashboard-configured rules |
Tool call (VaultakMixin) | Risk-scored; blocked via RuntimeError if score >= threshold |
Tool output (VaultakMixin) | Scanned for PII and masked before returning to the agent |
| Agent response (output guardrail) | PII masked before the response reaches the user |