docs/developer/architecture.md
Agent Zero is built on a flexible and modular architecture designed for extensibility and customization. This section outlines the key components and the interactions between them.
The user or Agent 0 is at the top of the hierarchy, delegating tasks to subordinate agents, which can further delegate to other agents. Each agent can utilize tools and access the shared assets (prompts, memory, knowledge, extensions and skills) to perform its tasks.
Agent Zero's runtime architecture is built around Docker containers:
Host System (your machine):
Runtime Container:
This architecture ensures:
[!NOTE] The legacy approach of running Agent Zero directly on the host system (using Python, Conda, etc.) is still possible but requires Remote Function Calling (RFC) configuration through the Settings page. See the development guide for detailed instructions.
| Directory | Description |
|---|---|
/docker | Docker-related files for runtime container |
/docs | Documentation files and guides |
/usr/skills | Skills using the open SKILL.md standard (contextual expertise) |
/agents | Agent profiles (prompts, tools, extensions per profile) |
/knowledge | Knowledge base storage |
/logs | HTML CLI-style chat logs |
/memory | Persistent agent memory storage |
/prompts | Default system and tool prompt templates |
/python | Core Python codebase |
/python/api | API endpoints and interfaces |
/python/extensions | Modular extensions |
/python/helpers | Utility functions |
/python/tools | Tool implementations |
/tmp | Temporary runtime data |
/usr/chats | Saved chat history (JSON) |
/usr/secrets.env | Secrets store (not always included in backups) |
/usr/projects | Project workspaces and .a0proj metadata |
/webui | Web interface components |
/webui/css | Stylesheets |
/webui/js | JavaScript modules |
/webui/public | Static assets |
| File | Description |
|---|---|
usr/settings.json | Main runtime settings (written by the Settings UI) |
usr/secrets.env | Secrets store (managed via Settings -> Secrets) |
conf/model_providers.yaml | Model provider defaults and settings |
agent.py | Core agent implementation |
execute.py | Framework initialization |
models.py | Model providers and configs |
preload.py | Pre-initialization routines |
prepare.py | Environment preparation |
requirements.txt | Python dependencies |
run_ui.py | Web UI launcher |
[!NOTE] In the Docker runtime, the framework lives under
/a0inside the container. Data persists as long as the container exists. For upgrades, prefer Backup & Restore instead of mapping the full/a0directory.
Agent Zero's architecture revolves around the following key components:
The core actors within the framework. Agents receive instructions, reason, make decisions, and utilize tools to achieve their objectives. Agents operate within a hierarchical structure, with superior agents delegating tasks to subordinate agents.
Agent Zero employs a hierarchical agent structure, where a top-level agent (often the user) can delegate tasks to subordinate agents. This hierarchy allows for the efficient breakdown of complex tasks into smaller, more manageable sub-tasks.
Communication flows between agents through messages, which are structured according to the prompt templates. These messages typically include:
| Argument | Description |
|---|---|
Thoughts: | The agent's Chain of Thought and planning process |
Tool name: | The specific tool used by the agent |
Responses or queries: | Results, feedback or queries from tools or other agents |
A typical interaction flow within Agent Zero might look like this:
thoughts argument, possibly involving the use of tools or the creation of sub-agentsTools are functionalities that agents can leverage. These can include anything from web search and code execution to interacting with APIs or controlling external software. Agent Zero provides a mechanism for defining and integrating both built-in and custom tools.
Agent Zero comes with a set of built-in tools designed to help agents perform tasks efficiently:
| Tool | Function |
|---|---|
| behavior_adjustment | Agent Zero use this tool to change its behavior according to a prior request from the user. |
| call_subordinate | Allows agents to delegate tasks to subordinate agents |
| code_execution_tool | Allows agents to execute Python, Node.js, and Shell code in the terminal |
| input | Allows agents to use the keyboard to interact with an active shell |
| response_tool | Allows agents to output a response |
| memory_tool | Enables agents to save, load, delete and forget information from memory |
Agent Zero has integrated SearXNG as its primary search tool, replacing the previous knowledge tools (Perplexity and DuckDuckGo). This integration enhances the agent's ability to retrieve information while ensuring user privacy and customization.
Privacy-Focused Search SearXNG is an open-source metasearch engine that allows users to search multiple sources without tracking their queries. This integration ensures that user data remains private and secure while accessing a wide range of information.
Enhanced Search Capabilities The integration provides access to various types of content, including images, videos, and news articles, allowing users to gather comprehensive information on any topic.
Fallback Mechanism In cases where SearXNG might not return satisfactory results, Agent Zero can be configured to fall back on other sources or methods, ensuring that users always have access to information.
[!NOTE] The Knowledge Tool is designed to work seamlessly with both online searches through SearXNG and local knowledge base queries, providing a comprehensive information retrieval system.
Users can create custom tools to extend Agent Zero's capabilities. Custom tools can be integrated into the framework by defining a tool specification, which includes the tool's prompt. Place these prompt overrides in your agent profile:
agent.system.tool.$TOOL_NAME.md in agents/<agent_profile>/prompts/agent.system.tools.md within the same prompt scopepython/tools using Tool base class[!NOTE] Tools are always present in system prompt, so you should keep them to minimum. To save yourself some tokens, use the Skills module to add contextual expertise that is only loaded when relevant.
The memory system is a critical component of Agent Zero, enabling the agent to learn and adapt from past interactions. It operates on a hybrid model where part of the memory is managed automatically by the framework while users can also manually input and extract information.
The memory is categorized into four distinct areas:
Agent Zero employs a sophisticated message history and summarization system to maintain context effectively while optimizing memory usage. This system dynamically manages the information flow, ensuring relevant details are readily available while efficiently handling the constraints of context windows.
Implementation Details:
By dynamically adjusting context windows and summarizing past interactions, Agent Zero enhances both efficiency and user experience. This innovation not only reflects the framework's commitment to being dynamic and user-centric, but also draws inspiration from human cognitive processes, making AI interactions more relatable and effective. Just as humans forget trivial details, Agent Zero intelligently condenses information to enhance communication.
[!NOTE] To maximize the effectiveness of context summarization, users should provide clear and specific instructions during interactions. This helps Agent Zero understand which details are most important to retain.
The prompts directory contains various Markdown files that control agent behavior and communication. The most important file is agent.system.main.md, which acts as a central hub, referencing other prompt files.
| Prompt File | Description |
|---|---|
| agent.system.main.role.md | Defines the agent's overall role and capabilities |
| agent.system.main.communication.md | Specifies how the agent should communicate |
| agent.system.main.solving.md | Describes the agent's approach to tasks |
| agent.system.main.tips.md | Provides additional tips or guidance |
| agent.system.main.specifics.md | Empty by default — override per profile for agent-specific instructions |
| agent.system.main.behaviour.md | Controls dynamic behavior adjustments and rules |
| agent.system.main.environment.md | Defines the runtime environment context |
| agent.system.tools.md | Organizes and calls the individual tool prompt files |
| agent.system.tool.*.md | Individual tool prompt files |
prompts/, serve as the base configurationagents/<agent_profile>/prompts/behaviour.md, containing dynamic rulesagents/<agent_profile>/agents/<agent_profile>/prompts/For user-created profiles, prefer /a0/usr/agents/<agent_profile>/ so updates do not overwrite custom files. See the Agent Profiles guide for the current agent.yaml structure, prompt override paths, and profile-specific _model_config model settings.
{{include original}}When overriding a prompt, you can extend the original instead of replacing it entirely. Use {{include original}} to pull in the default version and add your changes on top:
Example: agents/developer/prompts/agent.system.main.communication.md:
{{include original}}
- always explain your reasoning
- include code snippets in responses
This finds agent.system.main.communication.md in the next directory up the hierarchy → includes the default from prompts/ → appends the additions. Result:
## Communication
- be concise
- use markdown formatting
- ask clarifying questions when unsure
- always explain your reasoning
- include code snippets in responses
Overrides stay small and automatically inherit any future changes to the default.
Behavior Adjustment:
Behavior Management Components:
behaviour_adjustment.py: Core tool for updating agent behavior_20_behaviour_prompt.py: Extension that injects behavior rules into system promptbehaviour.mdBehavior Update Process:
Integration with System Prompt:
[!NOTE]
You can customize any of these files. Agent Zero will use files inagents/<agent_profile>/prompts/when present, and fall back toprompts/for everything else.
[!TIP] The behavior system allows for dynamic adjustments without modifying the base prompt files. Changes made through behavior rules persist across sessions while maintaining the core functionality.
Knowledge refers to the user-provided information and data that agents can leverage:
Custom Knowledge: Add files to /knowledge/custom/main directory manually or through the "Import Knowledge" button in the UI
.txt, .pdf, .csv, .html, .json, .mdKnowledge Base:
/docs folder automatically addedSkills provide contextual expertise using the open SKILL.md standard (originally developed by Anthropic). Skills are cross-platform and compatible with Claude Code, Cursor, Goose, OpenAI Codex CLI, GitHub Copilot, and more.
.sh, .py, .js, .ts scripts---
name: "my-skill"
description: "What this skill does and when to use it"
version: "1.0.0"
author: "Your Name"
tags: ["category", "purpose"]
---
# Skill Instructions
Your detailed instructions here...
## Examples
- Example usage 1
- Example usage 2
| Directory | Description |
|---|---|
/skills | Default skills included with Agent Zero |
/usr/skills | Your custom skills (create folders here) |
usr/skills (e.g., usr/skills/my-skill)SKILL.md file with YAML frontmatter (required).sh, .py, etc.)docs/ subfolder for additional documentationSkills are surfaced via description/tag matching. You can also use the skills_tool to:
Extensions are a powerful feature of Agent Zero, designed to keep the main codebase clean and organized while allowing for greater flexibility and modularity.
Extensions can be found in python/extensions directory:
python/extensions subfolder[!NOTE]
Consider contributing valuable custom components to the main repository. See Contributing for more information.