Context Drift in AI Agents: A Practical Governance Guide
This article explains context drift in AI agents, where conflicting rule files across a repository cause models to confidently pick one source without disclosing the conflict. It distinguishes context drift from context rot, outlines four common causes, and explains why passing tests fail to catch it. The article then presents a governance approach that treats rules as managed code: single source of truth, explicit layering and priority, commit-time conflict detection, metadata and deprecation, mandatory source declaration, and narrowed context assembly, followed by a practical rollout checklist.
1. An Overlooked Acceptance Blind Spot
Picture this: one refund policy document says 14 days, another says 30. You ask a coding agent or a customer support agent to answer a customer based on the project documentation. It quickly returns a number, with a confident tone and clean formatting. As the reviewer, can you tell from that single sentence whether the model also read the other answer?
You cannot. This is the most easily missed class of defect in agent engineering today: the output looks completely normal, all tests are green, but the model’s underlying sources of truth have already diverged. It is not lying. It simply picked one document from a pile of equally “authoritative” materials.
A developer relations practitioner ran a small experiment on a personal blog. In matching tasks where the task instructions conflicted with the project-wide rules, two mainstream coding agents followed the task instructions 95% to 100% of the time. Across 110 runs that did not ask the model to report conflicts, it proactively mentioned the discrepancy to the user zero times. The significance of these numbers is not the specific percentages. It is the structural fact they reveal: the model’s choice and the model’s disclosure are two separate things. The former is highly stable; the latter almost never happens.
These findings are limited to specific model versions and a specific task set, so they should not be generalized unconditionally. But the engineering problem they point to is universal.
2. Context Rot vs. Context Drift: Same Name, Different Problem
Engineers who spend long sessions building with agents tend to develop a reflex: when the conversation gets long, start over. The history is full of long-abandoned approaches, yet the model keeps picking them up again. Compressing history, clearing noise, and starting fresh all address the same issue: context rot, where an overly long single session accumulates noise that degrades output quality. Its timeline is “within a single conversation.”
This article is about a different phenomenon: context drift. The rule file in the project root has changed the refund window to 14 days. A skill instruction file under a task directory still says 30 days. The docs directory still holds a version from three months ago. Skill files are the operating instructions an agent loads when it receives a specific task. Even if you open a brand-new blank session, these materials will still produce different answers.
The key differences can be placed side by side:
- When it appears: Rot shows up in the later part of a long session; drift can trigger in the very first turn of a new session.
- Source of noise: Rot comes from accumulated history messages; drift comes from multiple documents in the project falling out of sync.
- User perception: Rot looks like off-track answers and repeated, unproductive attempts; drift looks like fluent, confident answers that give only one version.
- Where to start debugging: Rot is handled by clearing history and restating the task; drift requires locating the conflicting source text and checking which one is still valid.
Conflating the two leads to a common misdiagnosis: a team keeps reopening sessions and tuning prompts but can never eliminate the contradictory answers, because the problem is not in the session at all. It is in the repository.
3. How Drift Happens: Nobody Makes a Big Mistake
Creating drift does not require a serious operational error. One team updates the onboarding instructions while another team keeps its own maintained copy. A new hire joins, finds only one of them in the task directory, follows it, and delivers normally. Months later, the model faces two documents written with equal confidence, encountering exactly the information gap that a human handoff left behind.
From an engineering perspective, the causes of drift fall into four categories:
- Copy-based proliferation. Rules are copied into multiple subdirectories for “convenient local access,” then evolve independently.
- Missing ownership. With no clear single maintainer, updates only cover the copy the author has on hand.
- No deprecation mechanism. Old documents carry no version marker, effective date, or deprecation notice, making them formally equivalent to current documents.
- Overly broad loading scope. The agent’s context assembly strategy pulls too many directories into the retrieval scope, dragging historical materials along with them.
4. Why Green Tests Miss It
Out of 470 tasks, when do tests still pass? Answer: when the conflict falls outside the coverage of test assertions. The refund window is hardcoded in business logic, and unit tests only verify the calculation. Document-level facts, terminology rules, and edge-case explanations often have no corresponding assertions. So the green light from the pipeline only proves the code runs. It does not prove the basis is correct.
This means drift governance cannot rely on the existing test suite to surface the problem automatically. You need an independent rule-consistency check.
5. The Governance Approach: Treat Rules as Managed Code
5.1 Single Source of Truth
Designate one authoritative file for each class of fact. Every other location may only reference it, never restate it. For example, the root directory maintains global rules, and task-level files record only the differences with an explicit override declaration:
# Global Rules (Single Source of Truth)- Refund window: 14 days# Task-Level Override (Narrowing only, no widening)- This task does not change the refund policy
5.2 Explicit Layering and Priority
Define the load order and conflict resolution rules clearly: global rules < domain rules < task rules, and lower layers may only narrow, never widen. Make priority a contract written into the files, not something the model guesses on the spot.
5.3 Move Conflict Detection to Commit Time
Add a lightweight check to continuous integration that scans key fields in rule files and fails if the same field has multiple values:
# Example: extract a key field and check value uniquenessrg -n "Refund window" --glob "*.md" | awk -F: '{print $3}' | sort -u | wc -l# Output greater than 1 means drift; block the merge
5.4 Metadata and Deprecation
Add an effective date, maintainer, and status marker (active/deprecated) to every rule file. Move deprecated files into a separate archive directory so they fall outside the default retrieval scope.
5.5 Require the Agent to Declare Its Sources
In the system prompt, require that when multiple sources give different conclusions, the agent must list the conflicting source locations and stop, waiting for confirmation. Turning “silent selection” into “explicit questioning” is the lowest-cost way to convert invisible risk into auditable events.
5.6 Narrow the Context Assembly Scope
Authorize readable paths precisely by task directory, avoiding full-repository scans. If you use a cloud-hosted solution, you can use per-prefix authorization on object storage, log services to retain the agent’s read records, and monitoring alerts to notify on failed conflict checks, forming a closed loop.
6. Rollout Checklist
- Inventory all rule and skill instruction files, marking the maintainer and status of each.
- Choose a single source of truth and convert everything else to references.
- Add field-level uniqueness checks to the pipeline.
- Add the conflict declaration requirement to the system prompt.
- Bring rule files into code review and treat them the same as code.
The essence of context drift is version control failure for knowledge assets. The agent will not discover it for us. It will simply give an answer in the same confident tone, one whose source we cannot trace. The governance cost is far lower than the cost of investigating after the fact, so it is worth starting early.
