# Testing AI agent security

How agent harnesses decide who each message speaks for, and what that does to prompt injection, measured on real APIs and a real email agent.

A series by dave8172, 8 parts. Page: https://quirkyagents.com/wizard/blog/series/agent-security-tested/

An AI agent is a model plus the code around it, the harness. The harness decides who every
message speaks for: the operator who built the app, the person using it, or a tool's output. The
model trusts each message by that label. This series tests what that means in practice, from the
API rules up to a working email agent with attacks planted in its inbox. Every number was
measured, and each part says how to repeat it.

1. [How AI agents call tools: harness, roles, rules](https://quirkyagents.com/wizard/blog/how-ai-agents-call-tools/index.md): What a model, harness, framework and gateway each do, who each message speaks for, and what the Claude and OpenAI APIs accept and reject around tool calls.
2. [Pydantic AI vs a hand-rolled agent loop, measured in 285 runs](https://quirkyagents.com/wizard/blog/pydantic-ai-vs-hand-rolled-agent-loop/index.md): One email agent, built by hand and on Pydantic AI, on Claude Haiku 5.5. Where the framework helped, and an output-mode gap that vanished on a rerun.
3. [Who does an AI agent obey? Three harnesses tested](https://quirkyagents.com/wizard/blog/who-does-an-ai-agent-obey/index.md): Operator, user, tool or background job: which one Claude and GPT follow, and how much the agent harness changes it. Measured through three harnesses.
4. [Prompt injection on an email agent: 960 runs](https://quirkyagents.com/wizard/blog/prompt-injection-email-agent-three-harnesses/index.md): An email agent with a password file and planted emails: what leaked, and why "data, not instructions" tags stopped Claude doing its job.
5. [My prompt injection guard made my agent worse. Here's the fix](https://quirkyagents.com/wizard/blog/prompt-injection-guard-made-agent-worse/index.md): firstwatch 0.1's warning made an email agent on Claude Haiku 5.5 drop its task after an attack. The fix, measured in 140 runs, and what the guard adds.
6. [I tested Superagent's Security-One on an email agent: what it reads and what it does](https://quirkyagents.com/wizard/blog/security-one-prompt-injection-classifier-email-agent/index.md): Superagent's prompt injection classifier, scored on 49 texts an email agent reads and 424 real tool calls, next to TypeSafe's Jev 1.13.0. What it caught, what it blocked by mistake, and why.
7. [How to test an AI agent for prompt injection](https://quirkyagents.com/wizard/blog/how-to-test-ai-agent-prompt-injection/index.md): A small test world, attacks with harmless twins, three delivery paths and scoring from what the agent did: the method behind this series.
8. [Approval gates for AI agent tool calls, tested in 1,940 runs](https://quirkyagents.com/wizard/blog/ai-agent-tool-approval-gates-tested/index.md): Three rules for when an AI agent must ask before it acts, tested on an email agent with planted attacks: what each one stopped, and how often it asked.
