Skip to main content

Crate rpi_harness

Crate rpi_harness 

Source
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 — the AgentHarness run loop and AgentLane trait.
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 a compactionSummary entry; branch tails folded back into a conversation are summarized into a branchSummary entry.
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/RunEnd events, typed on listeners, and the WatchHandle (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-role AgentMessage constructors and the harness-level convert_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 the AgentHarness rejection classes in agent-harness.ts.
run_budget
Run-level budget for the agent loop.
runtime
Durable operation runtime: admission, recovery, reconcile, checkpoint.
session
session submodule — mirrors packages/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.