Most AI agent demos work. Then you ship them, and they start doing the same three things over and over:
- Confidently wrong. The model returns a plausible answer, the pipeline trusts it, and bad data lands downstream.
- Non-deterministic output. One run returns JSON, the next returns JSON wrapped in prose, the third forgets a required field.
- Silent failure. A step half-completes, the next step runs on partial state, and nothing raises an error until a human notices.
The instinct is to blame the model and reach for a bigger one. In my experience the model is rarely the problem. The prompt chain is.
The difference between a prompt and a prompt chain
A prompt is one instruction. A prompt chain is a sequence of constrained steps where each step:
- has a single responsibility
- produces machine-validated output
- cannot proceed until the previous step's output is verified
Here is the chain that finally made my agents survive production:
-> role + seniority
-> banned-token list
-> strict JSON schema output
-> a separate verification pass
Each link does real work.
1. Role + seniority
Weak: "You are a helpful assistant."
Strong: "You are a senior backend engineer reviewing a payments migration. You have shipped PCI-compliant systems. You optimise for correctness over speed and you flag uncertainty explicitly."
Seniority changes the distribution of answers. A "senior engineer" prompt hedges less and reasons more. It is a cheap, high-leverage change.
2. Banned-token list
Models converge on the same filler: "delve into", "in today's fast-paced world", "game-changer", "it's worth noting that". In a production pipeline this filler is pure noise — and it is a signal that the model is drifting toward generic output.
I keep an explicit negative token list per prompt. If the model produces banned tokens, the output is rejected and retried. This one constraint tightened output quality more than any temperature tweak.
3. Strict JSON schema output
Free-text output is unparseable at scale. Every machine-consumed step must return JSON that validates against a schema — and if it does not validate, the step fails, it does not "try to interpret".
{
"type": "object",
"required": ["verdict", "reason", "confidence"],
"properties": {
"verdict": { "enum": ["allow", "block", "needs_human"] },
"reason": { "type": "string", "maxLength": 280 },
"confidence": { "type": "number", "minimum": 0, "maximum": 1 }
}
}
Schema-first output turns a probabilistic model into a typed function call. It is the single biggest reliability win in the whole chain.
4. A separate verification pass
This is the link most people skip, and it is the one that stops "confident and wrong" from reaching production.
The agent that acts never decides it is done. A second, independent prompt receives the tool output plus the intended action and must return a verdict against a schema. Crucially:
- the verifier is not the author — models spot a bad plan far better when they did not write it
- the verifier's output is validated — a malformed verdict is treated as a block
- the default on any doubt is
needs_human, notallow
Why chains beat single mega-prompts
| Single mega-prompt | Prompt chain | |
|---|---|---|
| Debugging | which instruction broke? | isolate the failing step |
| Output | free text | schema-validated |
| Failure mode | silent | explicit + retryable |
| Model swap | rewrite everything | swap one step |
A chain is composable. You can upgrade one link, add a verification pass, or insert a human-in-the-loop gate without touching the rest.
The takeaway
If your agent keeps breaking, stop upgrading the model and start constraining the chain. Role + seniority, a banned-token list, strict schema output, and an independent verification pass took my agents from "works in the demo" to "survives production".
I packaged the exact 32 system prompts (orchestration, code review, security audit, extraction, analysis, verification), the JSON schemas, and a stdlib-only Python multi-agent runner I use into a small toolkit:
Production AI Agent Architecture & Autonomous Prompt Chains -> https://ancuboy.gumroad.com/l/production-ai-agent-kit
It is the working runtime and prompt library behind a real autonomous agent stack — task dispatching, SQLite-backed state, exponential-backoff retry, worker heartbeats with lease reclaim, and the schema-validated verification pattern above. No third-party packages, no monthly SaaS fee.
If you only take one thing from this post: add the verification pass. It is the difference between an agent that demos well and one that ships.
Top comments (0)