Overview
Guardrails are safety mechanisms that pause agent execution when:- The agent needs sensitive information (credentials, payment details)
- The agent is uncertain and requires human guidance
- The agent encounters content that requires human verification
- The agent detects potential policy violations
Detecting Guardrails
Guardrails are detected differently depending on your integration method.REST API (Polling)
When polling a task endpoint, a guardrail appears as:WebSocket (Real-Time)
With WebSocket connections, you receive immediate notifications:Responding to Guardrails
Once a guardrail triggers, respond with the requested information or guidance. ThenewState: "resume" parameter tells the agent to continue execution from the exact point where the guardrail paused—it doesn’t restart the task.
| Parameter | Type | Required | Description |
|---|---|---|---|
actionType | string | Yes | Must be "guardrail" |
taskDetails | string | Yes | Your response to the agent |
newState | string | Yes | "resume" to continue, "stop" to cancel |
Common Guardrail Scenarios
1. Login Credentials
Guardrail:2. Payment Information
Guardrail:3. Ambiguous Instructions
Guardrail:4. Verification Needed
Guardrail:5. CAPTCHA Detection
Guardrail:6. Content Verification
Guardrail:Automated Guardrail Handling
For predictable guardrails (like login credentials), implement automated handling:Pattern 1: Credential Manager
Pattern 2: Rule-Based Handler
Pattern 3: Async Handler with Timeout
Best Practices
1. Never Hardcode Sensitive Data
Don’t put credentials directly in code:2. Implement Timeouts
Always set timeouts for human intervention:3. Log All Guardrails
Track guardrail occurrences for debugging and improvement:4. Provide Clear Responses
Be specific in your guardrail responses:Related Guides
Related Guides