My coding agents test prompts by checking that a string is in them
What happens
When I build agent products with coding agents, the instructions usually tell them to verify their work with tests. That's reasonable for normal code. The trouble is that in an agent product, the part that matters most is the model's response, and you can't check that with a deterministic test.
So the agents look for something they can assert, and they find the prompt. I end up with tests like this:
assert "inline rubric text for tests" in system_prompt
The test passes and coverage goes up, but nothing about the model's behavior has been checked.
What it costs
- Every prompt edit breaks a test. Then the agent spends tokens rewriting the test to match the new wording, and the rewritten test proves nothing new.
- When prompts are managed outside the repo (I use Langfuse for some projects), someone edits the prompt there and the tests in the repo start failing for no real reason.
What I do now
I put this in the project rules:
- Prompts are not a test target.
- Don't write meaningless tests such as string matching against prompts.
- Judge prompt and model response quality from integration test results, using an LLM as a judge.
I don't have numbers on how well the rule holds yet. It looks to me like the same habit behind the hard gates I wrote about: coding agents reach for deterministic checks even when the thing being checked is probabilistic.
What I'd like to hear
- How do you test the behavior of an LLM-backed feature? LLM as a judge, golden examples, human review, something else?
- Have you kept your coding agent from writing prompt-content tests? What worked, and what didn't?
- If your prompts live in a tool like Langfuse, how do you keep tests and prompts from drifting apart?
Setup and context
- Agent environment
- Claude Code, Codex
- Instructions and prompts
- Project rules: prompts are not a test target; no meaningless tests such as string matching against prompts; judge prompt and response quality from integration test results using an LLM as a judge.
- Tools
- Langfuse (prompt management, some projects)
Tried this in your setup?
Share what you changed, what improved, and what still differs. Different results are useful too.