TaskResult.error.
The retry-with-feedback prompt wiring described below (upstream output + guardrail feedback injected into the next attempt’s prompt) requires a
praisonaiagents build from 2026-07-28 or later (see upstream fixes 36da000 and de5a95d). On earlier builds task.validation_feedback was populated on the Task object, but the retry attempt’s LLM prompt was assembled without it — the retry ran with the same original prompt as attempt 1.Decision routing is case- and whitespace-insensitive as of the
praisonaiagents
build merging MervinPraison/PraisonAI#4260
(2026-08-23). On earlier builds a verdict with a trailing newline —
"invalid\n", which is what LLMs routinely return — missed the condition lookup and
the workflow finished silently as though everything passed: the task was not retried,
validation_feedback was not populated, and no exception was raised. Upgrade if your
judge task’s condition keys are not matching what the model returns.How It Works
Quick Start
1
Install Package
First, install the PraisonAI Agents package:
2
Create Validation with Guardrails
The simplest way to add validation is using guardrails:
How the router reads your verdict
TheProcess router applies .lower().strip() to the model’s decision before looking it up in condition, so case and surrounding whitespace never break a match.
invalid branch:
Which verdicts trigger validation feedback
Only a closed set of verdicts populatetask.validation_feedback when routed back to a previous task — Process.VALIDATION_FAILURE_DECISIONS in praisonaiagents/process/process.py is the source of truth:
"revise") can still route to a retry task via condition, but it will not populate validation_feedback with the judge’s reasoning. Use one of the listed verdicts as your retry key when you want the feedback dict populated.
Validation Methods
PraisonAI offers two primary validation approaches:1. Guardrails (Recommended)
Guardrails provide inline validation with automatic retry and feedback mechanisms.Function-Based Guardrails
LLM-Based Guardrails
For complex validation that requires understanding:2. Decision-Based Validation Workflows
For complex validation flows with multiple validators:How Validation Feedback Works
When validation fails, the system automatically:-
Captures the validation feedback including:
- The validation decision (e.g., “retry”, “invalid”)
- Detailed feedback about what was wrong
- The original output that failed
- Which validator made the decision
-
Creates typed validation outcome (recommended):
-
Passes feedback to retry task via context (legacy):
-
Includes feedback in task context for the next attempt
Under the hood the workflow process engine writes the feedback and any upstream output onto
task._execution_context. The prompt builder folds this field into the retry attempt’s context. The field is deliberately preserved across therun_task/arun_taskretry loop and reset by the Process engine before the next task is selected, so retries within the same attempt see the feedback and there is no cross-task leak.
AgentTeam task, the re-run now populates Task.validation_feedback and Process._build_task_context renders it into the retry’s prompt — the same slot that decision-based validation has always filled. The re-run is no longer a blind repeat of the identical prompt.
Since PraisonAI #4929,
AgentTeam re-runs fill Task.validation_feedback from the guardrail reason. Earlier releases logged the reason and dropped it before the re-run, so the second attempt saw the same prompt as the first with no clue about what to fix.Typed Validation Outcome (Recommended)
Use the typed outcome for robust error handling:Complete Examples
Example 1: Data Validation Pipeline
Example 2: Multi-Stage Validation
Example 3: Complex Validation with Context
Validation Feedback in Action
When validation fails, agents receive both typed outcomes and legacy feedback: Typed Outcome (Recommended):Best Practices
Clear validation criteria
Clear validation criteria
Define specific, measurable criteria and return actionable feedback strings when validation fails. Include examples of valid output in task descriptions.
Efficient validation
Efficient validation
Use function guardrails for simple checks (length, format, required fields). Reserve LLM guardrails (string prompts) for subjective quality checks.
Set reasonable retry limits
Set reasonable retry limits
Use
max_retries=3 as a default. Increase only when feedback is precise enough for the agent to self-correct.Fail fast on structural errors
Fail fast on structural errors
Validate JSON schema, required sections, or word counts before expensive downstream tasks run.
Advanced Configuration
Retry Strategies
Custom Feedback Formatting
Common Validation Patterns
Word/Character Count
Content Requirements
Troubleshooting
Validation always fails
Validation always fails
- Check validation criteria are achievable
- Verify feedback is clear and actionable
- Test validation function separately
- Increase max_retries if needed
No feedback in retry
No feedback in retry
- Ensure using proper validation return format
- Check workflow connections
- Verify decision task conditions
- Enable verbose mode for debugging
Infinite validation loops
Infinite validation loops
- Set appropriate max_retries
- Implement retry counters
- Add fallback conditions
- Log validation attempts
Related
Agent Run Outcomes
Typed validation outcomes and status handling
Guardrails
Deep dive into the guardrails system
Task Retry Policy
Per-task retry with exponential backoff
Workflows
Complex workflow patterns

