Why AI Coding Agents Need a Memory Pipeline

An episode of the “AI that Works” show where Dex (CEO of HumanLayer) and Aaron (CTO of Boundary/BAML) walk through a pipeline they built together that mines AI coding agent sessions for durable knowledge. The pipeline analyzes agent traces to produce proposed snippets for CLAUDE.md/AGENTS.md, reports on what agents get stuck on, and structured “context shards” — all for about two cents per session by using cheap classifier models for bulk filtering and strong models only where they matter.

Key Points

Detailed Summary

The setup: why memory matters

Agent sessions are hill-climbing: the user gives feedback, the agent fixes things, and either party learns something. But when the session ends, that learning is lost. Some of it is tribal knowledge (“please don’t run that command again”), and some took 500 tool calls to discover — information you’d rather capture as a snippet, diagram, or architecture note than re-derive every session. Related approaches exist (compounding engineering, Matt Biozo’s “retro skill”), but the open question is how to decide what earns a spot in your CLAUDE.md or memory bank, and how to keep it from going stale.

The naive v1

Take user + assistant messages only (drop tool calls for cost), send to Haiku with structured output, get back “context shards”: the memory, reasoning for why it matters, and citations back to session/message/user IDs so feedback could be tracked across a whole org (HumanLayer is multiplayer, so two users hitting the same problem is visible). It worked directionally but required constant prompt fiddling.

Building the real pipeline

Aaron’s process, in order:

  1. Build lots of tooling — about ten dashboard iterations to browse sessions, filter to human messages, and trace what flowed where (including Sankey diagrams of extraction).
  2. Prototype with Claude Code — let a top model roam the data freely and produce the best possible report, then study its behavior to find the reusable patterns (which messages it filtered, what signals it used).
  3. Encode the workflow in BAML — LLM functions with typed inputs/outputs, enum classifications, and float scores that come back as true probabilities.

The final pipeline has three branches, mapped to the three memory classes:

Post-filtering, memories are judged for quality: is it tribal knowledge (not obvious from reading the code — “did it take 10 files to understand this?”), is it readable, is it a duplicate? Then everything is sorted into the rules/facts/research categories and drafts and reports are written.

Iteration discipline

BAML Query

Rather than sprinkling span/trace code through the pipeline, BAML auto-captures spans for LLM functions into a local program database. bamlq gives a CLI/SQL interface over the run’s data, which let Aaron vibe-code custom dashboards on top of the live program — the only API needed is the query layer. The argument: generic observability UIs can’t anticipate what you need to see; give the model keys to the database instead.

Open problems discussed