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
- Anthropic
- Vercel AI SDK
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.
- Anthropic
- Vercel AI SDK
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/andlegacy/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.”
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
| Option | Default | Description |
|---|---|---|
model | (required) | Vercel AI SDK model instance, or model string for Anthropic |
client | (Anthropic only) | Anthropic SDK client instance |
repoRoot | (required) | Root directory of the repository to search |
thoroughness | 'medium' | 'quick' (1-2 searches), 'medium' (2-4), 'thorough' (4-8) |
maxTurns | (auto) | Override the max model turns (defaults based on thoroughness) |
timeout | (none) | Timeout in ms for the entire exploration |
replyTimeout | 30000 | Timeout in ms for waiting for host reply to send_message |
excludes | (WarpGrep defaults) | Glob patterns to exclude from search |
includes | (all files) | Glob patterns to include in search |
Result Shape
contexts contains:
Direct Import
You can also import the subagent creators directly withoutMorphClient:
- Anthropic
- Vercel AI SDK