Expand description
ReAct agent loop with self-correction.
Minimal v0.0.1 implementation:
- Applies guides once at the start.
- Sends
Context(withtools) to the model. - Dispatches each returned tool call via
ToolRegistry. - Runs
Sensor::SelfCorrectsensors after each action; auto-fix patches are applied directly to the world, blocking signals are fed back to the model. - Stops when the model returns no tool calls, when
policy.max_itersis hit, or when a stuck-detector (StuckPolicy,MonotonyPolicy) says the run is spinning.
Re-exports§
pub use acceptance::Acceptance;pub use acceptance::FilesExist;pub use acceptance::NonEmptyAnswer;pub use acceptance::Verdict;pub use goal::Goal;pub use goal::GoalStore;pub use goal::Phase;pub use goal::PhaseStatus;pub use receipt::Receipt;pub use receipt::ReceiptBuilder;pub use seal::SealBreach;pub use seal::SealSet;pub use learning::*;pub use memory_layer::*;pub use boundary_guide::*;pub use profile_guide::*;pub use recall_layer::*;pub use registry::*;pub use replay::*;pub use subagent::*;pub use telemetry::*;
Modules§
- acceptance
- What “done” means, checked before the loop says so.
- blueprint
- Blueprint — deterministic + agent hybrid state machine (Stripe Minions pattern).
- boundary_
guide - Opt-in
Guidefor the requests an agent cannot fulfil. - compactor
- Five-stage progressive compaction (DESIGN.md §9), borrowed from Claude Code.
- daemon
- Optional standalone scheduler for the harness-rs ecosystem.
- experience
- harness-experience — learn from what you did before
- goal
- A goal: the run itself, written down and survivable.
- hooks
HookBus— dispatch the lifecycle events to registeredHooks.- learning
- Self-evolving learning loop for
crate::AgentLoop. - loop_
engine - harness-loop-engine — loop engineering for harness-rs
- memory_
layer - Long-term-memory wiring for
crate::AgentLoop. - meters
- Metrics — what runs cost and how they behave, as numbers a dashboard can aggregate across thousands of runs. Traces answer “what happened in this run”; these answer “what is p95 tool latency this week” and “which model is eating the token budget”, which no amount of per-run spans can.
- orchestrator
- harness-orchestrator — single-machine async Run orchestration
- profile_
guide - Opt-in
Guidethat rendersharness_core::UserProfileinto the agent’s system prompt. - recall_
layer - Cross-session recall wiring for
crate::AgentLoop. - receipt
- What the run can show for itself.
- registry
- A tiny name-keyed tool registry used by
AgentLoop. - replay
- Session record + replay (DESIGN.md §15 v0.2+).
- sandbox
- Sandbox trait + concrete backends.
- scheduler
- In-process agent scheduling + delivery for harness-rs. Optional — nothing else in the framework depends on it.
- seal
- Making the gate unforgeable.
- subagent
- Subagent: an isolated agent loop spawned from a parent.
- telemetry
TelemetryHook— maps the agent’s lifecycleEventstream onto structuredtracingspans and events, so a run becomes observable in anytracingsubscriber.- templates
- Pre-built Blueprint templates per DESIGN.md §15 (v0.1 roadmap).
- timeline
- A recorded run as a self-contained HTML timeline — one file, no server, no
scripts or fonts fetched from anywhere.
harness trace run.jsonl --html out.htmlwrites one;render_htmlis the same thing as a function.
Macros§
- node_
async - Convenience: avoid the
Box::pinboilerplate when the closure doesn’t borroww.
Structs§
- Agent
Loop - The agent loop.
- Cancellation
Token - The token
AgentLoop::with_cancellationtakes, re-exported so a caller can cancel a run without depending ontokio-utildirectly. A token which can be used to signal a cancellation request to one or more tasks. - Compact
Policy - Governs when and how far the loop compacts context. Hysteresis: only
start compacting once usage crosses
high_water, and stop as soon as it’s back undertarget— instead of running every stage above a threshold on every turn. This avoids over-compacting (needlessly reaching the lossy, main-modelAutoCompactstage) and, because compaction rewrites history and invalidates the provider prefix cache, avoids nibbling the context every single turn. - Monotony
Policy - A second stuck signal, orthogonal to
StuckPolicy: the model calls one tool round after round — a different argument every time, so nothing ever repeats — and never moves on to anything else. - Session
- A persistent multi-turn conversation over one
AgentLoop. - Stuck
Policy - Governs the loop’s stuck-detector. When the model repeats the same tool
call (name + args) round after round without making progress, the loop first
nudges it to change approach, then terminates cleanly with
Outcome::Stuckrather than burning the rest of the budget spinning on a loop. - Tool
Result Policy - A ceiling on how much of one tool result reaches the context.
Enums§
- Outcome
- Where a run finished. Each variant is
#[non_exhaustive]so new fields don’t break downstream matches — always include..when destructuring.
Functions§
- apply_
patches - Apply auto-fix patches; return short descriptions of those that succeeded.
- is_
default_ safe_ fix - Audit #7: default safelist for
FixPatch::RunCommand.