Agent Experience Loop
Models don't learn between sessions — the system around them has to. Each run produces evidence: how confident each agent's outputs were, what worked, what failed and why. Untracked, that evidence evaporates at session end and every pipeline run starts amnesiac. This skill is the loop that captures it: record per-agent experience as structured data at run completion, load it at session start, and — the step everyone skips — periodically distill it into actual prompt and skill changes.
The hard-won insight behind the design: the JSON file is a buffer, not a knowledge base. Accumulating learnings feels like progress; it is inventory. The leverage arrives only when a recurring learning graduates into a prompt rule, a schema tightening, or a bundle skill — after which the learning is retired from the buffer. A learnings file that only grows is a diary, not a loop.
Use this when
- The same class of mistake recurs across sessions and everyone remembers fixing it before.
- You can't answer "which agent has been trending down this month?" with data.
- A learnings/memory file exists, grows, and has never caused a single prompt change.
- Sessions are orchestrated by different runtimes/people and experience fragments across them.
The loop, precisely
run completes ──> record: per-agent confidence (EMA) + structured learnings
│
session starts <── load: agent bootstraps context with its prior experience
│
periodically ──> distill: recurring categories → prompt/skill changes → retire entries
│
continuously ──> staleness check: a memory nobody writes is decoration (CI)
Four design decisions, each paid for:
- EMA, not average. Confidence is smoothed exponentially (
new = α·observation + (1−α)·old, α≈0.3): recent behavior dominates, ancient history fades, and one outlier can't swing the number. A plain average makes month-old behavior forever equal to yesterday's.
- Structured entries, not prose. Each learning is
{category, insight, outcome}. Categories are what make distillation possible — you can count them; counting free-text is archaeology.
- Capture at completion, not at approval. Real bug from the source system: experience was recorded at the final approval gate, so every agent that ran after it (deploy, analytics, growth) accumulated nothing — invisibly, for weeks. Hook the recorder to the actual end of the run.
- Staleness is an error. If the file hasn't been written in N days of active development, the loop is broken at the capture end — and everything downstream is silently running on stale experience. The check belongs in CI/session start, not in someone's memory.
Run vs read
| Resource |
Action |
Why |
scripts/learnings.py |
RUN |
The loop's mechanics: record (EMA + entry), show, check-staleness (CI-friendly). One JSON file, no dependencies. |
references/loop-design.md |
READ |
The capture-point bug, why EMA, the distillation discipline, retirement rules. |
examples/selftest.sh |
RUN |
Proves EMA math, recording, and staleness detection on a shipped fixture. |
python3 .../learnings.py record --file learnings.json --agent analyst \
--confidence 88 --category schema_drift \
--insight "output enum drifted from registry" --outcome "aligned; added CI check"
python3 .../learnings.py show --file learnings.json [analyst]
python3 .../learnings.py check-staleness --file learnings.json --max-age-days 14
Common pitfalls
- Hoarding. A thousand learnings and zero prompt changes means the distillation step is missing — the loop's entire ROI lives there.
- Recording prose. "Agent did okay-ish, some issues with the schema thing" cannot be counted, so it cannot graduate. Category + insight + outcome, always.
- Capture at the wrong boundary. Anything that runs after your capture point learns nothing; audit which agents actually write entries (the staleness check per agent, not just per file).
- Trusting the memory across structural changes. After a prompt rewrite or model change, an agent's old EMA describes a different agent; re-bootstrap it (the record notes when and why).
- Loading raw learnings into every context. Load the distilled summary per agent, not the archive — context is a budget (see
cost-budgeting).
Verification checklist
Related skills in this bundle
observability-tracing — traces are the raw evidence; learnings are its digested form. Confidence values recorded here often originate in trace meta.
eval-harness — eval scores over time and EMA confidence are two views of the same question ("is this agent getting worse?"); disagreements between them are worth investigating.
prompt-contracts — distillation's most common output is a contract tightening; the loop feeds the contract.
two-layer-critic — review findings are high-grade learning input; wire the critic's structured findings into the same categories.
1---2name: experience-loop3description: Give a multi-agent system persistent experience — per-agent smoothed confidence and structured learnings recorded at run completion, loaded at session start, and periodically distilled into prompt/skill improvements. Use this when every session starts from zero and repeats last month's mistakes, when agent performance data exists only in people's memory, when accumulated "learnings" JSON grows but nothing changes, or when you need to know which agents are trending down.4license: Apache-2.05---67# Agent Experience Loop89Models don't learn between sessions — **the system around them has to**. Each run produces evidence: how confident each agent's outputs were, what worked, what failed and why. Untracked, that evidence evaporates at session end and every pipeline run starts amnesiac. This skill is the loop that captures it: record per-agent experience as structured data at run completion, load it at session start, and — the step everyone skips — periodically distill it into actual prompt and skill changes.1011The hard-won insight behind the design: **the JSON file is a buffer, not a knowledge base.** Accumulating learnings feels like progress; it is inventory. The leverage arrives only when a recurring learning graduates into a prompt rule, a schema tightening, or a bundle skill — after which the learning is *retired* from the buffer. A learnings file that only grows is a diary, not a loop.1213## Use this when1415- The same class of mistake recurs across sessions and everyone remembers fixing it before.16- You can't answer "which agent has been trending down this month?" with data.17- A learnings/memory file exists, grows, and has never caused a single prompt change.18- Sessions are orchestrated by different runtimes/people and experience fragments across them.1920## The loop, precisely2122```23run completes ──> record: per-agent confidence (EMA) + structured learnings24 │25session starts <── load: agent bootstraps context with its prior experience26 │27periodically ──> distill: recurring categories → prompt/skill changes → retire entries28 │29continuously ──> staleness check: a memory nobody writes is decoration (CI)30```3132Four design decisions, each paid for:33341. **EMA, not average.** Confidence is smoothed exponentially (`new = α·observation + (1−α)·old`, α≈0.3): recent behavior dominates, ancient history fades, and one outlier can't swing the number. A plain average makes month-old behavior forever equal to yesterday's.352. **Structured entries, not prose.** Each learning is `{category, insight, outcome}`. Categories are what make distillation possible — you can count them; counting free-text is archaeology.363. **Capture at completion, not at approval.** Real bug from the source system: experience was recorded at the final approval gate, so every agent that ran *after* it (deploy, analytics, growth) accumulated nothing — invisibly, for weeks. Hook the recorder to the actual end of the run.374. **Staleness is an error.** If the file hasn't been written in N days of active development, the loop is broken at the capture end — and everything downstream is silently running on stale experience. The check belongs in CI/session start, not in someone's memory.3839## Run vs read4041| Resource | Action | Why |42|---|---|---|43| `scripts/learnings.py` | **RUN** | The loop's mechanics: `record` (EMA + entry), `show`, `check-staleness` (CI-friendly). One JSON file, no dependencies. |44| `references/loop-design.md` | **READ** | The capture-point bug, why EMA, the distillation discipline, retirement rules. |45| `examples/selftest.sh` | **RUN** | Proves EMA math, recording, and staleness detection on a shipped fixture. |4647```bash48python3 .../learnings.py record --file learnings.json --agent analyst \49 --confidence 88 --category schema_drift \50 --insight "output enum drifted from registry" --outcome "aligned; added CI check"51python3 .../learnings.py show --file learnings.json [analyst]52python3 .../learnings.py check-staleness --file learnings.json --max-age-days 1453```5455## Common pitfalls5657- **Hoarding.** A thousand learnings and zero prompt changes means the distillation step is missing — the loop's entire ROI lives there.58- **Recording prose.** "Agent did okay-ish, some issues with the schema thing" cannot be counted, so it cannot graduate. Category + insight + outcome, always.59- **Capture at the wrong boundary.** Anything that runs after your capture point learns nothing; audit which agents actually write entries (the staleness check per agent, not just per file).60- **Trusting the memory across structural changes.** After a prompt rewrite or model change, an agent's old EMA describes a different agent; re-bootstrap it (the record notes when and why).61- **Loading raw learnings into every context.** Load the distilled summary per agent, not the archive — context is a budget (see `cost-budgeting`).6263## Verification checklist6465- [ ] `sh examples/selftest.sh` passes (EMA math exact, entries recorded, staleness caught).66- [ ] The recorder runs at run completion, and post-approval agents demonstrably accumulate entries.67- [ ] `check-staleness` runs in CI or at session start.68- [ ] At least one prompt/skill change in the repo history traces back to a distilled learning (the loop has closed at least once).69- [ ] Retired learnings are marked, not deleted — the audit trail of *why a prompt changed* is part of the system's provenance.7071## Related skills in this bundle7273- `observability-tracing` — traces are the raw evidence; learnings are its digested form. Confidence values recorded here often originate in trace `meta`.74- `eval-harness` — eval scores over time and EMA confidence are two views of the same question ("is this agent getting worse?"); disagreements between them are worth investigating.75- `prompt-contracts` — distillation's most common output is a contract tightening; the loop feeds the contract.76- `two-layer-critic` — review findings are high-grade learning input; wire the critic's structured findings into the same categories.