Making the session-analyst agent reliable by removing its ability to break things
An agent that helps users diagnose and repair broken Amplifier sessions โ orphaned tool calls, ordering violations, incomplete turns.
A fast, cheap model with detailed manual JSONL editing instructions loaded into its context. Two paths available: a Python script or hand-editing files.
The agent frequently chose to hand-edit transcript.jsonl instead of using the repair script โ making broken sessions more broken, not less.
A Python repair script. Correct, deterministic, tested. But described briefly in the agent's context.
Detailed step-by-step JSONL editing procedures with exact JSON templates, bash commands, and worked examples. More detail = more likely to be used.
"A Haiku-class agent will attempt whatever its loaded context makes possible. The manual path had more detail, so it naturally preferred it."
Removed all manual repair procedures from the agent's context. Explicit prohibition on hand-editing JSONL files. No fallback path.
Reorganized session/ into a clean three-layer architecture. Consolidated duplicate code, replaced hardcoded strings with constants.
Created amplifier-session.py with subcommands: diagnose, repair, rewind, info, find. One script, one command per operation.
All manual repair/rewind procedures with JSON templates and bash commands. Session-repair-knowledge.md went from 231 to 106 lines.
Explicit prohibition: "NEVER attempt to manually edit transcript.jsonl or events.jsonl." If the script fails, the agent stops and reports the error. No manual fallback.
"By removing the manual path entirely and making the script path the only one with executable detail, we align the agent's available actions with the desired behavior. There's literally nothing left for it to attempt manually."
messages.py ยท diagnosis.py โ Slicing, orphan detection, repair algorithms. No I/O, fully testable.
store.py ยท events.py โ Read/write transcripts, metadata, events. 14+ hardcoded filename strings replaced with constants.
finder.py (NEW) โ Resolve partial IDs, search by project/date/keyword/status. Sorted most-recent-first.
Design the agent's environment so the right action is the only action available.
4 expert agents consulted: foundation-expert, amplifier-expert, zen-architect, core-expert. They confirmed session storage belongs in foundation.
Brainstorm mode produced a design with 8 validated sections. Three-phase execution plan: core restructure โ new capabilities โ agent rewire.
Subagent-driven-development recipe: fresh agent per task with spec review + quality review. 4 independent reviewers confirmed zero breaking changes.
Data as of: March 18, 2026
Feature status: Merged & Active (PR #131 merged into main)
Repository: microsoft/amplifier-foundation
Research performed:
gh pr view 131 --json title,body,additions,deletions,changedFiles,commits,...gh pr view 131 --json commits --jq '[.commits[].authoredDate] | sort' โ first: 2026-03-18T21:29:41Z, last: 2026-03-19T02:23:47Zgh pr view 131 --json commits --jq '[.commits[].authors[].login]' โ bkrabach: 32 commits, microsoft-amplifier: 1 co-authorgh pr view 131 --json files โ 28 files, 12 test filesGaps & notes:
Primary contributor: Brian Krabach (bkrabach) โ 100% of commits (32/32)
Session repair is now deterministic. The agent can't break what it can't touch.
View PR #131 โ