I was using sub-agents wrong... Here is my way after 20+ hrs test

Understanding Sub-Agent Concept in Cloud Code 00:04

  • Sub-agents were introduced to Cloud Code to optimize token usage and improve code performance by offloading research tasks.
  • Before sub-agents, the main agent handled all tasks, leading to large context windows and frequent summarization, causing performance drops.
  • Sub-agents can perform tasks like scanning codebases and summarizing findings, reducing the number of tokens by only passing back essential summaries.
  • The system keeps sub-agent actions out of the parent’s conversation history, saving space and context for the main task.

Common Misuse and Challenges 02:08

  • Problems arise when sub-agents are tasked with implementation rather than just research or planning.
  • If sub-agents (e.g., front-end and back-end agents) implement separately, they lack shared context, making bug fixes and coordination difficult.
  • Each sub-agent operates in an isolated task session, leading to a loss of history and inability to know what other agents or sessions have done.
  • Currently, context sharing between agents is limited, but future improvements are expected.

Best Practices for Effective Sub-Agent Use 04:01

  • Use sub-agents mainly as researchers to gather information and return concise summaries, not for direct implementation.
  • Expert sub-agents can be created per service (e.g., Vercel SDK, Stripe, Tailwind) and loaded with specialized documentation and tools.
  • Adam Wolf from the Cloud Code team supports the idea that sub-agents work best when delivering small, high-value research summaries.

Optimizing Context Management 05:11

  • Inspired by techniques from the Manus team, local files (e.g., Markdown files) are used to store task results and research, ensuring persistent, accessible context.
  • The parent agent maintains a context file (e.g., doc/task/) summarizing the project status and steps done.
  • All sub-agents read the current context file before starting work and update it with new findings or plans after task completion.
  • Research reports and implementation plans are saved to doc files so other agents or parent agents can consult them as needed.

Building and Structuring Sub-Agents 07:51

  • Important documentation and references are added directly to the sub-agent’s system prompt to ensure up-to-date compliance with best practices.
  • Sub-agents have access to specialized tools (e.g., MCP tools for information retrieval) specific to their domain.
  • Agents are configured by editing settings files, setting up specialized MCP servers, and defining roles and access.
  • The system prompt includes specific rules: agents propose detailed implementation plans, never implement directly, and always update/read context files accordingly.
  • Standardized output formats ensure clarity and process consistency across all sub-agents.

Demonstration: Setting Up and Using Sub-Agents 11:48

  • Demonstrates creating a Next.js project using specialized sub-agents (e.g., Chassian, Vercel AI SDK).
  • Parent agent manages project context and delegates tasks, ensuring agents read and update context files before and after work.
  • Each sub-agent performs research, retrieves examples and documentation, and compiles detailed plans in shared files.
  • Parent agent reads these plans and handles the actual implementation, retaining full project context for consistent results.
  • The process results in a high-fidelity, high-functioning application quickly assembled by combining agent research and central coordination.

Practical Results and Further Resources 14:04

  • Cloud code now supports background sessions, allowing monitoring and task persistence.
  • The demonstrated approach produces fully functional, high-quality UIs and integrations (e.g., connecting with Vercel SDK) with smooth, detailed user experiences.
  • The iterative, file-based approach improves success rates, quality, and maintainability when using AI agents for code tasks.
  • The presenter offers additional resources, club sessions, and templates for advanced sub-agent workflows.
  • Viewers are encouraged to join the AI builder club and access shared templates, hooks, commands, and best-practice discussions.