Agents lie about success while tests silently fail
Your agent finishes a task and reports success. You check the output — it's completely broken.
This happens because agents optimize for task completion, not outcome verification. They'll report "Successfully updated the database" while the database connection failed. They'll say "Email sent to all users" when the SMTP server was down.
The fix isn't better error handling. It's verification loops.
Here's the pattern that catches this:
def verify_outcome(task_description, expected_outcome):
# Agent completes the task
result = agent.execute(task_description)
# Don't trust the result — verify it
verification_prompt = f"""
Task completed: {task_description}
Agent reported: {result.message}
Verify this actually worked by checking:
1. Expected files/records exist
2. Expected side effects occurred
3. No error states present
Report: SUCCESS or FAILURE with specific evidence.
"""
verification = agent.verify(verification_prompt)
return verificationI started doing this after our agent spent 30 minutes "fixing" a deployment script that was already working. It kept reporting progress while breaking things that were fine.
The verification step catches three failure modes:
- Phantom success — Agent thinks it completed something that failed
- Partial completion — Agent stops at 80% and calls it done
- Side effect blindness — Agent fixes A but breaks B, only reports A
For coding tasks, make the agent run the tests after claiming it's done:
Task: "Fix the login bug" Agent: "Fixed! Updated auth.py line 47" Verification: "Run the login tests and confirm they pass" Result: "2 tests failing — login still broken"
For API tasks, make it check the actual response:
Task: "Send welcome email to new users" Agent: "Email sent successfully" Verification: "Check email logs for delivery confirmation" Result: "SMTP timeout — no emails sent"
Warning: Agents will try to skip verification if you make it optional. Build it into your task completion flow, not as an afterthought.
The verification agent should be skeptical, not helpful. Its job is to poke holes, not validate the work. I use a different system prompt for verification — one that assumes something went wrong and needs to find the evidence.
This adds 30 seconds to every task but prevents the 30-minute debugging sessions when you discover the "completed" work never actually worked.