Hand Side Work to a Subagent

Your festival repository now has a browser your agent can use and a server setup you’ve trimmed to what each task needs. Waiting in docs/issues.md are four open issues. Before you take on two of them at once, you’ll take a smaller step and get a second agent to do a piece of work for your main session.

In this lesson, you’ll hand the work of proposing a fix for issue #1 to a subagent, write the hand-off so it carries the decision the work depends on, and check what comes back. You’ll also be able to say when side work is worth handing off and when it should stay in your session.

See What a Subagent Starts With

A long session collects everything it touches. Every file the agent reads, every search result, and every test log takes up room in its context until the history gets compacted, and the job you care about gets crowded out by details you needed only once.

A subagent is a second agent that your main agent starts for one side task. It works in its own context, reads and runs what the task needs, and then sends back a summary. Only that summary enters your main session, so the file reads and logs stay out of it. Typical side tasks are searching the codebase, researching a library, reviewing a diff, or proposing a change from a few files.

Handing off a task is a bit like sending someone on an errand with a note. The comparison stops there, though. Unlike a person on an errand, a subagent is another run of the same kind of agent, and it has nothing to go on except what it’s given.

A typical subagent starts from a fresh context, the way a new session does. It gets the hand-off message your main agent writes for it, plus whatever its own setup loads. For most subagents, though not all, that includes the project’s instruction file. Some agents can also fork a subagent that starts with a copy of your conversation, but this lesson asks for the fresh kind.

Subagents also draw on the same usage limits as your session. Handing work off moves it out of your context, but it doesn’t make it free.

Hand Issue #1 to a Subagent

Issue #1 says that search misses an item when the capitalization differs: a visitor types Fiddle, and the volunteer wrote green fiddle case with a ribbon. Fixing it is a contained job that needs only src/search.js and its tests, so it’s a good place to practice a hand-off.

First, check that your main checkout is clean. In the festival folder, run git status. It should report nothing to commit, working tree clean. If it doesn’t, commit or discard what’s left from the last lesson, because the proposal you’re about to get should start from a known state.

Settle the Decision First

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.