Building Agent Harnesses We Can Trust
what the agent is told, how it is scored, what it can see

Gustavo Pinto
AI Staff Engineer, iFood
Professor, UFPA
The harness: everything around the model
Adapted from Martin Fowler's harness engineering1 linkedin.com/in/ghlp
The harness: everything around the model
Adapted from Martin Fowler's harness engineering1 linkedin.com/in/ghlp
The harness: everything around the model
Adapted from Martin Fowler's harness engineering1 linkedin.com/in/ghlp
The harness: everything around the model
Adapted from Martin Fowler's harness engineering1 linkedin.com/in/ghlp
The harness: everything around the model
Adapted from Martin Fowler's harness engineering1 linkedin.com/in/ghlp
Think of the agent as a new hire
Skills
- Like a job description
- Says if the agent only advises or acts
- Reviewers read it, not the code
Tests
- Like a sales target
- Green build and high coverage
- The agent hits the number, not the goal
Access
- Like an access badge
- Logs, metrics, live database state
- Locked behind VPNs and proxies
linkedin.com/in/ghlp
Three studies, one large company
About 8,000 engineers. The numbers are local; the pattern is general. linkedin.com/in/ghlp
Skills: what the agent is told
I
Before it acts
what it is told
II
After it acts
how it is scored
III
When it breaks
what it can see
linkedin.com/in/ghlp
Skills
502 skills, written and run by agents
Agents help write them. Agents run them. Humans review them.
- From one company catalog
- Mostly data and docs work
- Only 1% run on their own
Pinto, Costa, and de Souza, 2026 linkedin.com/in/ghlp
A skill is a set of instructions
Nobody checks that the top and the body match
Illustrative example linkedin.com/in/ghlp
Skills
One in three skills is mislabeled
We compared the label of 502 skills with their body.
- 13% say “I assist” but run shell
- 21% say “I execute” but stop to ask
- Reviewers end up checking the wrong ones
502 skills from a company catalog linkedin.com/in/ghlp
Example: postgres-query
What it can do
- Run
psql on production - Write to the database
- Our check calls it aligned
What stops it
- One sentence the agent may ignore
- A similar skill blocks writes in code
linkedin.com/in/ghlp
Writing “ask first” is not enough
- 60% of skills tell the agent to ask before acting
- Only 3% use a built-in confirmation step
- In the rest, the agent decides whether to ask
linkedin.com/in/ghlp
Skills
The riskiest commands hide
Only 6% of skills run risky programs.
- 81% of those are mislabeled
rm -rf and sudo in “helper” skills- Raw database access in a “safe” skill
linkedin.com/in/ghlp
What the harness should do with skills
When a skill is added
- Read the body, not just the label
- Flag “helper” skills that run shell
- List every tool it can call
When a skill runs
- Allow only the listed tools
- Use real checkpoints, not prose
- Block writes in code, not in text
linkedin.com/in/ghlp
Tests: how the agent is scored
I
Before it acts
what it is told
II
After it acts
how it is scored
III
When it breaks
what it can see
linkedin.com/in/ghlp
Eight repositories, tests written by agents
Agents write the code and the tests that check it.
- Each repo has
CLAUDE.md or AGENTS.md - Up to 465 commits co-written by AI
- 20 measures of test quality
| What it is | Language | Code (lines) | Tests | Coverage |
|---|
| P1 | Customer journeys | Python, TS | 79k | 7,694 | 88% |
| P2 | Support backend | Python, TS | 96k | 7,085 | 91% |
| P3 | Cash-flow API | Go | 23k | 821 | 59% |
| P4 | MCP server | Python | 4k | 369 | 88% |
| P5 | Multi-agent platform | Python | 41k | 3,865 | 82% |
| P6 | Segmentation API | Kotlin | 2k | 110 | 49% |
| P7 | Agent API | Python | 3k | 318 | 63% |
| P8 | Payroll-loan API | Kotlin | 2k | 270 | 53% |
AI co-written commits are a lower bound. Coverage is line coverage, measured locally.
linkedin.com/in/ghlp
Up to 30% of tests only check that a value exists
Weak
is not None, len > 0- Counts as covered
- Misses a wrong value
Strong
- Checks the actual value
- Fails if the logic breaks
linkedin.com/in/ghlp
Tests
The test that tests a fake
The test swaps the real code for a fake, then checks the fake.
- Passes even if the code is broken
- Up to 74% of fakes replace real logic
linkedin.com/in/ghlp
100% coverage, zero bugs caught
schemas/collection.py: every line covered
- We planted 4 small bugs in it
- The tests caught none
- The tests create the object, but never check its fields
linkedin.com/in/ghlp
The vote: the agent does not cheat
It writes the tests coverage asks for
- No tests weakened on purpose
- Coverage checks that code ran
- Mutation testing checks that bugs get caught
linkedin.com/in/ghlp
Tests
The better check costs more
One team turned mutation testing off in Nov 2026.
- 60 to 70 minutes per merge request
- Only 3 of 8 projects require it
linkedin.com/in/ghlp
What the harness should do with tests
When the agent writes tests
- Flag tests that only check a value exists
- Show it the bugs its tests missed
- Ask for a test that catches them
When a merge is checked
- Require mutation testing, not just coverage
- Run it only on changed files
- Predict which mutants matter1
linkedin.com/in/ghlp
Incidents: what the agent can see
I
Before it acts
what it is told
II
After it acts
how it is scored
III
When it breaks
what it can see
linkedin.com/in/ghlp
Incidents
Ten days, eight database incidents
Claude Code fixing a production messaging system.
- 22 fix commits
- 2 to 4 deploys per incident day
linkedin.com/in/ghlp
Seven minutes, three wrong turns
Real agent messages from the Nov 11 incident. Some were translated from Portuguese. linkedin.com/in/ghlp
The fix that brought the bug back
Its own comment said safe. The old bug came back.
Deadlock retry, Nov 11: rollback wiped work that was not saved yet linkedin.com/in/ghlp
Incidents
“Done.” It was not.
Before the incidents, the agent reported a fix as done.
- The change never reached the code
- It noticed only turns later
- “The fix was NOT applied… the bug is still in app.py:51”
linkedin.com/in/ghlp
Who held the lock?
The answer existed, but the agent could not reach it
- The app log cut the message short
- The full report was in the database log
- The agent only had the app log
linkedin.com/in/ghlp
What the agent could not reach
- “I do not have access to the database nor exec in prod (I tried, no permission)”
- “I need the real Datadog log… I can't access it (requires login)”
- To see live locks, it had to deploy a probe
linkedin.com/in/ghlp
The pattern
- 3 simple incidents: fixed on the first try
- 5 timing bugs: all began with a wrong fix
- Each guess fit what the agent could see
- Missing data, not bad reasoning
linkedin.com/in/ghlp
A human still had to catch it
- Someone who knew locks and races
- Asked for the right evidence
- Checked that the fix really worked
linkedin.com/in/ghlp
What the harness should do with production access
Before an incident
- Keep lock and deadlock history
- Never cut logs short
- Tell the agent which environment it is in
During an incident
- Allow read-only database queries
- Stay inside existing security
- Replay load to test a guess before deploying
linkedin.com/in/ghlp
Takeaways
- 1
Skills: check what they can runread the body, allow only listed tools, block writes in code
- 2
Tests: score bugs caught, not lines runrequire mutation testing, show the agent what it missed
- 3
Production: give the agent safe eyesfull logs, read-only queries, replay before deploying
- 4
Fix the signals, not just the modelcheck the job, the target, and the badge
linkedin.com/in/ghlp
That’s all Folks!
linkedin.com/in/ghlp · mail@gustavopinto.org · gustavopinto.org · ML4SE.substack.com