Friendev
Features Install Blog Github Discussions
2025 12 10 β€’ Feature

Friendev 0.2.7: Introducing SubAgent Architecture

Friendev Team β€’ 5 min read
Friendev 0.2.7: Introducing SubAgent Architecture
# Friendev 0.2.7: Deep Dive into SubAgent Architecture Friendev 0.2.7 introduces a game-changing feature: **SubAgent Architecture**. This isn't just a new tool; it's a fundamental shift in how Friendev handles complex tasks. By allowing the main agent to spawn specialized, isolated sub-processes, we're moving from a single-threaded thinker to a collaborative team structure. ## The Architecture: Recursive & Isolated At the heart of this feature is the `task` tool. When the main agent invokes this tool, Friendev doesn't just switch context; it spins up a completely new, isolated environment. ### 1. Session Isolation Each SubAgent runs in its own `ChatSession`. * **Fresh Context**: The SubAgent starts with a blank slate. It does *not* see the main agent's chat history. This is a deliberate design choice to prevent "context pollution"β€”the confusion that arises when an LLM tries to hold too much irrelevant information in its working memory. * **Explicit Handoff**: The main agent must explicitly provide all necessary context in the `prompt` parameter. This forces the main agent to summarize and clarify the task before delegating it. ### 2. Recursive Execution The implementation uses a recursive loop (`run_agent_loop`). * **Inherited Capabilities**: SubAgents inherit the full toolset of the parent, including file access, shell commands, and MCP integrations. * **Safety Inheritance**: Crucially, SubAgents inherit the security mode of the parent. If you are running in **Shorekeeper** or **Jury** mode, the SubAgent's actions are subject to the same rigorous security checks. ## Specialized Roles Friendev 0.2.7 defines specific system prompts for different SubAgent types, optimizing their behavior for distinct phases of development: ### πŸ› οΈ The Coder * **System Instruction**: "Focus on implementation details, error handling, and edge cases." * **Behavior**: The Coder is less chatty and more action-oriented. It prioritizes writing code that works and passes tests. It is the "hands-on" builder. ### πŸ” The Reviewer * **System Instruction**: "Analyze code for bugs, security issues, and style violations. Be critical and thorough." * **Behavior**: The Reviewer adopts a critical persona. It looks for what's *wrong* rather than just trying to complete a task. This adversarial relationship with the Coder helps catch issues that a single "optimistic" agent might miss. ### πŸ“‹ The Planner * **System Instruction**: "Break down complex requirements into actionable steps. Use the `todo_write` tool." * **Behavior**: The Planner is architecturally focused. It doesn't write implementation code; instead, it maps out the strategy, creating a structured Todo list that guides the subsequent execution. ## Example Workflow Imagine you ask Friendev to "Refactor the authentication module." 1. **Main Agent**: Realizes this is complex. Spawns a **Planner**. 2. **Planner SubAgent**: Scans the code, identifies dependencies, and creates a 5-step migration plan using `todo_write`. Returns the plan to Main. 3. **Main Agent**: Sees the plan. For Step 1 (Create new Token Service), it spawns a **Coder**. 4. **Coder SubAgent**: Writes the `TokenService` struct and unit tests. Returns "Done". 5. **Main Agent**: Spawns a **Reviewer** to check the new file. 6. **Reviewer SubAgent**: Points out a potential race condition. 7. **Main Agent**: Spawns **Coder** again to fix the race condition. This loop continues until the task is done, with the Main Agent acting as the Project Manager. ## Why This Matters * **Token Efficiency**: By isolating tasks, we avoid feeding the entire conversation history into the model for every small step, saving tokens and reducing latency. * **Higher Quality**: Specialized prompts mean the model doesn't have to be a "jack of all trades" at every moment. It can fully commit to being a harsh critic or a creative builder. * **Scalability**: This architecture lays the groundwork for even more complex workflows, such as parallel execution of sub-tasks in future updates. Upgrade to Friendev 0.2.7 today and experience the power of a dedicated AI development team.

© 2025 Friendev. Open Source AI Development Assistant.