Skip to content

microharness (v0.4.1 · Beta)

A minimalist, zero-dependency, and pluggable AI agent microframework in Python.

PyPI version Status: Beta Python 3.11+ License: MIT

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, ACP stdio, 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.Protocol interfaces—no inheritance required.
  • Declarative Defaults: Operational thresholds, timeouts, retry counts, and provider profiles live in core/defaults.json and core/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 pip or uv, 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, @file tagging, session resumption, and Ctrl+C vs Esc cancellation.
  • Subagents — Built-in explore, reviewer, and worker presets, custom .md subagents, 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 stdio backend (microharness acp) for editors and orchestrators.
  • Architecture & Internals — Sandboxing, memory compaction, prompt caching, lifecycle hooks, and checkpoints.
  • Python API & Pluggability — Extending Harness with custom Model, Tool, ToolProvider, Evaluator, and HookProtocol components.
  • Benchmarks & Experiments — Mini-SWE sanity suite, DeepSWE-mini / Harbor Docker evaluation, and CSV experiment tracking.