How minimax-ai/mini-agent works
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: agent.py Agent loop · cli.py CLI · llm_wrapper.py LLM wrapper · skill_loader.py Skill loader
Components 20
Runtime
Entry points and local execution
- CLI · Command-line entry into the local agent
mini_agent/cli.py
Core Agent
Orchestration and model boundary
- Agent loop · Coordinates prompts, tool calls, results, and task flow
mini_agent/agent.py - LLM wrapper · Selects and normalizes provider access
mini_agent/llm/llm_wrapper.py - LLM contract · Shared model client contract
mini_agent/llm/base.py - OpenAI client · OpenAI-compatible model client
mini_agent/llm/openai_client.py - Anthropic client · Anthropic-compatible model client
mini_agent/llm/anthropic_client.py
Actions
Local tools and external tool access
- Shell tool · Runs local shell commands
mini_agent/tools/bash_tool.py - File tools · Workspace file and path operations
mini_agent/tools/file_tools.py - Session notes · Stores cross-session facts and notes
mini_agent/tools/note_tool.py - Skill tool · Invokes packaged skills as actions
mini_agent/tools/skill_tool.py - Skill loader · Finds and registers bundled skills
mini_agent/tools/skill_loader.py - MCP loader · Connects to remote MCP servers
mini_agent/tools/mcp_loader.py
Skills
Packaged capability modules
- Skill library · Bundled Claude-style skill collection
mini_agent/skills - Document skills · DOCX, PDF, PPTX, and XLSX workflows
mini_agent/skills/document-skills - Web testing · Browser and app testing workflows
mini_agent/skills/webapp-testing
Integration
Editor and external interfaces
- ACP server · ACP interface for editor integrations
mini_agent/acp/server.py
Support
Configuration, schema, logging, and utilities
Connections 26
- 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