# Subagents

---

## Subagents in VS Code

**How to invoke:**
<VClicks>
1. Enable tools in Copilot Chat (hammer icon)
2. Call explicitly with `#runSubagent`
3. Or accept when Copilot suggests one
</VClicks>

---

## Use Cases 

<VClicks>
- Specialized searches (explore codebase, web, docs)
- Long-running tasks (data analysis, refactoring)
- TDD workflows (test generation, validation)
- Multi-step processes (research, summarize, act)
</VClicks>
---
## Explore Subagent Flow

<SubagentDiagram
  task="Find auth files"
  files={["Auth.tsx", "auth.ts", "authService.ts"]}
/>

Click **Start** to see how the main agent delegates file search to a specialized Explore subagent.

---

## Parallel Subagent Execution

<ParallelSubagentDiagram
  task="Research Vue 3 reactivity"
  agents={[
    { name: "Web Agent", icon: "🌐", color: "#3b82f6", domain: "Docs, GitHub", findings: ["Official guide", "RFC #123", "GitHub issue"] },
    { name: "Community", icon: "💬", color: "#8b5cf6", domain: "Reddit, SO", findings: ["r/vuejs post", "Top SO answer", "Discord tip"] },
    { name: "Codebase", icon: "📂", color: "#10b981", domain: "Project files", findings: ["useAuth.ts", "store.ts", "api/client.ts"] }
  ]}
/>

Click **Start** to see the fan-out/fan-in pattern where multiple subagents search in parallel.

---

## Subagent in nanocode: Fetch Tool

```shell
nanocode | claude-opus-4-5 | /Users/alexanderopalic/Projects/typescript/nanocode

────────────────────────────────────────────────────────────────────────────────
❯ how does fc bayern played yesterday
────────────────────────────────────────────────────────────────────────────────
[agentLoop] Starting with 1 messages
[agentLoop] Got response, stop_reason: tool_use

⏺ Fetch(https://www.google.com/search?q=fc+bayern+munich+m)
  ⎿  I apologize, but I cannot access real-time sports results or ... +7 lines
[agentLoop] Starting with 3 messages
[agentLoop] Got response, stop_reason: tool_use

⏺ Fetch(https://www.espn.com/soccer/team/_/id/132/bayern-m)
  ⎿  Based on the information in the image, Bayern Munich's most  ... +7 lines
[agentLoop] Starting with 5 messages
[agentLoop] Got response, stop_reason: end_turn

⏺ FC Bayern Munich lost 2-1 to FC Augsburg in the Bundesliga yesterday.
```

The **Fetch tool** uses a subagent to summarize HTML responses before returning.

---