DEV Community

Abdeljabbar Elassali
Abdeljabbar Elassali

Posted on

Stop Stuffing Your System Prompt: What Belongs in Agent Memory Instead

Stop Stuffing Your System Prompt: What Belongs in Agent Memory Instead

Every scheduled agent has a system prompt that started life as five clean lines and is now a 30,000-token onboarding document. It holds the client list, the pricing exceptions, the tone rules, the "remember that Acme Corp's invoices go to billing@ not accounts@" notes, the escalation policy, and seventeen reminders accumulated over six months of production incidents.

It works, technically. It is also the most expensive way to run a scheduled agent, and it gets more expensive and more brittle with every run.

The system prompt is not memory. Treating it like memory is the default architecture of half the scheduled agents in production, and it is worth understanding exactly what it costs.

The prompt is instructions. Memory is experience.

A system prompt tells the agent who it is and how to behave: its role, its tools, its output format, the guardrails. That content is stable. It changes when you change the automation itself.

Everything else operators paste in there, the client preferences, the learned exceptions, the corrections from last Tuesday's incident, is not instruction. It is experience. It changes because something happened in the world, sometimes between individual runs on the same day. The moment you mix experience into instructions, you get the worst of both: instructions that go stale and experience that cannot be updated without a deploy.

A useful test: if a fact would change because something happened in the world, it does not belong in the system prompt. "Always format reports as markdown tables" is an instruction. "Acme Corp switched to net-45 terms on the 12th" is a memory.

Why this hurts scheduled runs specifically

In a chat session, a bloated prompt is a minor inefficiency. In a scheduled agent, it is a recurring tax, because the entire prompt is re-sent on every single run.

Do the rough math. A 30,000-token system prompt on an agent that fires every 15 minutes is 2.88 million tokens a day before the agent has done anything useful. That is not a rounding error. Operators regularly discover the prompt is the single largest line item in the agent's token bill, and every kilobyte of "just in case" context added during debugging gets billed 96 times a day, forever.

Then there is the accuracy cost. Long-context analysis keeps landing in the same place: models reliably use only about 60 to 70 percent of their advertised context window before accuracy on buried details starts to slip, the pattern researchers call "lost in the middle" (Startup Fortune). A fact sitting at token 12,000 of a 30,000-token prompt is technically present and practically invisible. The more "just in case" knowledge you cram in, the less of it the agent can actually use.

And there is the staleness cost. A system prompt is code. Updating it means editing the workflow, testing, deploying. So nobody does it for small facts. The prompt quietly becomes a museum of how the business worked three months ago, and the agent confidently applies last quarter's rules to this quarter's data.

What belongs in the prompt

Keep the prompt small, stable, and boring:

  • Identity and role: what the agent is for.
  • Tool instructions: which tools exist and when to call them.
  • The memory protocol: where memories live, and when to read and write them.
  • Output format and guardrails: the non-negotiables.

That is the whole list. If you can read the entire prompt in under a minute, it is about the right size.

What belongs in memory

Memory holds everything that changes because the world changed:

  • Per-client facts and preferences.
  • Corrections: "last time this input meant X, it was wrong; it means Y."
  • Accumulated judgments: which data sources are trustworthy, what "urgent" means for each account.
  • Run history: what happened last run, so this run does not repeat it.

The difference is not just storage. Memory is retrieved selectively. A good setup pulls the handful of relevant memories for this run instead of dumping the entire archive into every prompt (The Agent Loop suggests loading three to ten relevant notes at session start). The agent gets what it needs, and the token bill stops scaling with the total amount the agent has ever learned.

The migration is an afternoon's work

Moving from a mega-prompt to prompt-plus-memory does not require rebuilding the agent:

  1. Read the current prompt and highlight everything that is a fact about the world rather than an instruction. That highlighted part is your memory seed.
  2. Give the agent read and write tools for a memory store, and three lines in the system prompt: check memory at the start of a run, save what was learned at the end.
  3. Run it for a week, then delete the highlighted facts from the prompt. If a run ever needs something that is not in memory, that is a retrieval gap to fix, not a reason to stuff it back into the prompt.

You can build the store yourself: a Postgres table, a handful of markdown files, a vector database once retrieval gets hard. At small scale that works fine. The DIY version starts to hurt when the same memory needs to reach agents running in different tools: the n8n workflow, the Make scenario, the Claude Code session where the whole thing gets debugged, the phone app where results get checked. Then the memory lives in four places or nowhere.

That is the gap Vilix AI fills. It is a cloud-hosted memory layer, so there is nothing to deploy or maintain, and every agent reaches the same memory over MCP: scheduled runs, coding assistants, phone apps, all reading and writing one shared store. It keeps full conversation history, not just extracted facts, so an agent can revisit what actually happened instead of a summary of a summary. There is a free plan that stays free, a 7-day Pro trial with no credit card, and your data is portable: export everything or delete it anytime at vilix.ai.

One rule to keep

The system prompt is for who the agent is. Memory is for what the agent has learned. Every time you are tempted to paste a fact into the prompt, ask whether it would survive a code deploy unchanged for six months. If not, it is a memory. Put it in memory, and let your scheduled runs stop paying rent on knowledge they only need once in a while.

Top comments (0)