danielrosehill's picture
Add missing critical steps to flow with subheading format
364e204

Claude Agent "Picker" Pattern (Claude Code)

A pattern for dynamic multiagent crew assembly

Concept Notes Idea Claude Code

alt text Oct / 31 / 2025

The Problem

Agents have to be used judiciously.

Just like MCP tools.

Too many cooks in the kitchen (and all that).

The actual problem in technical terms: context flooding:

  • The more agents, the more descriptions the orchestration agent (plain Claude) has to parse through to figure out which subagent to delegate a task to.
  • The more MCP tool definitions Claude has to read... the same thing.

alt text

A thought:

If AI tooling progresses faster than context widows grow, this problem can be expected to get more acute and its consequences to be more widely felt.

Once upon a time, LLMs were envisioned as tools for handling (simple) text. Nowadays, our somewhat fantastical ambition has evolved to that LLMs can maintain good inference while simultaneously dealing with:

  • Lots of text (code)
  • Tool definitions (MCP)
  • Agent maps

Etc.

Why Bother With Subagents At All?

Some are strenously against multiagent systems.

But this quote from the Anthropic docs illustrates why it's worth persevering with working with subagents in spite of this limit:

"Each subagent operates in its own context, preventing pollution of the main conversation and keeping it focused on high-level objectives."[^1]

Which is a very big deal when context pollution can flatten out otherwise great inference.

For creating performant agentic systems, using emerging tooling judiciously has become almost as vital an enterprise as knowing what tooling to use.

Thus, a late night idea for a workaround pattern (even if imperfect, flawed, etc):


The Idea

alt text

I call it the agent picker because the first thought I had when writing this was the high school ritual of picking teammates for a game of soccer (was that just my school? It seems awfully callous!).

It offers a hacky workaround because:

  • If you add a whole bunch of system level agents ... you get the problem above
  • If you add them at the project level ... the CLI starts warning about the context problem

At the time of writing, the inner mechanics of agent delegation are opaque.


The Model

Ingredient 1: Agent Farm

alt text

Or more accurately the "subagent farm" but that sounds even odder.

You may go through creative bursts in which you think ... "that would be an amazing subagent." It may have application across multiple Claude workspaces.

This agent may be useful on a personal project and equally helpful on a work project with collaborators. It doesn't matter. What matters is the idea and config behind the agent and how it leverages AI to help achieve a project.

For simplicity, let's sketch the filetree as:

~/subagents

Ingredient 2: The Harsh Team Picker Guy (HTPG) - The Router

alt text

Our next task:

We want an agent whose purpose is to intelligently assemble a multi-agent crew for a workspace.

Note to self (and anyone reading this): this is very unlikely an original idea. But hey, who knows.

Either way, here's my twist on it:

  • Claude Code knows its own context window and the parameters of how much context it can fit in the "other stuff" that goes on top of user prompts (namely, agent definitions and MCP tools).

Downstream, this agent could select both. In this implementation (V1) let's just stick to subagent crew formation.

So Harsh Team Picker Guy (HTPG) is a friendly pre-kickoff agent.

In real world terms, I imagine HTPG as the project lead when you offload some project to an outsourced company. The project lead listens, takes notes, and assigns internal resources to your job. HTPG does thusly.

HTPG has to have some firepower, though. So I envision him working like this, in sequence:

Task 1: Crew shortlisting / selection

  • Evaluate the project spec the user is proposing
  • Draw up a shortlist of subagents to form a "crew" with minimal task overlap and maximal "synergy"

Task 2: Truncate crew to fit context limit (user-set)

  • Calculate the approximate cumulative context window that the desired-for crew would impose
  • If beyond the defined limit, make some substitutions until we can get a crew together that fits within that limit.

alt text Graphic: Selected subagents are truncated for context optimisation before (almost) being dispatched into a repo

Potential "tactics" for substitution:

  • Remove least important subagents
  • Truncate descriptions / shorten system prompts of constituent agents

Task 3: Variable-based agent config adaption

Finally - tweak the (stock) configs: this could be variable substitution to give our cookie cutter subagents a bit of context about the project. But mostly we expect and hope that this will happen through Claude's excellent built-in orchestration.

Task 4 (Wrap): Copy adapted crew to target directory (project workspace)

This completes the flow.


Output: The System (Workspace with Optimized Crew)

Complete Flow Sequence

Step 1: Project Analysis

HTPG evaluates the project specification and requirements that the user is proposing.

Step 2: Intelligent Crew Selection

HTPG draws up a shortlist of subagents from the Agent Farm to form a "crew" with minimal task overlap and maximal synergy for the specific project needs.

Step 3: Context Window Calculation

HTPG calculates the approximate cumulative context window that the desired crew would impose on the system.

Step 4: Context Optimization (The Critical Step!)

If the crew exceeds the user-defined context limit, HTPG makes intelligent substitutions until an optimized crew is assembled that fits within constraints. Tactics include:

  • Removing least important subagents
  • Truncating descriptions or shortening system prompts of constituent agents

Step 5: Crew Staging

Selected and optimized crew gets copied to a temporary directory for processing.

Step 6: Config Adaptation

Crew configs are edited for the task at hand through variable substitution, giving cookie-cutter subagents project-specific context.

Step 7: Deployment to Workspace

Processed crew gets copied into the project directory at ./.claude/agents.

Step 8: Documentation Generation

CLAUDE.md gets created in the workspace containing a brief overview of the assembled crew and their roles.

Step 9: User Confirmation

User receives a success message confirming their repo has been created with an optimized team of subagents that won't overrun context.

The Result

Users can create as many stock agents as they wish, knowing they'll be kept safe in the Agent Farm library and intelligently assembled when needed for future projects.

Reference

For more details on how subagents work in Claude Code, see the Anthropic subagent documentation (captured at time of writing).


[^1]: Quote sourced from Anthropic Claude Code documentation on October 31, 2025.