Subagents

Subagents

VSCode Agent Refresher: Agent Mode works by combining your instructions (your prompt) with system prompts that define how the agent should behave and reason when performing tasks. The agent has built-in tools that allow it to read your project files, understand the structure, and modify the code. It uses these processes to gather relevant context when making intelligent changes.

Understanding Sub-Agents :

  • What are Sub Agents? They are the smaller agents within a main agent. The main agent may hold the broad context about the entire project, and a sub-agent is created to handle a specific task with only the relevant context it needs. This focused context helps it perform the task more efficiently and with fewer mistakes.

  • How Sub Agent Isolate Context: They isolate context by limiting their working information to only what is necessary for a specific task. When initialized, they typically start with little or no built-in context, and any context they operate with is either passed down from the main agent or provided through prompts defined by the user.

  • Types Of Sub-Agents:

    • Local Agent: This Agent runs on your local workspace. Some of its benefits include:

      • Editing Files

      • Code Refactoring

      • Running test/builds, etc

    • Background Agent: This Agent runs Async in the background on your local workspace while you continue doing other tasks. So the benefits include:

      • Project-wide refactoring

      • Generating Documentation

      • Initial Code Base Analysis. etc

    • Cloud Agent:

Setting Up Sub Agent:

To create a sub agent in vs code ensure you an on VSCode >= v1.106

  • Creating a local agent:

    • Click on the setting button and select custom age



    • Next, click on the Create new custom agent



    • Next, select where to store it.

    • Now define what task you want the sub-agent to perform, what argument hint you want it to look out for, and finally what built-in tools you want it to have access to.

    • Now go back to the chat window, click on the ask