Expand description
Mirrors packages/agent/src/harness (AgentHarness: session tree, JSONL
persistence, compaction, the run loop that drives pi-agent).
M5 surface, built up module-by-module. Currently exposes the foundation
layers (error, result, types, session::types); subsequent modules
(session::state, session::reducer, session::jsonl, compaction,
messages, events, skills, agent_harness) are added as M5 progresses.
Modules§
- agent_
harness - Mirrors
packages/agent/src/harness/agent-harness.ts— theAgentHarnessrun loop andAgentLanetrait. - cache_
stats - Prompt-cache waste accounting.
- compaction
- Mirrors
packages/agent/src/harness/compaction— context-window management for long sessions. When token usage approaches the model’s context window, older history is summarized into acompactionSummaryentry; branch tails folded back into a conversation are summarized into abranchSummaryentry. - context_
files - Project context-file discovery. Mirrors
packages/coding-agent/src/core/ resource-loader.ts(loadContextFileFromDir+loadProjectContextFiles). - diagnostics
- Structured resource diagnostics.
- durable
- Session-owned durable control and shared prototype wire codec.
- error
- Mirrors
packages/agent/src/harness/session/types.ts::SessionError. - events
- Mirrors
packages/agent/src/harness/events.ts— the harness event bus,RunStart/RunEndevents, typedonlisteners, and theWatchHandle(snapshot + buffered-until-start + unsubscribe) used by lane/session watches. - frame_
progress - Durable assistant-message progress: record every streamed frame, and salvage what committed if the run dies.
- frontmatter
- Shared YAML-frontmatter parser for the skills and prompt-template loaders.
- messages
- Mirrors
packages/agent/src/harness/messages.ts— the harness’s custom-roleAgentMessageconstructors and the harness-levelconvert_to_llm. - prompt_
templates - Mirrors
packages/agent/src/harness/prompt-templates.ts— markdown template loading + argument substitution + invocation formatting. - result
- Mirrors
packages/agent/src/harness/result.ts(TaggedError/matchError) and theAgentHarnessrejection classes inagent-harness.ts. - run_
budget - Run-level budget for the agent loop.
- runtime
- Durable operation runtime: admission, recovery, reconcile, checkpoint.
- session
sessionsubmodule — mirrorspackages/agent/src/harness/session/*.- settle
- Commit-on-settle: persist a run’s messages when they settle, not at run end.
- skills
- Mirrors
packages/agent/src/harness/skills.ts— YAML-frontmatter skill loading + the TWO SEPARATE skill-formatting paths (invariant §9): - system_
prompt - Mirrors
packages/agent/src/harness/system-prompt.ts— composition of the harness system prompt from a base prompt + the skill listing. - task_
lease - Durable task leases + terminal receipts for externally driven sessions.
- tool_
program_ body - Native primary-entry archival bodies; no observer, replay, repair, or blob sidecar.
- tool_
program_ queries - Bounded, read-only native child inspection. Cursors bind a branch snapshot, not a credential. Native metadata ancestry may grow with history; these are payload/response bounds, not RSS bounds. No execution, repair or source fallback.
- tool_
recovery - Text markers for tool results that recovery produced rather than the loop.
- types
- Mirrors
packages/agent/src/harness/types.ts(harness-level surface only). - watcher
- Live event watching for the harness surface.