Skip to content

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 in Available Subagents prompt index and /agent.
  • tools: Comma-separated or YAML list (read, write, edit aliases supported).
  • model: Model alias from config.json or provider/model spec.
  • effort (aliases: reasoning_effort, thinking): Child reasoning effort override.
  • max_steps (alias: max_turns): Step cap for the child loop (when unset, inherits subagent_max_steps from config, null by default).
  • read_only: Enforce ReadOnlyEnvironment isolation (true / false).

Parallel Delegation & Isolation

  • Concurrent Fan-Out: Emitting multiple subagent tool calls in one turn or passing tasks: [{agent, task, ...}, ...] runs child loops concurrently and aggregates findings.
  • Safety Boundaries:
  • Child subagents do not recursively invoke subagent or code_mode (preventing bypass of child tool allowlists).
  • Read-only subagents (explore, reviewer, read_only: true) never share mutable write paths with concurrent worker subagents.
  • Subagents that reach max_steps produce a structured wrap-up summary of findings/progress so work is not lost.
  • Each subagent resolves its own model context window independently (per-subagent cap).

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-only explore searches cleanly, but spin in long loops when assigned mutating worker edits.
  • Avoid tight max_steps caps on explore and reviewer: Small step caps (15–35) often halt reviewer mid-inspection before returning a synthesis. Leave max_steps unset or use generous insurance caps (100+).
  • Cross-model review beats same-model review: A reviewer sharing 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's 5m KV cache.
  • When Main + Explore + Workers pays 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/$25 or $4/$20 per 1M tokens), keeping a full-context frontier parent orchestrating cheap hy4-flash workers roughly doubles total simulated cost (~$97 -> ~$199 across 15 DeepSWE-mini tasks). 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 by 41%–80%).