microharness (v0.4.1 · Beta)¶
A minimalist, zero-dependency, and pluggable AI agent microframework in Python.
microharness is built exclusively on Python's standard library (dependencies = [], Python 3.11+) to demonstrate and enforce clean architectural boundaries in agentic systems—while remaining practical for real-world coding workflows, interactive TUI sessions, and containerized SWE benchmarks. See the Changelog for release notes.
Core Mental Model: Loop vs. Harness¶
microharness separates the core reasoning loop from the surrounding runtime chassis:
flowchart LR
U[User / Benchmark Task] --> H[Harness Chassis]
H --> L[Agent Loop]
L <--> M[Model Protocol]
L <--> T[ToolRegistry]
T --> E[Environment / Sandbox / Docker]
T --> MCP[MCP ToolProvider & Code Mode]
T --> SA[Subagent Delegation]
H --> MEM[Memory & 80% Compaction]
H --> HK[Lifecycle Hooks & Checkpoints]
H --> TR[Tracer & Evaluator]
| Component | Responsibility | Module |
|---|---|---|
| Agent Loop (The Engine) | Pure Thought → Action → Observation cycle. Agnostic to benchmarks, sandboxes, and concrete LLM providers. | core/loop.py |
| Harness (The Chassis) | Workspace environment, sandboxing, token budgets, KV-cache-friendly memory compaction, hooks, checkpoints, tracing, and grading. | core/harness.py |
| Interactive Router | Unified slash-command table (/model, /resume, /compact, /agent, ...) shared by the CLI session and full-screen TUI. |
core/interactive.py |
Design Principles¶
- Zero Runtime Dependencies: Core functionality and all built-in transports (HTTP chat completions, SigV4 signing, Docker orchestration, MCP
stdio/HTTP/SSE, ACPstdio, curses TUI) use Python's standard library only. - Protocol-Based Pluggability: Models, capability opt-ins, tools, tool providers, hooks, request signers, and evaluators implement minimal
typing.Protocolinterfaces—no inheritance required. - Declarative Defaults: Operational thresholds, timeouts, retry counts, and provider profiles live in
core/defaults.jsonandcore/providers.json, not scattered inline. - Cascading & Safe Extensibility: Global (
~/.microharness/) and project-local (.microharness/) configs, instructions (AGENTS.md), progressive skills, slash commands, subagents, presets, and tool plugins layer predictably with explicit trust boundaries. - KV-Cache Economics: Memory stays prefix-immutable until the 80% compaction threshold so provider prompt caching maintains high cache hit rates across multi-turn sessions.
Explore the Documentation¶
- Getting Started — Install with
piporuv, configure provider credentials, and run your first interactive or Docker-sandboxed session. - Configuration & Extensibility — Layered JSONC configs,
AGENTS.md, progressive skills, custom slash commands, and Python tool plugins. - Interactive CLI & TUI — Built-in slash commands,
@filetagging, session resumption, andCtrl+CvsEsccancellation. - Subagents — Built-in
explore,reviewer, andworkerpresets, custom.mdsubagents, and parallel delegation. - Agent Config Presets — Self-contained portable agent bundles (
agent.md+ subagents, tools, skills, commands). - MCP & Python Code Mode — Lazy-loaded stdlib MCP client (
stdio, Streamable HTTP,/sse) and loopback Python batching. - Agent Client Protocol (ACP) — Zero-dependency JSON-RPC 2.0
stdiobackend (microharness acp) for editors and orchestrators. - Architecture & Internals — Sandboxing, memory compaction, prompt caching, lifecycle hooks, and checkpoints.
- Python API & Pluggability — Extending
Harnesswith customModel,Tool,ToolProvider,Evaluator, andHookProtocolcomponents. - Benchmarks & Experiments — Mini-SWE sanity suite, DeepSWE-mini / Harbor Docker evaluation, and CSV experiment tracking.