Context engineering
A learning loop for AI coding agents
A retrospective after each change decides where lessons go.
440 tracks Guiding rules cut 13,400 → 2,500 words
The problem
Long agent sessions lose the thread. One session driving a whole feature change fills up with everything it has read and tried, and the goal gets buried: one of my sessions grew from about 50,000 to 450,000 tokens over 324 turns. Lessons pile up, rules start to contradict each other, and instruction files get huge.
What I built
A harness for AI coding agents with two loops.
- Build loop: each stage of a change (design, plan, build, check) runs in a fresh session. A program builds its reading list: the goal, the design, and only the files that stage needs.
- Learning loop: after each change, a retro in its own fresh session proposes where each lesson goes: a program check, a procedure line, or me, if it changes the goals. The retro also merges repeated rules and cuts rules whose reason is gone.
What running it showed
- Sessions stay smaller. In the latest change, each stage started in a fresh session at about 30,000 tokens and peaked between 53,000 and 247,000.
- Scale. 440 tracks ran through three versions of the harness. A track is one feature change, from design to merge, usually ending in a retro.
- Lessons stopped piling up. In the first two versions, retros proposed about 1,000 lessons, all into one handbook that only grew, to about 143,000 words. In the current version, each of 105 lessons went to one place: 36 changed the harness on the spot, and 12 removed text.
- Rules get cut, not just added. One merge cut the project's guiding rules from about 13,400 words to 2,500.
Status
Pre-launch, and running on my own projects. I built it alone under contract with Constellation, for its builder community.