Agent Harness establishes that observability is non-negotiable while a session is running — the user is supervising a probabilistic, model-driven control flow and needs the steering wheel visible. This page is about observability after a session ends: what the harness must persist so a session is debuggable, shareable, replayable, and intelligible to a future reader (often a future-you) who wasn’t there when it ran.

The thread runs through every other harness page: Streaming in Agent Harnesses (live observability via streams), Context Window Management Strategies (auto-compaction destroys evidence), Tool Design for Agent Harnesses (intent legibility in the trace), Self-Extending Agents (extensions are observable because they are files). This page is the post-hoc completion of that thread.

The Concrete Scenario

You finish a 2-hour Pi session. During those two hours:

  • The agent made ~30 tool calls
  • It edited 15 files
  • It went down 4 dead-end side quests before finding the right approach
  • One sub-task was branched off via /tree and returned a summary
  • Total cost: $4.20
  • The result: a tricky bug, fixed correctly

Two days later you want to understand what happened. Maybe you’re reviewing the work, recreating the approach for another problem, debugging a regression in production, or sharing what worked with a colleague who doesn’t have Pi installed. What does the harness owe you?

The Eleven Needs

#NeedWhat it answersPi’s support
1Full transcript (text + tool calls + tool results)What was said, asked, returnedYes — sessions on disk, verbatim
2Reasoning / belief layer (assistant text)What did the agent see and concludeYes — part of transcript
3Cross-session searchHave I solved something like this beforePartial — grep works; no built-in indexer
4Export to portable formats (JSON / HTML / markdown)Can I share this without the harnessYes — --export
5Tree structure with timestampsWhat was the shape of the work; where were the dead endsYes — /tree
6Cumulative repo diff + agent-vs-human attributionWhat changed in my codebase; who made each changePartial — /files extension; attribution is gappy
7Resume / Replay / Fork (three distinct ops, see below)How do I continue, re-run, or branch from a past pointYes — --resume, --continue, --fork
8Cost / token timelineWhere did the spend concentrateLive yes; post-hoc weaker
9Inside-branch / inside-sub-agent visibilityWhat happened in the parts only summaries surfacedYes for branches; sub-agent depends on extension
10System prompt + context-as-it-was (CLAUDE.md snapshot, model id, temp)Under what rules was the agent operatingYes — captured in session payload
11Tagging / annotationMark this turn as “wrong path” / “this worked”No — gap in most harnesses

Two Distinctions Worth Pinning Down

Action vs belief

A transcript records both:

  • “What did the agent do?” → the tool calls + their results
  • “What did the agent see and conclude?” → the assistant’s text blocks + the tool results that informed it

These answer different questions. Debugging a wrong action is different from debugging a wrong belief. The transcript must preserve both layers; if a harness elides either (e.g. summarizing the assistant’s reasoning, or truncating tool results) you can answer the action question but not the belief question, and vice versa.

Resume vs replay vs fork

Three operations commonly collapsed into the word “replay”:

OperationWhat it doesDeterminismUse case
ResumeContinue from turn N; the next thing is a new prompt from youForward-only; future is non-deterministicPicking up where you left off
ReplayRe-render a past session deterministically from stored responses (no API calls)Exactly reproducible if model responses were storedReviewing, sharing, teaching
Re-executeRe-run from turn N forward by re-calling the modelNon-deterministic; LLMs sample stochasticallyTrying a different approach from a saved checkpoint
ForkBranch from turn N as a new line; original is preservedNew line is non-deterministic; old line frozenExploring alternatives without losing the original

Pi’s --resume is resume. Pi’s session export is replay. Pi’s --fork and /tree are fork. There is no first-class “re-execute from turn N with the same prompt” because, with non-deterministic models, that’s just a fork that happens to start with a duplicate prompt.

The user error worth avoiding: assuming “replay” means “re-execute and get the same result.” With LLMs, only replay-from-stored-responses gives identical output. Re-executing always varies.

What’s Load-Bearing vs What’s Ergonomic

Of the eleven needs, most are conveniences. Two — possibly three — are foundations whose absence silently corrupts every other item on the list.

Load-bearing #1: full transcript, literally full

Without messages, nothing else works. The caveat is that “full” must mean literally full, not “abbreviated for storage.” A harness that truncates large tool results in the persisted session preserves the agent’s response to the tool result but loses the input it was reasoning from. You can no longer reconstruct why it concluded what it concluded. The agent’s behavior becomes inexplicable — not because it was inexplicable at the time, but because the explanation has been silently deleted.

Pi stores tool results verbatim. The discipline matters: a transcript that has been size-optimized post-hoc is a transcript you cannot trust.

Load-bearing #2: context-as-it-was

This is the non-obvious one. If the system prompt + context files (CLAUDE.md, skill descriptions) + model identifier + sampling parameters at session time are not preserved alongside the messages, every other observability feature lies to you in a way you cannot detect.

Concrete failure modes:

  • Edit CLAUDE.md between sessions → past sessions appear to violate today’s rules
  • Tighten a tool description → past tool calls look like misuse
  • Change a project’s preferred file layout → past edits look misplaced
  • Switch the underlying model (Sonnet ↔ Haiku) without recording which ran → behavior looks erratic

In every case the transcript is intact, the tool calls are visible, the costs are tallied, the diffs are clean — and your interpretation of all of them is wrong, because the rules and the model that produced the behavior are not recorded alongside it.

Compare the two failure modes:

Need missingFailure modeDetectable?
#1 Full transcriptObvious gap — “I have no record of what happened”Yes, immediate
#10 Context-as-it-wasPlausible record, wrong interpretationNo, invisible

With #1 missing, you know you’re stuck. With #10 missing, you confidently draw wrong conclusions. The session looks fine. Your understanding of it is corrupted.

This is the same shape as the failures identified across the cluster:

All four are the same pattern: a record that is internally consistent but reasons from premises that no longer exist or were never preserved.

Load-bearing #3 (corollary): the model identifier and sampling config

A subset of #10 that deserves its own callout. Different models behave differently for identical inputs; same model with temperature=0.2 vs temperature=1.0 behaves differently. A session record without these fields makes its behavior unattributable. Pi captures them in the session payload. Many harnesses surface them in the UI but drop them in exports — a gap to check before trusting any exported session.

The Unifying Principle

Key

An observability record is trustworthy only if it captures both the actions and the conditions under which the actions occurred. Actions without context-as-it-was are stories without settings — internally coherent, externally meaningless. The harness must persist not just what the agent did, but the rules and model that shaped what it did.

This generalizes the in-flight observability principle from Agent Harness: “if the model is driving and you can’t see the steering wheel, you’ve lost the loop.” The post-hoc version is: “if you can see the steering wheel but not the road conditions, you’ve lost the loop equally.”

Concretely: a session payload that stores messages but not the system prompt is a steering log without a road map. A session payload that stores tool calls but truncates tool results is a steering log without the terrain the driver was reading. A session payload that omits the model identifier is a steering log without knowing which car was driving.

Implications for Choosing or Building a Harness

Specific things to verify before trusting a harness’s observability:

  1. Are tool results stored verbatim, or summarized at write time? Test with a deliberately large tool result.
  2. Is the system prompt captured per session, or rebuilt at view time? Edit CLAUDE.md and re-open an old session — does it render with the old prompt or the new one?
  3. Is the model identifier in the export? Open the export and search for the model name explicitly.
  4. Are sampling parameters preserved? temperature, top_p, anything else the harness varies.
  5. Are sub-agent and branch transcripts retrievable, not just their summaries? Drill into a /tree branch you “discarded” and check it’s still there.
  6. Does export include cost data per turn, or just a total? A total is hindsight; per-turn is diagnosis.
  7. What is the format of the export? HTML for sharing, JSON for tooling — both should round-trip the same data.

A harness that fails any of these is not unobservant — it is misleadingly observant, which is worse.

What Pi Does Well, and the Two Gaps

Strengths: Sessions stored on disk verbatim; system prompt + CLAUDE.md snapshot per session; tree branching preserved; HTML and raw export; --resume / --continue / --fork distinguished; live cost meter; tool results verbatim.

Gaps:

  • No tagging/annotation. You can’t mark a past turn as “wrong path” or “this worked.” Search across sessions is grep-only — your future self has to re-derive the conclusion you reached today.
  • Cross-session search is unindexed. grep -r ~/.pi/sessions/ works but isn’t ergonomic. A simple FTS index over session payloads would be a high-leverage extension; the kind of thing the agent itself could build (see Self-Extending Agents).

Both gaps are extension-shaped opportunities, not architectural limitations. The minimum-core philosophy of Pi (Coding Agent) is that these belong as user-built skills rather than bundled features.

  • Agent Harness — the in-flight observability principle this page completes for the post-hoc case
  • Pi (Coding Agent) — the reference implementation; session trees, --export, --resume/--fork/--continue
  • Context Window Management Strategies — auto-compaction is the canonical example of post-hoc observability destroyed for capacity reasons
  • Streaming in Agent Harnesses — sub-agent summaries are post-hoc observability destroyed for context-budget reasons
  • Tool Design for Agent Harnesses — intent legibility (write vs edit) is observability built into the tool layer
  • Self-Extending Agents — extensions are observable because they are files; the same principle, applied to capability rather than history
  • Writing Conflict-Free Instructions — CLAUDE.md snapshots are required precisely because the rules in it shape behavior; without the snapshot, rule edits silently rewrite the past
  • Provider Abstraction in Agent Harnesses — cross-provider fork/replay only works because session payloads are canonical; the model identifier is part of “context-as-it-was” for exactly this reason
  • Coding Harness as IDE: live, at-a-glance observability across many sessions (DreamCoder’s minimap: working, blocked, idle), the real-time counterpart to post-hoc replay

Open Questions

  • Could a harness automatically tag turns based on signals (cost spike, tool error, user-issued Esc, branch creation) so that some annotation exists without manual effort?
  • What does cross-session search look like done well — full-text index, embedding search, both? Where should the index live (per-project, global)?
  • For exported sessions shared with others: is there a standard format that captures all eleven needs, or are exports always lossy compared to the on-disk session?
  • Should harnesses checksum or sign sessions to detect post-hoc tampering? In an audit context (security-sensitive code, regulated environments), an unsigned session is just a story.