← all posts

Managing Context In Long AI Sessions

February 24, 2026
Managing Context In Long AI Sessions

Long AI sessions degrade in a very specific way: they remain fluent while becoming less grounded.

That makes them dangerous. A later turn can sound more coherent than an earlier turn while being based on weaker facts.

The fix is not just "more context window." The fix is building a habit of externalizing state and forcing re-grounding.

Externalize State

Important state should live outside the chat:

  1. Requirements in a tracked file.
  2. Decisions in a plan or ADR.
  3. Progress in a handoff note.
  4. Results in test output.
  5. Source facts in citations or file references.

This lets a later session recover the work without trusting compressed memory, which is exactly what you should not trust on a long task.

Separate Evidence From Inference

A useful AI handoff should distinguish:

  1. What was directly observed.
  2. What was inferred.
  3. What remains unknown.

Example:

Observed: build fails in PostContent.tsx on image path.
Inference: new post front matter may reference a missing image.
Unknown: whether all posts are affected.

This prevents the most common long-session failure: one convenient guess mutates into a false premise that every later step builds on.

Use Citations In Technical Reasoning

For local code, cite file paths and lines. For documents, cite the source note or section. For command output, summarize the relevant output.

The point is not academic style. The point is traceability under fatigue.

When a session is long, humans also stop remembering where a claim came from. Citations are not only for the model. They are for the operator.

Reset When New Evidence Arrives

If a new log contradicts the current theory, treat the log as current truth. Do not keep patching around an old explanation.

This sounds basic, but it is where many AI-assisted debugging sessions go off the rails. The model is good at continuing. It is not naturally good at discarding a beautiful but wrong explanation.

Avoid Context Stuffing

Dumping the whole repo or entire wiki into context can reduce quality. The model spends attention on irrelevant detail.

Prefer a retrieval loop:

  1. Identify the question.
  2. Search for relevant files.
  3. Read only the needed sections.
  4. Summarize evidence.
  5. Continue.

Good Handoff Format

Goal:
Current state:
Changed files:
Verified:
Known risks:
Next step:

This is simple, but it works. Long AI sessions are reliable only when another worker can resume the task without inheriting the previous session's hidden assumptions.

;