Intent Drift

What is intent drift?

Intent drift is the gradual divergence between what you originally asked an AI coding agent to do and what its current plan and edits are actually doing.

It is not a crash, a hallucination, or a bad edit. Every step a drifting agent takes is locally reasonable - that is exactly why it is hard to notice. The plan shifts once, then again, and each individual justification is sound. What is lost is the thread back to the original goal.

The practical result: you asked for a change to one behaviour and end up with a change to another, plus tests that prove the new behaviour works. The diff looks confident and clean. Nothing in the output says the goal changed.

A concrete example

You start a session with one goal: reduce the application's memory usage, staying under 100MB.

Three steps in, the agent is profiling startup time and optimizing an initialization sequence. Nothing broke. But the goal was memory, not startup latency, and the constraint - stay under 100MB - was never checked against the work.

from intent_alignment import IntentAlignmentEngine

engine = IntentAlignmentEngine()

report = engine.evaluate({
    "original_goal": {
        "text": "Reduce the application's memory usage.",
        "constraints": ["Stay under 100MB RAM"],
        "success_criteria": ["Peak memory < 50MB"],
    },
    "current_plan": {
        "summary": "Optimizing startup initialization for faster load.",
        "steps": ["Profile initialization", "Optimize startup sequence"],
    },
})

print(report.overall_alignment)   # e.g. 46.7
print(report.status)              # e.g. "Major_Drift"
print(report.recommendation)      # pause and confirm the new plan is authorized

How it differs from nearby ideas

vs. concept drift (machine learning)

Concept drift is statistical: a model's inputs change distribution over time, so accuracy decays. It is measurable across a dataset over weeks. Intent drift is conversational and local - it happens inside one session, between a stated goal and the next few actions, with no retraining involved.

vs. scope creep

Scope creep usually means the work got bigger while the goal stayed the same. Intent drift is the reverse emphasis: the work may stay the same size while the goal quietly changes. You can drift without adding a single task.

vs. hallucination

Hallucination is a truth failure. Intent drift is an alignment failure: the output can be entirely correct code that solves a problem you did not ask to solve.

Why it happens

  • Recency dominates. The most recent plan and the most recently touched files carry the most weight, including for the model. The original goal is present in the conversation but no longer the loudest signal.
  • Local reasoning is rewarded. Agents optimize the step in front of them. A detour to fix adjacent code is a good decision locally and a drift decision globally.
  • Nothing checks the goal. Tests verify behaviour, linters verify style, CI verifies the build. None of them compare the work against the goal you started with, so drift has no gate to fail.
  • The goal lives in chat. It exists in a scrollback that nobody - human or agent - rereads before the next edit.

How to detect it

Drift is a comparison, so detection needs both sides written down: the original goal, and the current plan and execution. Then it is a scoring problem - which is what this project implements.

Intent Drift runs nine evidence providers over that context - goal alignment, constraints, scope, architecture, execution, file graph, dependencies, requirement coverage, and problematic findings - and returns a transparent alignment score, a drift level, and a recommendation rather than a black-box number. Matching is token and alias based, so every score traces back to specific input text.

pip install intent-drift
intent-drift \
  --original-goal "Reduce memory usage" \
  --current-plan "Improve startup"

Common questions

Is intent drift the same as hallucination?

No. Hallucination is about factual truth - a model asserting something false. Intent drift assumes the output is factually fine; the problem is that it no longer serves the goal it was started for.

Is it the same as context rot?

Related but distinct. Context rot is a property of the model's prompt: earlier details lose influence as the window fills. Intent drift is the observable outcome - the work diverges from the goal - which context rot is one of many causes of.

Doesn't a bigger context window fix this?

No. A window can hold the goal without weighting it. The failure isn't that the goal is missing from the prompt; it's that the accumulating plan and its recent files outweigh it, and every step looks locally reasonable.