Quick Start
How It Works
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
seed | int | None | None | Per-call random seed forwarded to the LLM. Overrides any seed set on the LLM instance for this call only. |
cancel_token | InterruptController | None | None | Cooperative cancellation token. When is_set() returns true at a checkpoint, raises InterruptedError(reason). Falls back to agent.interrupt_controller if not provided. |
Deterministic seed
Per-call determinism for reproducible outputs.Cooperative cancellation
Thread-safe cancellation without hard kills.Tool argument validation
Validate tool arguments before execution.| Field | Type | Description |
|---|---|---|
valid | bool | Whether validation passed |
errors | List[str] | List of error messages |
warnings | List[str] | List of warning messages |
remediation | Optional[str] | Suggested fix for validation errors |
PII redaction
Scrub sensitive data from LLM requests.
What gets scrubbed:
- Key=value pairs:
api_key=sk-…,password: hunter2,token=…→[REDACTED] - Naked tokens: OpenAI-style
sk-ABCDEF…keys →[REDACTED] - Identifiers: US SSNs
123-45-6789→[REDACTED-SSN], credit cards →[REDACTED-CC], emails →[REDACTED-EMAIL]
Which one do I use?
Common Patterns
Reproducible eval
Cancel from Ctrl+C handler
Disable redaction in tests
Best Practices
Seed reliability
Seed reliability
Some providers ignore
seed or treat it as best-effort. Don’t rely on it for production routing decisions.Thread-safe cancellation
Thread-safe cancellation
InterruptController.request(...) is thread-safe. Trip it from a signal handler, an HTTP cancel endpoint, or a parent supervisor.Fast validators
Fast validators
Validators run on every tool invocation. Avoid network calls or heavy work — return fast
ValidationResult objects.Local audit trail
Local audit trail
enable_pii_redaction() only scrubs messages going to the LLM. Your local chat history still has the raw prompt — keep it secure or scrub it separately.Related
Approval
Human-in-the-loop approvals for sensitive operations
Guardrails
Input and output validation with custom rules
Security Environment Variables
Secure handling of API keys and secrets
Hooks
Event system for BEFORE_LLM and BEFORE_TOOL hooks

