How to Improve Your AI Agent's System Prompt From Real Conversations
To improve your agent's system prompt using real production conversations, find the failing conversations by intent, cluster the failure into one named pattern, write one prompt rule that fixes it, test the change agains
To improve your agent's system prompt using real production conversations, find the failing conversations by intent, cluster the failure into one named pattern, write one prompt rule that fixes it, test the change against the past conversations that failed, and ship it as a reviewed change. Agnost AI runs this loop for you, best for teams who want the fix delivered as a pull request: it detects failures across whole production conversations, alerts when a failure pattern rises, and Auto Improve opens a pull request with the fix tested against past runs, for a human to review. Prompt optimizers such as Pydantic Logfire and DSPy's GEPA can propose the edit itself.
Quick answer: five steps
- Find failing conversations by intent. Group production conversations by what the user wanted, then pull the ones that went wrong: frustration, repeated questions, corrections, abandonment, tool-call errors.
- Cluster the failure. Name the recurring pattern ("refuses refunds it is allowed to issue") and count it. Fix the most frequent pattern first, not the freshest.
- Write the rule. Turn the pattern into one specific prompt instruction with explicit boundaries, such as "Issue refunds under $50 directly; escalate only above $50."
- Test against past conversations. Replay the conversations that failed with the new prompt, plus a golden set of healthy ones to catch regressions.
- Ship. Merge it as a reviewed pull request that names the pattern and the evidence, then check the failure rate on new traffic.
Disclosure: We make Agnost AI. Facts about the other tools come from each vendor's own docs or site, checked on November 18, 2026.
The approach in one paragraph
System prompt optimization works best when it stops being a vibes exercise. Instead of staring at your prompt and adding another "be concise" line because something felt off, you mine your real production conversations for failures and friction, cluster them into recurring patterns, then translate each pattern into one specific prompt change you can test and ship as a reviewable diff. That is the whole loop, and the rest of this post is how to actually run it.
Most teams I talk to iterate on prompts the same way: someone notices a bad reply in a Slack screenshot, opens the prompt, and tweaks a sentence. Three weeks later nobody remembers why that sentence is there, and the prompt is 1,400 tokens of accumulated superstition. There is a better way, and it does not require a research team.
Why guesswork prompts go stale
Here is the thing nobody tells you when you ship your first agent: your prompt is fine for the demo and wrong for production. The demo covers the three happy paths you tested. Production covers the 200 weird things real users actually do.
When you edit prompts from gut feeling, you optimize for the last bad example you saw, not the distribution of what's actually breaking. You fix the loud failure (the angry user who emailed you) and ignore the quiet one (the 8% of users who silently abandon during setup). The loud failure is usually rare. The quiet one is usually killing your retention.
Conversation-driven optimization flips this. You let the volume of real failures tell you what to fix first, in order of impact, instead of fixing whatever's freshest in your memory.
Step 1: Collect real failures and friction, not just thumbs-down
Thumbs-up/thumbs-down feedback is a trap. Most users never click it, and the ones who do are a biased sample. You need signal from the conversations themselves.
What to actually capture:
- Hard failures: the agent says it cant do something it should, hallucinates a feature, loops, or hands off to a human unnecessarily.
- Friction: the user has to repeat themselves, rephrase, or correct the agent before it understands.
- Abandonment: the conversation just stops mid-task. No goodbye, no resolution. This is the most underrated signal there is.
- Escalation language: "this isn't what I asked," "no, I meant," "forget it." These phrases are gold.
You don't need fancy tooling to start. Pull a week of transcripts, read 50 of them with coffee, and tag what went wrong. Reading raw conversations is humbling and it's the single highest-leverage thing a founder can do for their agent. Do it before you automate anything.
Step 2: Cluster failures into patterns (intents)
One bad conversation is an anecdote. Forty bad conversations that all fail the same way are a pattern, and patterns are what you fix.
The goal here is to group your tagged failures into a handful of recurring intents. Not "user was confused" (too vague) but specific, named buckets like:
| Pattern | What it looks like | Rough frequency |
|---|---|---|
| Setup friction | User stalls during onboarding, asks the same config question twice | 22% of failed convos |
| Refused valid request | Agent says it can't do X even though it can | 11% |
| Over-apologizing | Agent burns three sentences apologizing instead of acting | 9% |
| Wrong escalation | Hands off to human when it had the answer | 7% |
Now you have a prioritized list. Setup friction at 22% is where you start, not over-apologizing at 9%, even if the apologies annoy you personally.
This clustering step is the part people skip, and it's exactly why their prompt edits feel random. Without it, you're fixing by recency. With it, you're fixing by impact.
Step 3: Translate one pattern into one specific change
Now the actual prompt engineering. The rule: one pattern, one targeted change. Don't rewrite the whole prompt because then you can't tell what worked.
Let's take the "refused valid request" pattern. Say your support agent keeps telling users it can't issue refunds, but it actually can for orders under $50.
Before:
You are a helpful support assistant. Be polite and professional.
If you are unsure whether you can perform an action, tell the
user you'll connect them with a human.
That last line is the culprit. "Unsure" is doing way too much work, so the model defaults to punting.
After:
You are a support assistant for Acme. You CAN issue refunds for
orders under $50 without approval. Do it directly when asked and
confirm the amount. Only escalate to a human for refunds over $50,
disputed charges, or account deletion. When you escalate, say
exactly why.
See what changed? We replaced a vague hedge with explicit capability boundaries and a concrete threshold. The model now knows the line. Same approach works for setup friction (add the exact happy-path steps), over-apologizing (instruct it to act first, apologize at most once), and wrong escalation (define the escalation criteria precisely).
Concrete beats polite every time. "Be helpful" is noise. "Issue refunds under $50 directly" is a decision the model can follow.
Step 4: Test the change before you trust it
Do not ship a prompt change because it looks right. Prompts have side effects. The refund fix might make the agent too eager and start refunding things it shouldn't.
You don't need a heavy setup. A lightweight check:
- Pull 15 to 20 real conversations that triggered the pattern.
- Run the new prompt against those same inputs.
- Eyeball: did it fix the failure without breaking the good cases?
- Keep a small set of "golden" conversations that should always pass, and rerun them on every change to catch regressions.
The point is comparison against real traffic, not synthetic test cases you made up. Your made-up cases reflect your assumptions. Production conversations reflect reality, and reality is what's churning your users.
Step 5: Ship it as a reviewable diff
Treat your system prompt like code, because it is code. It should live in version control, change through pull requests, and carry a description of what failure pattern it fixes and what data backs it.
A good prompt PR description reads like: "Fixes the refused-refund pattern (11% of failed support convos this week). Added explicit refund authority under $50 and tightened escalation criteria. Tested against 18 real transcripts, fixed 16, no regressions on golden set."
That description means the next person (or you, in two months) knows why the line exists. No more archaeology. No more "I think Dave added this, don't touch it."
Tools that improve a system prompt from production conversations
| Tool | Starts from | What it changes | How the change is tested | How it ships |
|---|---|---|---|---|
| Agnost AI | Every production conversation, judged against your plain-language rules | Prompt, tool, or code, in your linked GitHub repo | Replays the affected past conversations; results in the PR | Pull request, a person merges; alert re-checked about an hour after merge |
| Pydantic Logfire prompt optimization | Recent production runs, failures weighted highest | One prompt edit at a time, citing the runs behind it | Optional evals gate promotion | You accept the diff; versions served by label, with canary |
| Arize AX Prompt Learning | Evaluator feedback on a dataset | Prompts in Arize's prompt hub | Evaluators on the dataset | A person promotes a version |
| DSPy GEPA | A training set and a metric with text feedback | Prompts in a DSPy program | Your validation set | You deploy it |
| LangSmith Engine, Selfship | Production traces or conversations | Prompt or code | Engine: trace replay in private beta; Selfship: before/after eval evidence | Pull request |
Facts from each vendor's docs or site, checked November 18, 2026. For the full comparison by loop step, see self-improving AI agents: the tools that do it.
Where Agnost AI fits
Everything above is doable by hand, and you should do it by hand at least once so you understand your own failure modes. But reading transcripts every week and clustering them manually doesn't scale past a certain volume.
Agnost AI runs this loop on your production traffic. It captures conversations over OpenTelemetry or its SDKs (OpenAI Agents SDK, Vercel AI SDK, LangChain and LangGraph, Mastra, Pydantic AI, Google ADK, Agno), groups them by user and session, and judges each one against rules you write in plain language, such as "never tell a customer you can't issue a refund under $50." It also flags frustration, intents, and tool-call errors. When a failure crosses an alert threshold, Auto Improve opens a pull request on your linked GitHub repository with the prompt or code change, tested against past runs: it replays the affected conversations and shows the results in the pull request. You review and merge, exactly like the manual flow. About an hour after merge it re-checks the alert and records improved, unchanged, regressed, or inconclusive.
A quick checklist
Pin this somewhere:
- [ ] Read 50 raw transcripts yourself before automating anything
- [ ] Tag failures by type, not just "good/bad"
- [ ] Cluster into named patterns with frequencies
- [ ] Fix the highest-frequency pattern first, not the freshest one
- [ ] One pattern, one specific prompt change
- [ ] Replace vague hedges ("if unsure") with explicit boundaries
- [ ] Test against real conversations that triggered the pattern
- [ ] Keep a golden set to catch regressions
- [ ] Ship as a PR with a description tied to data
Closing
The teams whose agents keep getting better aren't smarter prompt writers, they just close the loop between what users actually do and what the prompt says. Read your conversations, fix by pattern, ship reviewable diffs.
If you'd rather have that loop run continuously instead of carving out transcript-reading time every week, that's the whole reason Agnost AI exists. Either way, let your real conversations drive the prompt, not your gut.
Frequently asked questions
How can I improve my agent's system prompt using real production conversations?
Find the failing conversations by intent, cluster the failure into one named pattern, write one prompt rule that fixes it, test the change against the past conversations that failed plus a set of healthy ones, and ship it as a reviewed pull request, then check the failure rate after release. Agnost AI runs this loop on production conversations: when an alert fires, Auto Improve opens a pull request with the fix tested against past runs for a human to review. Prompt optimizers such as DSPy's GEPA and Pydantic Logfire propose prompt edits from a metric or from production runs.
Which tools improve a system prompt automatically from production data?
Agnost AI detects failures in production conversations and opens a pull request with a prompt or code fix tested against the affected past conversations. Pydantic Logfire's prompt optimization reads recent production runs and proposes one prompt edit at a time for you to accept. Arize AX Prompt Learning rewrites prompts from evaluator feedback. DSPy's GEPA evolves prompts against a training set and a metric you supply. LangSmith Engine and Selfship also open pull requests from production failures.
How often should I update my system prompt?
Tie it to data, not the calendar. If a new failure pattern crosses a meaningful share of your conversations, fix it now. If nothing is breaking, leave the prompt alone. Constant tweaking with no signal behind it is how prompts rot. Teams with real traffic usually find something worth fixing every week or two.
Should I rewrite the whole prompt or make small changes?
Small, targeted changes, almost always. One pattern, one diff. Big rewrites make it impossible to tell what helped, and they reintroduce bugs you already fixed. Rebuild from your documented patterns only when the prompt has become a long list of conflicting instructions.
How do I know a prompt change actually worked?
Replay the conversations that showed the failure against the new prompt before you merge, and keep a golden set of healthy conversations to catch regressions. After release, compare the failure rate for that pattern on new traffic. If you can't measure it against real traffic, you're guessing.
Originally published on agnost.ai.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.