DEV Community

T.M. Gunderson
T.M. Gunderson

Posted on

Your AI Agent Forgets Your Rules After Hour One: The Context-Hygiene Check

You set up an AI agent with clear rules: "Always cc my assistant on external emails," "Never delete files without asking," "Flag invoices over $500 before paying." It follows them perfectly for the first hour. Then it starts drifting. By hour three, it's drafting replies without the cc line and moving files you didn't tell it to touch.

The agent isn't being disobedient. The rules just got buried.

Why agents forget

AI agents process information in a context window — essentially a rolling transcript of everything they've seen and done. Research from Chroma, a vector-database company, tested 18 frontier models and found a consistent pattern: as input length grows, performance degrades on even simple tasks. The assumption that models process context uniformly doesn't hold. Every tool result, every file opened, every intermediate step piles more tokens onto that transcript. Your standing rules — the ones you set at the start — get pushed deeper into the pile until the agent effectively can't see them anymore.

The symptom isn't dramatic failure. It's quieter: a rule that worked at 9 AM stops working at 11 AM. The agent still "knows" the rule in the sense that it learned it, but the rule has been displaced by newer information in the working window.

Four habits that keep the rules visible

1. Put away used results once they're consumed

When an agent reads a file, generates a draft, or checks your calendar, don't let that result sit in the active context forever. Summarize what it found into a compact note, then close the conversation about it. The full tool output — which might be hundreds or thousands of tokens — is the single biggest cause of rule burial. Keep the conclusion; discard the full transcript.

What this looks like: Instead of letting the agent hold ten files in working memory, ask it to summarize each one in two sentences, then move on. The summaries stay. The files don't.

2. Periodically summarize-and-continue instead of scrolling forever

Long-running tasks are where rules decay fastest. Every few turns, tell the agent: "Summarize where we are, then continue." This resets the active context to the current state, pushing the accumulated noise to the background. It's the equivalent of clearing your desk before the next task instead of stacking papers on top of papers.

What this looks like: On a two-hour project, ask for a one-paragraph status check every 30 minutes. The agent restates the goal, the decisions made so far, and the next step — in about 100 tokens instead of 10,000.

3. Keep standing rules in a file outside the chat

Don't rely on the initial prompt to carry your rules for the entire session. Put them in a file the agent can reference. When the rules are external, the agent can re-read them on demand instead of hoping they're still in active memory. Think of it as a shared handbook rather than something you said once at the beginning of a meeting.

What this looks like: A simple text file with five to ten bullet points: escalation rules, format preferences, off-limits actions, approval thresholds. Reference it explicitly when the agent starts a new phase: "Re-read the rules in agent-guidelines.txt before proceeding."

4. Send big subtasks to a fresh agent with clean context

The cleanest way to prevent rule burial is to not let the context grow in the first place. For large, distinct subtasks — writing a report, analyzing a dataset, drafting a batch of emails — spin up a fresh agent instance with just the task description and relevant rules. That agent starts with a blank slate, does the work, and hands the result back. The parent agent never gets clogged with the intermediate steps.

What this looks like: Agent A handles the overall workflow and orchestration. Agent B handles the report draft. Agent C handles the data cleanup. Each one stays within its lane, and none of them accumulate the full mess of the project.

The 60-second spot-check

Here's the simplest way to know if your agent's rules are still active: mid-task, ask it to recite your standing instructions.

"What are the rules I gave you at the start of this session?"

If it answers accurately, your rules are still in active context. If it summarizes them vaguely, misses key points, or asks you to remind it, the rules are buried and the agent is already drifting. This isn't a gotcha — it's a diagnostic. Check once per long session, or whenever the agent's output starts feeling "off."

When to expect this vs. when to worry

Context decay is normal and expected on long or complex tasks. It's not a bug in the agent software; it's a property of how these models process information. What matters is recognizing it and having habits that compensate.

Expected: A two-hour session where the agent gradually needs more explicit reminders. This is just the cost of doing multi-step work with AI.

Worrying: An agent that ignores a critical safety rule after a single short task. That's not context rot — that's either a badly written rule, a misaligned tool integration, or a task the agent shouldn't be doing at all.

Honest boundaries

These habits help, but they don't eliminate the problem. If your workflow involves dozens of sequential tool calls, complex branching logic, or real-time monitoring over many hours, no amount of summarizing fully solves context decay. In those cases, the honest answer is: you need a different architecture — multiple agents with handoffs, a workflow engine with checkpointing, or a more traditional automation tool that doesn't depend on a single model's working memory.

The four habits above are the low-hanging fruit. Most small-business use cases don't need more than this. Start here, check with the spot-test, and only escalate to heavier infrastructure when you've confirmed the problem is real and recurring.


Practical next step: If you're building workflows with AI agents, the biggest time-saver is having a ready-made playbook of automation recipes — the boring, repetitive tasks that actually eat your day. I put together a pack of 50+ verified automation blueprints for small businesses: https://smbscaleup.gumroad.com/l/boring-automation-pack

Top comments (0)