# minimax-ai/mini-agent architecture

> Architecture diagram of the GitHub repository minimax-ai/mini-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/minimax-ai/mini-agent
- Repository: https://github.com/minimax-ai/mini-agent

## Overview

1. **Repository role**
   - This is a Python agent framework and demo application centered on MiniMax M2.5, exposed primarily as a CLI package (`mini_agent`) with optional editor integration via ACP.
   - It is not a generic web app; the core architecture is an LLM-driven orchestration loop around tools, skills, and optional remote tool servers.

2. **Top-level runtime shape**
   - The package runs as a local agent on the user’s machine, operating over a configurable workspace directory.
   - The main entrypoint is the CLI (`mini_agent/cli.py`), which boots configuration, logging, the agent loop, and tool loading.

3. **Agent orchestration layer**
   - `mini_agent/agent.py` is the central coordinator. It owns the execution loop that sends prompts to the model, receives tool calls, invokes tools, and feeds results back into the conversation.
   - README features indicate this layer also handles long-running tasks, interleaved reasoning, and conversation summarization when context grows too large.

4. **LLM abstraction boundary**
   - `mini_agent/llm/` isolates provider-specific API access behind a common wrapper.
   - `base.py` defines the shared contract; `openai_client.py` and `anthropic_client.py` implement provider adapters; `llm_wrapper.py` selects and normalizes usage.
   - Architecturally, this is the boundary between the local agent runtime and the external model API, which is described as Anthropic-compatible and used with MiniMax endpoints.

5. **Tool execution subsystem**
   - `mini_agent/tools/` contains the local action surface the agent can use:
     - shell execution (`bash_tool.py`)
     - filesystem operations (`file_tools.py`)
     - session memory/notes (`note_tool.py`)
     - MCP integration (`mcp_loader.py`)
     - skill invocation (`skill_loader.py`, `skill_tool.py`)
   - These tools are the primary side-effect boundary: the model suggests actions, the agent validates/dispatches them, and tool outputs are returned into the reasoning loop.

6. **Persistent memory and workspace state**
   - The Session Note Tool is a distinct persistence mechanism, letting the agent retain key facts across sessions.
   - The workspace directory from config is the main local state boundary for file operations and generated artifacts; tools operate relative to it rather than on arbitrary global paths.

7. **Skills as packaged capability modules**
   - `mini_agent/skills/` is a large bundled capability library, largely organized as Claude Skills.
   - Skills are content-and-script packages rather than code dependencies: each skill has a `SKILL.md` plus assets/scripts for tasks like document generation, PDF/DOCX/PPTX handling, design, testing, communication, and web-app testing.
   - The loader layer makes these skills available to the agent as specialized task modules.

8. **MCP and external tool servers**
   - MCP support is a separate integration boundary, primarily handled through `mini_agent/tools/mcp_loader.py` and config examples in `mini_agent/config/mcp-example.json`.
   - This enables the agent to call out to external tool servers, such as search or knowledge graph services, without embedding those capabilities locally.

9. **ACP editor integration**
   - `mini_agent/acp/server.py` exposes the agent through ACP for editor integrations such as Zed.
   - This is a second interface into the same core agent runtime: instead of the CLI user flow, an editor talks to the agent server over the ACP boundary.

10. **Configuration, logging, and resilience**
   - `mini_agent/config.py`, `mini_agent/config/`, and `scripts/setup-config.*` define how API keys, base URLs, model selection, workspace paths, and limits are injected.
   - `mini_agent/logger.py` and `mini_agent/retry.py` support observability and robustness around API calls and tool execution.
   - `mini_agent/schema/` centralizes structured data contracts used across tools, model responses, and ACP/MCP-facing surfaces.

11. **Examples and validation**
   - `examples/` shows the intended architecture in use: basic tools, simple/full agents, session notes, provider selection, and tool schema demos.
   - `tests/` covers the major boundaries separately: agent loop, tools, LLM clients, MCP loading, ACP, session behavior, terminal utilities, and integration flows.

12. **How data flows through the system**
   - User input enters through the CLI or ACP server.
   - The agent builds context from config, workspace state, session notes, and loaded skills/tools.
   - The LLM returns reasoning and/or tool actions.
   - The agent executes local tools or MCP calls, captures results, updates memory/logs, and continues until the task completes.
   - Final output returns to the CLI/editor, while generated files and notes persist in the workspace or session storage.

Main entry points: [`mini_agent/agent.py`](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/agent.py) (Agent loop), [`mini_agent/cli.py`](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/cli.py) (CLI), [`mini_agent/llm/llm_wrapper.py`](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/llm/llm_wrapper.py) (LLM wrapper), [`mini_agent/tools/skill_loader.py`](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/skill_loader.py) (Skill loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_cli["CLI<br/>entrypoint<br/>[cli.py]"]
end

subgraph group_core["Core Agent"]
  node_agent(("Agent loop<br/>orchestrator<br/>[agent.py]"))
  node_llm_wrapper["LLM wrapper<br/>adapter<br/>[llm_wrapper.py]"]
  node_llm_base["LLM contract<br/>interface<br/>[base.py]"]
  node_openai_client["OpenAI client<br/>provider adapter<br/>[openai_client.py]"]
  node_anthropic_client["Anthropic client<br/>provider adapter"]
end

subgraph group_actions["Actions"]
  node_bash_tool["Shell tool<br/>[bash_tool.py]"]
  node_file_tools["File tools<br/>toolset<br/>[file_tools.py]"]
  node_note_tool[("Session notes<br/>persistent memory<br/>[note_tool.py]")]
  node_skill_tool["Skill tool<br/>[skill_tool.py]"]
  node_skill_loader["Skill loader<br/>discovery<br/>[skill_loader.py]"]
  node_mcp_loader["MCP loader<br/>external tool bridge<br/>[mcp_loader.py]"]
end

subgraph group_capabilities["Skills"]
  node_skills_root["Skill library<br/>packaged capabilities"]
  node_doc_skills["Document skills<br/>skill family"]
  node_webapp_testing["Web testing<br/>skill family"]
end

subgraph group_integration["Integration"]
  node_acp_server["ACP server<br/>editor bridge<br/>[server.py]"]
end

subgraph group_support["Support"]
  node_config["Config<br/>settings<br/>[config.py]"]
  node_schema["Schemas<br/>contracts<br/>[schema.py]"]
  node_logger["Logger<br/>observability<br/>[logger.py]"]
  node_retry["Retry<br/>resilience<br/>[retry.py]"]
end

node_cli -->|"loads"| node_config
node_cli -->|"starts"| node_agent
node_cli -->|"binds"| node_llm_wrapper
node_cli -->|"loads"| node_skill_loader
node_cli -->|"loads"| node_mcp_loader
node_cli -->|"configures"| node_logger
node_acp_server -->|"hosts"| node_agent
node_agent -->|"queries"| node_llm_wrapper
node_agent -->|"executes"| node_bash_tool
node_agent -->|"executes"| node_file_tools
node_agent -->|"reads/writes"| node_note_tool
node_agent -->|"executes"| node_skill_tool
node_agent -->|"routes"| node_mcp_loader
node_agent -->|"validates"| node_schema
node_agent -->|"hardens"| node_retry
node_llm_wrapper -->|"implements"| node_llm_base
node_llm_wrapper -->|"selects"| node_openai_client
node_llm_wrapper -->|"selects"| node_anthropic_client
node_skill_loader -->|"discovers"| node_skills_root
node_skill_loader -->|"registers"| node_doc_skills
node_skill_loader -->|"registers"| node_webapp_testing
node_skill_tool -->|"invokes"| node_skills_root
node_mcp_loader -->|"reads"| node_config
node_note_tool -->|"uses"| node_config
node_file_tools -->|"uses"| node_config
node_logger -->|"supports"| node_retry

click node_cli "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/cli.py"
click node_acp_server "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/acp/server.py"
click node_agent "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/agent.py"
click node_llm_wrapper "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/llm/llm_wrapper.py"
click node_llm_base "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/llm/base.py"
click node_openai_client "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/llm/openai_client.py"
click node_anthropic_client "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/llm/anthropic_client.py"
click node_bash_tool "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/bash_tool.py"
click node_file_tools "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/file_tools.py"
click node_note_tool "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/note_tool.py"
click node_skill_tool "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/skill_tool.py"
click node_skill_loader "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/skill_loader.py"
click node_mcp_loader "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/mcp_loader.py"
click node_skills_root "https://github.com/minimax-ai/mini-agent/tree/main/mini_agent/skills"
click node_doc_skills "https://github.com/minimax-ai/mini-agent/tree/main/mini_agent/skills/document-skills"
click node_webapp_testing "https://github.com/minimax-ai/mini-agent/tree/main/mini_agent/skills/webapp-testing"
click node_config "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/config.py"
click node_schema "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/schema/schema.py"
click node_logger "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/logger.py"
click node_retry "https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/retry.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli toneBlue
class node_agent,node_llm_wrapper,node_llm_base,node_openai_client,node_anthropic_client toneAmber
class node_bash_tool,node_file_tools,node_note_tool,node_skill_tool,node_skill_loader,node_mcp_loader toneMint
class node_skills_root,node_doc_skills,node_webapp_testing toneRose
class node_acp_server toneIndigo
class node_config,node_schema,node_logger,node_retry toneTeal
```

## Components

### Runtime

Entry points and local execution

- [CLI](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/cli.py): entrypoint · Command-line entry into the local agent · `mini_agent/cli.py`

### Core Agent

Orchestration and model boundary

- [Agent loop](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/agent.py): orchestrator · Coordinates prompts, tool calls, results, and task flow · `mini_agent/agent.py`
- [LLM wrapper](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/llm/llm_wrapper.py): adapter · Selects and normalizes provider access · `mini_agent/llm/llm_wrapper.py`
- [LLM contract](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/llm/base.py): interface · Shared model client contract · `mini_agent/llm/base.py`
- [OpenAI client](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/llm/openai_client.py): provider adapter · OpenAI-compatible model client · `mini_agent/llm/openai_client.py`
- [Anthropic client](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/llm/anthropic_client.py): provider adapter · Anthropic-compatible model client · `mini_agent/llm/anthropic_client.py`

### Actions

Local tools and external tool access

- [Shell tool](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/bash_tool.py): tool · Runs local shell commands · `mini_agent/tools/bash_tool.py`
- [File tools](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/file_tools.py): toolset · Workspace file and path operations · `mini_agent/tools/file_tools.py`
- [Session notes](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/note_tool.py): persistent memory · Stores cross-session facts and notes · `mini_agent/tools/note_tool.py`
- [Skill tool](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/skill_tool.py): tool · Invokes packaged skills as actions · `mini_agent/tools/skill_tool.py`
- [Skill loader](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/skill_loader.py): discovery · Finds and registers bundled skills · `mini_agent/tools/skill_loader.py`
- [MCP loader](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/tools/mcp_loader.py): external tool bridge · Connects to remote MCP servers · `mini_agent/tools/mcp_loader.py`

### Skills

Packaged capability modules

- [Skill library](https://github.com/minimax-ai/mini-agent/tree/main/mini_agent/skills): packaged capabilities · Bundled Claude-style skill collection · `mini_agent/skills`
- [Document skills](https://github.com/minimax-ai/mini-agent/tree/main/mini_agent/skills/document-skills): skill family · DOCX, PDF, PPTX, and XLSX workflows · `mini_agent/skills/document-skills`
- [Web testing](https://github.com/minimax-ai/mini-agent/tree/main/mini_agent/skills/webapp-testing): skill family · Browser and app testing workflows · `mini_agent/skills/webapp-testing`

### Integration

Editor and external interfaces

- [ACP server](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/acp/server.py): editor bridge · ACP interface for editor integrations · `mini_agent/acp/server.py`

### Support

Configuration, schema, logging, and utilities

- [Config](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/config.py): settings · Model, workspace, limits, and API settings · `mini_agent/config.py`
- [Schemas](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/schema/schema.py): contracts · Shared structured data contracts · `mini_agent/schema/schema.py`
- [Logger](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/logger.py): observability · Logging and runtime tracing · `mini_agent/logger.py`
- [Retry](https://github.com/minimax-ai/mini-agent/blob/main/mini_agent/retry.py): resilience · Retry and recovery helpers · `mini_agent/retry.py`

## Connections

- CLI → Config: loads · Bootstraps runtime configuration
- CLI → Agent loop: starts · Starts the local agent loop
- CLI → LLM wrapper: binds · Initializes model access
- CLI → Skill loader: loads · Discovers available skills
- CLI → MCP loader: loads · Configures external tool servers
- CLI → Logger: configures · Sets up logging
- ACP server → Agent loop: hosts · Exposes the same agent runtime over ACP
- Agent loop → LLM wrapper: queries · Sends prompts and receives model output
- Agent loop → Shell tool: executes · Dispatches shell actions
- Agent loop → File tools: executes · Performs workspace file operations
- Agent loop → Session notes: reads/writes · Maintains session memory
- Agent loop → Skill tool: executes · Runs packaged skill workflows
- Agent loop → MCP loader: routes · Delegates to remote MCP tools when enabled
- Agent loop → Schemas: validates · Uses structured contracts for model and tool data
- Agent loop → Retry: hardens · Retries transient failures
- LLM wrapper → LLM contract: implements · Shares the common client contract
- LLM wrapper → OpenAI client: selects · Uses OpenAI-compatible backend when configured
- LLM wrapper → Anthropic client: selects · Uses Anthropic-compatible backend when configured
- Skill loader → Skill library: discovers · Loads bundled skill packages
- Skill loader → Document skills: registers · Makes document skills available
- Skill loader → Web testing: registers · Makes web-testing skills available
- Skill tool → Skill library: invokes · Runs skill content and scripts
- MCP loader → Config: reads · Uses MCP configuration and endpoints
- Session notes → Config: uses · Respects workspace and persistence settings
- File tools → Config: uses · Restricts file actions to configured workspace
- Logger → Retry: supports · Logs failures and recovery events
