Plan Validation
Before executing a plan, validate that it is feasible, safe, and complete. Plan validation catches problems before they cause harm.
6 min•By Priygop Team•Updated 2026
Plan Validation Checks
- All required tools exist: every action in the plan maps to an available tool
- Dependencies are valid: no task depends on a task that comes after it
- No cycles: no circular dependencies between tasks
- Step count is bounded: the plan does not exceed the maximum step limit
- Sensitive actions are flagged: any write, delete, or send action requires approval
- All required inputs are available: each step has access to the data it needs
Plan Validator
Plan Validator
# Validate a plan before execution
def validate_plan(plan: list, available_tools: set, max_steps: int = 20) -> dict:
"""
Check a plan for validity before execution.
Returns validation result with any errors found.
"""
errors = []
warnings = []
step_ids = {step["id"] for step in plan}
# Check step count
if len(plan) > max_steps:
errors.append(f"Plan has {len(plan)} steps, exceeding max of {max_steps}")
for step in plan:
action = step.get("action")
# Check tool exists
if action not in available_tools and action not in ("FINISH", "ESCALATE", "HUMAN_APPROVAL"):
errors.append(f"Step {step['id']}: tool '{action}' not available")
# Check dependencies exist
for dep in step.get("depends_on", []):
if dep not in step_ids:
errors.append(f"Step {step['id']} depends on '{dep}' which does not exist")
# Warn about high-risk actions
if action in ("send_email", "delete_record", "issue_refund", "make_payment"):
if not step.get("requires_approval"):
warnings.append(f"Step {step['id']}: '{action}' is high-risk but has no approval gate")
return {
"valid": len(errors) == 0,
"errors": errors,
"warnings": warnings,
"step_count": len(plan)
}
available_tools = {"web_search", "extract_data", "summarise", "send_email"}
test_plan = [
{"id": "S1", "action": "web_search", "args": {}, "depends_on": []},
{"id": "S2", "action": "summarise", "args": {}, "depends_on": ["S1"]},
{"id": "S3", "action": "send_email", "args": {}, "depends_on": ["S2"], "requires_approval": True},
]
result = validate_plan(test_plan, available_tools)
print(f"Valid: {result['valid']}")
print(f"Errors: {result['errors']}")
print(f"Warnings: {result['warnings']}")Key Takeaways
- Before executing a plan, validate that it is feasible, safe, and complete.
- All required tools exist: every action in the plan maps to an available tool
- Dependencies are valid: no task depends on a task that comes after it
- No cycles: no circular dependencies between tasks