Search

Sign in to launch Copilot/Codex from the palette.

COMPACTION

We ran the experiment we had been looking for. In these runs, goals survived more often than conventions, while prior reasoning did not survive compaction.

Experiment 2026.02.23

In Context Cues I collected the anecdotal evidence: DoltHub said Claude gets "definitely dumber" after compaction. GitHub issues reported conventions violated 100% of the time. Jason Liu proposed experiments, but I couldn't find published results for them.

So I ran them. 75 API calls across 5 conditions and 5 knowledge categories, scored by an automated judge. The results are more mixed than the complaints suggest..and more damning in the places that matter.

In this setup, goal and file recall stayed intact across all five conditions. The probe for prior reasoning scored only partial credit, including with full context.

The Experiment

We scripted a 20-message Effect-TS coding session. The agent builds Clock and Logger services, writes tests, and makes architectural decisions. Along the way, the user establishes conventions, corrects mistakes, and discusses trade-offs.

Then we simulate compaction by controlling what context the model sees at probe time. Five conditions:

Full Context

Complete conversation. No compaction. The control.

MODEL SUMMARY (500w)

GPT-4.1-mini summarizes the session in 500 words.

MODEL SUMMARY (200w)

Same summarizer, 200-word budget.

Bullet Extract

Deterministic extraction. Our code, no LLM. Structured bullets: goal, files, conventions, corrections.

Claude.md

Static project rules file. Simulates externalized memory..a fresh session with only the rules file.

Five probes, one per knowledge category. Each asks the model to demonstrate retention of a specific type of information. Three runs per condition at temperature 0.2 for variance measurement. GPT-4.1 for probes, GPT-4.1-mini as automated judge.

Scoring: 0 = lost, 1 = partial, 2 = retained. Each probe has a specific rubric. Zero ambiguous scores across all 75 runs.

The Results

Color scale: retained (1.8–2.0)   partial (1.2–1.7)   degraded (0.5–1.1)   lost (<0.5)

ConditionGoal RecaFile AwarCorr ReteConv AdheReas TrajAvg
Full Context2.02.02.01.31.01.67
Summary (500w)2.02.02.02.01.01.80
Summary (200w)2.02.02.01.01.01.60
Bullet Extract2.02.02.00.71.01.53
CLAUDE.md2.02.01.31.01.01.47
Probe Avg2.002.001.871.201.00

The columns differed more than the overall row averages. In this task, goals and files were easier to recover than conventions or prior reasoning.

Goals and Files: Retained in These Runs

Goal recall: 2.0/2.0 across every condition. File awareness: 2.0/2.0 across every condition. No variance. No exceptions.

Even the 200-word summary retained "we're building Clock and Logger services in Effect-TS." The CLAUDE.md condition also received full credit for goal recall. The goal was repeated and prominent in the synthetic session, which likely made it easier to recover.

This does not show that goals survive compaction generally. It shows that this repeated goal survived the five representations tested here.

Reasoning Trajectory: Partial in Every Condition

1.0/2.0 across every single condition. Including full context.

The full-context condition also scored partial on the reasoning probe. The response recovered the preferred entry-point composition but not the full sequence: "we tried inline provision, it got messy, we switched."

What the probe recovered

This probe suggests the reasoning sequence was harder to retrieve than the final decision. The experiment does not establish whether that came from compaction, retrieval, the probe, or the judge.

The result is consistent with reports that a session can retain decisions while losing the path to them. More tasks, models, and human grading would be needed before treating that as a general property.

Conventions: The Variable Middle

Convention adherence is where the conditions actually diverge. The probe asks the model to write new code following three mid-session conventions: Effect.fn, @scope/Name tags, Effect.logInfo.

Full context: 1.33 .. follows some, misses others

Summary 500w: 2.00 .. perfect. summarizer explicitly listed them

Summary 200w: 1.00 .. partial. word budget too tight

Bullet extract: 0.67 .. degraded. bullets too terse

CLAUDE.md: 1.00 .. partial. rules present but no usage examples

In these three runs, the 500-word model summary scored 2.00 while full context scored 1.33 on convention adherence. The summarizer distilled the conventions into explicit, prominent statements. In the full conversation, conventions are buried in back-and-forth..corrections mid-message, asides, code blocks.

This result is consistent with the "Lost in the Middle" work: the conventions were buried in a 20-message conversation and explicit in the summary. In these runs, moving them to a prominent position improved the convention score.

Corrections: Mostly Safe

Correction retention averaged 1.87/2.0 across conditions. The probe asks the model to create a new Layer..does it use Layer.effect (corrected) or Layer.sync (original mistake)?

Most conditions scored 2.0. The exception: CLAUDE.md dropped to 1.33. One of three runs reverted to the uncorrected pattern. The rules file said "use Layer.effect" but without the conversational context of why that correction was made, the directive was weaker.

Corrections are more resilient than conventions because they're binary. The model either uses the corrected form or doesn't. Conventions require combining multiple behaviors, which is harder to maintain.

The Retention Hierarchy

The average scores in this task formed this order:

RETAINED ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ Goal Recall ......... 2.00

RETAINED ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ File Awareness ...... 2.00

MOSTLY ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░ Correction .......... 1.87

VARIABLE ▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░ Convention .......... 1.20

PARTIAL ▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░ Reasoning ........... 1.00

One possible explanation is salience. Goals and files were repeated and prominent. Corrections asked for a binary choice. Conventions combined several behaviors, while the reasoning probe required reconstructing a sequence across messages.

The harder something is to compress into a single statement, the less likely it survives compaction.

What to Externalize

These scores changed what I put in CLAUDE.md, though the recommendation still needs testing on real repositories.

Put in Claude.md

Conventions and reasoning. These are the categories that degrade. Externalize them with explicit rules and examples. "Use Effect.fn for named functions" is partial. "Use Effect.fn for named functions (see: src/clock.ts getTime)" is retained.

What I Stopped Externalizing

Goals and file lists. These received full credit in all five conditions here. I would still verify that result on a real session before removing them from a rules file.

Re-State in Session

Reasoning chains. None of the five conditions recovered the full sequence in this probe. For decisions where the reason matters, I now restate it or link to the artifact that records it.

Compaction Insurance

If you run agents in loops..autonomous sessions that restart periodically..every restart is a compaction event. The context resets. The loop starts fresh.

CLAUDE.md files, AGENTS.md files, and health checks carry conventions and corrections across session boundaries because each new session reads them again.

Our data shows why this works: the CLAUDE.md condition scored 1.47 overall, losing to model summaries (1.80) in a single-session test. But that's the wrong comparison. A CLAUDE.md persists across unlimited sessions. A model summary exists for one compaction event and is gone.

The Loop Insight

In a loop architecture, the agent reads the rules file at session start, works until context fills, then restarts. The next session reads the file again, so conventions return to the front of the context instead of remaining buried in an old conversation.

CLAUDE.md scored below the model summaries in this single-session test, but it tests a different property: the file remains available when the session and its summary are gone.

Limitations

This is one experiment with one model (GPT-4.1), one task scenario (Effect-TS services), and 75 data points. The retention hierarchy is consistent across conditions, which builds confidence, but:

  • We tested simulated compaction (controlled context), not real compaction (model-internal). Real compaction implementations vary by provider and are opaque.
  • Three runs per cell is enough to spot patterns, not enough for statistical significance. The zero-variance cells (goal, files, reasoning) are more trustworthy than the variable ones (conventions).
  • The automated judge used GPT-4.1-mini with specific rubrics. Zero ambiguous scores suggests clean rubrics, but could also indicate rubrics that are too easy to satisfy.
  • Effect-TS has distinctive syntax. Convention adherence results may differ for less syntactically unique frameworks.

The experiment ran for under $5 in API costs. It could be replicated across models and scenarios for stronger claims. The harness is open source.

The Numbers

Primary hypothesis confirmed: compaction preserves goals but destroys conventions and reasoning. Not "sometimes" or "partially"..with remarkable consistency across all conditions.

Secondary hypothesis confirmed: retention is categorical. Goals (2.0) and reasoning (1.0) don't overlap. The hierarchy is stable.

Null hypothesis rejected: compaction is not lossless. But the loss is predictable, and that predictability is useful.

I externalize what degrades. Re-state what nothing preserves. No point wasting tokens on what survives everything.

Related

  • Context Cues .. The research review that motivated this experiment.
  • Loop .. Autonomous agent sessions with gates and health checks.
  • Effect-First .. How curated references beat raw documentation for Effect-TS.