Build a Basic AI Agent from Scratch: Agents and Sub-Agents
Build a Basic AI Agent from Scratch: Agents and Sub-Agents
This installment of the series adds selectable specialist agents (general, plan, explore, build, review) defined via an AgentDefinition dataclass and custom SOUL.md files, letting users switch the active top-level agent while keeping the conversation. It also introduces sub-agents: a parent can call spawn_subagent with an agent name, description and self-contained prompt, and the child runs in its own context with its own scratchpad and to-do list, sharing the parent's sandbox, cost tracker and audit log, returning only a size-limited final answer. Delegation is bounded by max depth, per-agent turn and tool-call caps, and concurrency limits, and sub-agents cannot pause for interactive permission prompts.
Source: Hacker News AI · ruxu.dev