Subagents¶
microharness supports delegating isolated subtasks to child agent loops via the subagent tool (core/subagents.py). Each child starts with a clean Memory (zero parent context bias), scoped tools, and optional model/effort overrides.
Built-in Subagent Presets¶
| Name | Access | Default Tools | Purpose |
|---|---|---|---|
explore |
Read-only | read_file, grep, glob, git_read |
Fast codebase search and discovery |
reviewer |
Read-only | read_file, grep, glob, git_read |
Independent, unbiased code review |
worker |
Read/Write | Inherits workspace tools (excluding recursive subagent and code_mode) |
General-purpose implementation & test execution |
Read-only subagents execute inside ReadOnlyEnvironment, which blocks file writes and mutating operations.
Custom Subagent Files (.microharness/agents/*.md)¶
Define custom subagents as Markdown files with optional YAML frontmatter in:
- Global:
~/.microharness/agents/*.md([global]) - Project:
.microharness/agents/*.md([project], shadows global and built-in presets) - Preset-scoped:
<preset>/subagents/*.md(see Agent Config Presets)
---
name: security-reviewer
description: Audits diffs and auth logic for security flaws
tools: [read_file, grep, glob, git_read]
model: fast
effort: high
max_steps: 10
read_only: true
---
You are a focused security reviewer starting with a clean context.
Inspect changed files, trace authentication and trust boundaries, and report exact file paths and line numbers.
Supported Frontmatter Fields¶
name: Subagent identifier (defaults to filename stem).description: Shown inAvailable Subagentsprompt index and/agent.tools: Comma-separated or YAML list (read,write,editaliases supported).model: Model alias fromconfig.jsonorprovider/modelspec.effort(aliases:reasoning_effort,thinking): Child reasoning effort override.max_steps(alias:max_turns): Step cap for the child loop (when unset, inheritssubagent_max_stepsfrom config,nullby default).read_only: EnforceReadOnlyEnvironmentisolation (true/false).
Parallel Delegation & Isolation¶
- Concurrent Fan-Out: Emitting multiple
subagenttool calls in one turn or passingtasks: [{agent, task, ...}, ...]runs child loops concurrently and aggregates findings. - Safety Boundaries:
- Child subagents do not recursively invoke
subagentorcode_mode(preventing bypass of child tool allowlists). - Read-only subagents (
explore,reviewer,read_only: true) never share mutable write paths with concurrentworkersubagents. - Subagents that reach
max_stepsproduce a structured wrap-up summary of findings/progress so work is not lost. - Each subagent resolves its own model context window independently (
per-subagentcap).
Interactive Usage (/agent)¶
In the interactive CLI or TUI:
/agent # List built-in and discovered subagents
/agent reviewer # Inspect reviewer's tools, model, effort, and max_steps
/agent explore Find all callers of ToolRegistry.dispatch
Tab autocomplete works for /agent names in the TUI, and live child-step action lines stream inline while a subagent executes.
Empirical Guidelines & Cost Trade-Offs¶
Findings from DeepSWE-mini multi-agent sweeps and frontier cost simulations highlight when subagent delegation helps vs. hurts:
- Match model size to role: Small local models (e.g.,
1.7B) handle bounded read-onlyexploresearches cleanly, but spin in long loops when assigned mutatingworkeredits. - Avoid tight
max_stepscaps onexploreandreviewer: Small step caps (15–35) often haltreviewermid-inspection before returning a synthesis. Leavemax_stepsunset or use generous insurance caps (100+). - Cross-model review beats same-model review: A
reviewersharing the implementer's model family tends to share its blind spots, whereas an asymmetric cross-model critic catches subtle edge-case bugs (e.g.,bandit,valibot,koota). Keep in mind that sequential review waits exceeding 5 minutes expire the parent loop's5mKV cache. - When
Main + Explore + Workerspays off: Orchestrating workers for small single-repo bugfixes can burn more parent output tokens planning and reviewing than solving directly—and under frontier pricing ($5/$25or$4/$20per 1M tokens), keeping a full-context frontier parent orchestrating cheaphy4-flashworkers roughly doubles total simulated cost (~$97 -> ~$199across 15DeepSWE-minitasks). Subagent workers pay for themselves when delegation collapses the parent's own context and step count on large multi-module repositories, or when inverting the flow (fast cheap main + frontier review/escalation on unresolved failures, cutting simulated frontier cost by41%–80%).