Preventing agents from declaring victory too early
The agent's confidence is not completion evidence. A harness has to make done an external, layered runtime judgment.
Notes from Learn Harness Engineering - Lecture 09
The slippery slope starts when "looks correct" becomes "done."
The lecture's password-reset example looks productive: schema changes, endpoint, email template, and passing unit tests. The hidden reality is worse: email config is missing, migration can fail halfway, and the complete reset flow never ran.
Code looks fine
Syntax is valid and local logic seems plausible.
Partial tests pass
Unit tests are green, often with mocks and isolated state.
Runtime is skipped
Startup, config, migrations, and real services stay unobserved.
Agent says done
Confidence replaces evidence, so defects move to the next session.
Unit tests only
Unit tests deliberately isolate dependencies. That design makes them poor at detecting cross-component failures.
- Renderer sends relative paths; preload expects absolute paths.
- ORM cache retains old schema state after a migration.
- Mocked config hides missing email service settings.
Execution evidence
Runtime verification observes the system after transformations from task specification to code to actual behavior.
Three layers turn completion into a gate.
The agent can request a verdict, but the harness owns the verdict. Each layer increases cost and information value, so failures should stop the pipeline early.
Syntax and static analysis
Lint, typecheck, parse, and other low-cost checks. Necessary, but never sufficient.
Runtime behavior verification
Test execution, application startup, health checks, and critical-path validation.
System-level confirmation
End-to-end testing, integration validation, and user scenario simulation.
PASS ALL THREE LAYERS BEFORE "DONE"
Core concepts
The key move is to separate subjective confidence from executable termination criteria.
Refactoring before verification corrupts the verdict.
"While we're at it" work changes the boundary between verified and unverified code. The harness should block cleanup, optimization, and style passes until the core feature has passed its functional checks.
Interface mismatch
Mocks let each side pass alone while the real boundary fails.
State propagation
Fresh test fixtures miss stale caches and migration side effects.
Environment dependency
Mock services hide configuration, latency, and availability defects.
Separate the worker from the checker.
Anthropic's 2026 research found agents give overly positive assessments of their own work. The fix is not asking the same agent to be more objective; it is using an independent checker with real runtime tests.
## Definition of Done
- Feature complete = end-to-end verification passed
- Required verification levels:
1. Unit tests pass
2. Integration tests pass
3. End-to-end flow verification passes
- Do not proceed to level 2 if level 1 fails
- Do not proceed to level 3 if level 2 fails
Harness comparison
How to prevent early victory
Externalize termination judgment.
The harness independently runs validation and uses runtime signals, not agent confidence.
Build the three-layer gate.
Static checks, runtime checks, then complete user flow. Stop at the first failed layer.
Write repairable errors.
Tell the agent what failed and where to look, for example missing email config or template path.
Capture side effects.
Observe startup, feature paths, database writes, file operations, and temporary-resource cleanup.
Bad: Test failed
Better: POST /api/reset-password returned 500.
Check that email service config exists in env vars.
Template should be at templates/reset-email.html.
Password reset case
The harness intervention catches the defects inside the session instead of paying post-hoc repair cost later.
Premature hand-in
Schema edited, endpoint written, template added, unit tests green, completion declared.
Actual omissions
No end-to-end reset link flow, failed partial migration, missing email service config.
Harness checks
Start the app, exercise the reset flow, verify database consistency and side effects.
Result
All defects discovered within the session, saving 5-10x the cost of post-hoc fixes.