Skip to main content
Subagents are autonomous agents that run in their own context window. The Explore subagent searches your codebase using WarpGrep, decides what to search next based on results, and returns a structured summary. Your main agent’s context stays clean.

Why?

Codebase exploration is context-heavy. A single WarpGrep call returns relevant code, but understanding how a system works often takes 3-8 searches. The Explore subagent handles this loop autonomously on a cheap/fast model (Haiku), then returns only the summary to your primary agent. The subagent also supports pause-and-ask messaging: if it hits a fork in the road (“Found JWT and OAuth auth. Which should I focus on?”), it can ask your app and wait for a reply before continuing.

Quick Start

Three Ways to Use

1. As a Tool in a Parent Agent

The subagent exposes a .tool property you can pass to any agent. The parent model calls it like any other tool, and the subagent runs its full search loop internally.

2. Direct Run with Messaging

Call .run() to start an exploration and listen for events. The subagent can pause and ask questions via send_message, and your app replies.

3. Streaming

Use .stream() to get events as an async generator.

Messaging Protocol

The subagent has two internal tools: codebase_search (WarpGrep) and send_message. The system prompt instructs it to use send_message when it:
  • Hits a fork: “Found auth in both src/middleware/ and legacy/auth/. Should I focus on one or cover both?”
  • Needs clarification: “There are 3 auth strategies (JWT, session, OAuth). Which one?”
  • Has a key finding to share before continuing: “The main handler is in src/auth/index.ts. Continuing to trace the JWT flow.”
When send_message is called, the tool blocks until your app replies (or a timeout fires). The reply is injected back as the tool result, and the subagent continues with that context.

Configuration

Result Shape

Each context in contexts contains:

Direct Import

You can also import the subagent creators directly without MorphClient: