Skyvern lets you make your workflows and tasks handle errors gracefully instead of failing silently. Every run returns aDocumentation Index
Fetch the complete documentation index at: https://skyvern-mintlify-refresh-session-endpoint-1776470899.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
status. When it’s not completed, you need to know what went wrong and respond programmatically. The flow is:
- Check
statusto detect failure states - Read
failure_reasonto get the raw error description - Set up
error_code_mappingto map failures to your own error codes - Respond in code to branch your logic based on the error code
Step 1: Check status
Every run transitions through these states:
| Status | What it means |
|---|---|
created | Run initialized, not yet queued |
queued | Waiting for an available browser |
running | AI is navigating and executing |
completed | Success—check output for results |
failed | System error (browser crash, network failure, exception) |
terminated | AI determined the goal is unachievable (login blocked, page unavailable) |
timed_out | Exceeded max_steps or time limit |
canceled | Manually stopped |
completed, failed, terminated, timed_out, canceled
You can detect failures in two ways:
- by polling
get_run - by checking the webhook payload
status field.
status field is at the top level of both responses.
For tasks
Pollget_run until the status is terminal:
For workflows
Same polling pattern works for workflow runs:failed vs terminated: A failed run hit infrastructure problems—retry might work. A terminated run means the AI recognized the goal is unachievable with current conditions. Retrying without changes (new credentials, different URL) will produce the same result.
Step 2: Read failure_reason
When a run fails or terminates, the failure_reason field contains a description of what went wrong. This is a free-text string—useful for logging but hard to branch on programmatically.
The field is available in both the polling response and webhook payload:
For tasks
For workflows
Step 3: Use error_code_mapping
failure_reason contains an AI-generated description of what went wrong. Define custom error codes to get consistent, actionable error messages.
When the run fails, Skyvern evaluates your natural language error descriptions against the page state and returns the matching code.
How it works: The error_code_mapping values are LLM-evaluated descriptions—you don’t need exact string matches. For example, "The login credentials are incorrect" will match pages showing “Invalid password”, “Wrong username”, “Authentication failed”, etc.
In tasks
Passerror_code_mapping as a parameter to run_task:
In workflows
Adderror_code_mapping to individual blocks (navigation, task, validation):
The JSON examples below include comments (
//) for clarity. Remove comments before using in actual workflow definitions—JSON does not support comments.Where the error code appears
When a mapped error occurs, your code appears inoutput.error. This field is available in both polling responses and webhook payloads:
output.error (your code) and failure_reason (raw text) are present. Use output.error for branching, failure_reason for logging.
Quick reference: Where error codes appear
| Context | Field | Example |
|---|---|---|
| Polling response | run.output.error | run.output.get("error") in Python |
| Webhook payload | output.error | Same structure as polling |
| Successful run | output contains your extracted data | No error key present |
Step 4: Respond in code
Now you can write clean switch/match logic:Validation blocks as assertions
Validation blocks are assertions that check conditions at critical points—like unit test assertions. If validation fails, the workflow terminates immediately with your error code instead of continuing and failing later with a confusing error. Use validation blocks after steps where you need to confirm success before proceeding:| Parameter | Purpose |
|---|---|
complete_criterion | Condition that must be true to continue to the next block |
terminate_criterion | Condition that stops the workflow immediately |
error_code_mapping | Maps termination conditions to your error codes |
verify_login sees a login error, the workflow terminates with output.error = "login_failed". Your Step 4 code handles it the same way as any other error code.
Common error patterns
| Error Code | Description | Typical Response |
|---|---|---|
login_failed | Credentials wrong, account locked, or MFA | Refresh credentials, retry |
captcha_required | CAPTCHA blocking automation | Use human_interaction block or browser profile |
not_found | Target data doesn’t exist | Return empty result, don’t retry |
maintenance | Site temporarily down | Schedule retry with backoff |
rate_limited | Too many requests | Add delays, use different proxy |
access_denied | Permission issue | Check account permissions |
timeout | Task took too long | Increase max_steps, simplify task |
Next steps
Reliability Tips
Write prompts that fail less often
Webhooks
Get notified when runs complete or fail

