Why AI Agents Shouldn't Keep Learning Through Bigger Prompts
Imagine an AI agent debugging duplicate webhook deliveries.
It recommends retrying, but the real issue is missing idempotency handling. We fix it by adding another instruction to its system prompt.
Then another failure happens. Another instruction.
Eventually, the prompt contains dozens of rules, each written for a different edge case.
But should every past mistake become a permanent instruction?
The Problem With Growing Prompts
System prompts are useful for stable rules: permissions, tool contracts, and safety boundaries.
But lessons learned from specific failures aren't always universally relevant.
As prompts grow, we introduce unnecessary context, higher token costs, and potentially conflicting instructions.
What if we stored those lessons separately and retrieved them only when needed?
An Architecture I'd Try
I'd separate the system into two loops: learning and execution.
1. Learning loop
After an agent finishes a task:
- Analyze execution traces and outcomes.
- Identify recurring failure patterns.
- Extract candidate lessons.
- Validate them against previous cases before storing them.
For example:
{
"trigger": "duplicate webhook debugging",
"guidance": "Check idempotency before retrying",
"status": "validated"
}
2. Execution loop
When a new task arrives:
- Identify the task context.
- Retrieve a few relevant lessons.
- Inject them into the current execution.
- Keep unrelated lessons out of the prompt.
A webhook-debugging lesson shouldn't appear during an unrelated database migration.
This isn't fine-tuning. It's context-aware guidance retrieval.
The Hard Part Isn't Retrieval
It's deciding which lessons deserve to be trusted.
An agent's failure explanation might itself be wrong.
I'd want every lesson to have supporting evidence, a defined scope, and a way to expire or disable it when circumstances change.
And importantly, safety rules and permissions must remain global, never dependent on retrieval.
How Would We Evaluate It?
I'd compare three approaches:
| Approach | Strategy |
|---|---|
| Static prompt | No accumulated lessons |
| Growing prompt | Append validated lessons globally |
| Contextual guidance | Retrieve relevant lessons per task |
Measure task success, token usage, latency, and regressions on unrelated tasks.
Contextual retrieval could reduce unnecessary context, but it introduces another risk: failing to retrieve the right lesson.
So the improvement needs to be measured, not assumed.
Final Thought
I don't think agents need to remember every mistake.
They need to recognize which past experience matters for the current task.
Maybe improving agents isn't always about writing better prompts.
Sometimes it's about deciding what shouldn't be in the prompt at all.


Top comments (0)