> ## Documentation Index
> Fetch the complete documentation index at: https://platform.minimax.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Mini-Agent: Build Your First Intelligent Assistant

> <Note> This tutorial will guide you through the core architecture of Mini-Agent and show you how to integrate with the MiniMax M2.1 model to build your own intelligent Agent. </Note>

<div style={{display: 'flex', alignItems: 'center', gap: '12px', marginBottom: '16px'}}>
  <div style={{width: '40px', height: '40px', borderRadius: '50%', background: 'linear-gradient(135deg, #6366f1, #8b5cf6)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: 'white', fontWeight: 'bold'}}>B</div>

  <div>
    <div style={{fontWeight: 500}}>Blue</div>
    <div style={{fontSize: '0.875rem', color: '#9ca3af'}}>January 15, 2026</div>
  </div>
</div>

<a href="https://github.com/MiniMax-AI/Mini-Agent" target="_blank" style={{display: 'inline-flex', alignItems: 'center', gap: '8px', padding: '8px 16px', borderRadius: '8px', border: '1px solid #e5e7eb', textDecoration: 'none', color: 'inherit', marginBottom: '32px'}}>
  <svg height="20" width="20" viewBox="0 0 16 16" fill="currentColor">
    <path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" />
  </svg>

  Download from GitHub
</a>

# Introduction to Mini-Agent Framework

**Mini-Agent is a minimalist yet professional AI Agent development framework open-sourced by MiniMax**, designed to demonstrate best practices for building intelligent agents using the MiniMax M2.1 model. Unlike complex frameworks like LangChain, Mini-Agent adopts a lightweight design that allows developers to reach the essence of Agents and understand their core working principles.

***

## Core Features

Mini-Agent's design philosophy is **Lightweight, Simple, and Extensible**. It avoids over-encapsulation and clearly presents the core logic of Agents to developers, helping learners truly understand how Agents work, rather than just learning how to use a framework's API.

### Key Capabilities

<AccordionGroup>
  <Accordion title="Complete Agent Execution Loop">
    MiniAgent implements a complete Agent execution loop: **Perception → Thinking → Action → Feedback**. It makes decisions through LLM, calls tools to execute tasks, and feeds execution results back to the LLM, forming a closed-loop intelligent decision system.
  </Accordion>

  <Accordion title="Persistent Memory">
    The built-in Session Note Tool ensures that the Agent can retain key information across multiple sessions, achieving cross-session memory persistence and giving the Agent the ability to "remember".
  </Accordion>

  <Accordion title="Intelligent Context Management">
    Uses an automatic summarization mechanism to handle long conversation scenarios. When the context approaches the Token limit, the system automatically calls the LLM to compress and summarize historical conversations, supporting unlimited task execution.
  </Accordion>

  <Accordion title="Rich Tool Ecosystem">
    * **Basic Tool Set**: File read/write, Shell command execution, and other basic capabilities
    * **Claude Skills Integration**: Built-in 15 professional skills covering document processing, design, testing, and development
    * **MCP Tool Support**: Native support for Model Context Protocol (MCP), easily integrating external tools like knowledge graphs and web search
  </Accordion>

  <Accordion title="Multiple API Compatibility">
    Compatible with Anthropic and OpenAI API interfaces, supporting LLM API integration from different model providers.
  </Accordion>
</AccordionGroup>

***

## Mini-Agent Architecture

A complete system consists of three core components:

### LLM (Brain) - Responsible for Understanding and Decision-Making

```python theme={null}
# mini_agent/llm/base.py
class LLMClientBase(ABC):
    async def generate(
        self,
        messages: list[Message],
        tools: list[Any] | None = None,
    ) -> LLMResponse:
        """Generate LLM response, including content, thinking process, and tool calls"""
        pass
```

`LLMClientBase` is the base class for LLM, defining the LLM interface. In the Mini-Agent project, based on `LLMClientBase`, both Anthropic and OpenAI LLM integration methods are provided.

### Tools - Capabilities for Executing Specific Tasks

```python theme={null}
# mini_agent/tools/base.py
class Tool:
    @property
    def name(self) -> str: ...        # Tool name
    
    @property
    def description(self) -> str: ... # Tool description (for LLM)
    
    @property
    def parameters(self) -> dict: ... # Parameter definition (JSON Schema)
    
    async def execute(self, **kwargs) -> ToolResult:
        """Execute tool and return result"""
        pass
```

Tools are the "hands and feet" of the Agent. The Mini-Agent project provides several basic tools:

* **BashTool**: Execute Shell commands
* **FileReadTool / FileWriteTool**: File read/write
* **SessionNoteTool**: Session notes (persistent memory)

### Memory - Conversation History and Context Management

```python theme={null}
# mini_agent/schema/schema.py
class Message(BaseModel):
    role: str  # "system", "user", "assistant", "tool"
    content: str | list[dict]
    thinking: str | None = None      # Extended thinking content
    tool_calls: list[ToolCall] | None = None
```

Memory manages conversation history. Mini-Agent uses an intelligent summarization mechanism to handle long conversation scenarios:

```python theme={null}
# Call LLM to generate summary
summary_prompt = f"""Please summarize the following Agent execution process concisely:
{summary_content}
Requirements: Focus on what tasks were completed, which tools were called, and retain key results"""

response = await self.llm.generate(messages=[
    Message(role="system", content="You are an assistant skilled at summarizing Agent execution processes"),
    Message(role="user", content=summary_prompt)
])
```

***

## Mini-Agent Loop Mechanism

Core Loop: **Perception → Thinking → Action → Feedback**

The core execution logic of Mini-Agent is in the `run()` method of `agent.py`:

```python theme={null}
async def run(self) -> str:
    step = 0
    while step < self.max_steps:
        # 1. Check and summarize message history (prevent context overflow)
        await self._summarize_messages()
        
        # 2. Call LLM to get response (thinking)
        response = await self.llm.generate(
            messages=self.messages,
            tools=tool_list
        )
        
        # 3. If no tool calls, task is complete
        if not response.tool_calls:
            return response.content
        
        # 4. Execute tool calls (action)
        for tool_call in response.tool_calls:
            tool = self.tools[tool_call.function.name]
            result = await tool.execute(**arguments)
            # Add result to message history (feedback)
            self.messages.append(tool_msg)
        
        step += 1
```

**Loop Decision Process:**

<Steps>
  <Step title="Receive Input">
    LLM receives message history and available tool list
  </Step>

  <Step title="Decision Making">
    LLM determines whether to call tools and outputs structured `tool_calls`
  </Step>

  <Step title="Execute Tools">
    Agent parses `tool_calls` and executes corresponding tools
  </Step>

  <Step title="Feedback Results">
    Tool execution results are added to history as `tool` role messages
  </Step>

  <Step title="Loop Iteration">
    Loop continues until LLM considers the task complete (no more tool calls)
  </Step>
</Steps>

***

## Integrating MiniMax-M2.1

### Step 1: Download Project

```bash theme={null}
# 1. Clone repository
git clone https://github.com/MiniMax-AI/Mini-Agent.git
cd Mini-Agent

# 2. Install uv (if not already installed)
# macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell):
irm https://astral.sh/uv/install.ps1 | iex
# Restart terminal after installation

# 3. Sync dependencies
uv sync
```

### Step 2: Configuration File

Copy `config-example.yaml` and rename it to `config.yaml`

### Step 3: Key Configuration

<Warning>
  **Required Configuration:**

  * `api_key`: Enter your MiniMax API Key
</Warning>

```yaml theme={null}
# ===== Key Settings =====
api_key: "YOUR_API_KEY_HERE"  # [Required] Enter MiniMax API Key
api_base: "https://api.minimax.io"  # International users use this address
# api_base: "https://api.minimaxi.com"  # Users in China use this address
model: "MiniMax-M2.1"
provider: "anthropic"  # LLM provider: "anthropic" or "openai"
```

### Step 4: Other Configuration (Optional)

```yaml theme={null}
# ===== Retry Configuration =====
retry:
  enabled: true           # Enable retry mechanism
  max_retries: 3          # Maximum retry attempts
  initial_delay: 1.0      # Initial delay time (seconds)
  max_delay: 60.0         # Maximum delay time (seconds)
  exponential_base: 2.0   # Exponential backoff base

# ===== Agent Configuration =====
max_steps: 100  # Maximum execution steps
workspace_dir: "./workspace"  # Working directory
system_prompt_path: "system_prompt.md"  # System prompt file

# ===== Tool Configuration =====
tools:
  # Basic tool switches
  enable_file_tools: true  # File read/write/edit tools
  enable_bash: true        # Bash command execution tool
  enable_note: true        # Session note tool

  # Claude Skills
  enable_skills: true      # Enable skills
  skills_dir: "./skills"   # Skills directory path

  # MCP Tools
  enable_mcp: true         # Enable MCP tools
  mcp_config_path: "mcp.json"  # MCP configuration file
```

### Step 5: Start Using

```bash theme={null}
# Run directly as module (suitable for debugging)
uv run python -m mini_agent.cli
```

**After running, you will see the Mini-Agent interactive interface:**

<img src="https://filecdn.minimax.chat/public/e2879bbf-292a-4b34-9b0e-72833463ec26.png" alt="Mini-Agent startup interface" style={{borderRadius: '8px', marginBottom: '16px', maxWidth: '100%'}} />

**Let's have it complete a task of making a product introduction of "Notion":**

<img src="https://file.cdn.minimax.io/public/ccd33a10-da41-4101-95bb-47872ad346fe.jpeg" alt="Mini-Agent interactive interface" style={{borderRadius: '8px', marginBottom: '16px', maxWidth: '100%'}} />

**Mini-Agent successfully completes the task:**

<img src="https://file.cdn.minimax.io/public/21abe584-30f1-4342-9b4e-bdf89319c16f.jpeg" alt="Mini-Agent execution result" style={{borderRadius: '8px', marginBottom: '16px', maxWidth: '100%'}} />

***

## Summary

* **The essence of an Agent is a decision loop**, including four types of behaviors: Perception, Thinking, Execution, and Feedback
* **Memory is the Agent's memory capability**, essentially context management, including compression, storage, and retrieval of context
* **Tools are the basic interface for Agents to interact with external systems and extend capabilities**; MCP, Claude Skills, and other capabilities proposed by the industry can be seen as further abstractions of Tools

***

## Related Resources

<Columns cols={3}>
  <Card title="MiniMax M2.1" icon="sparkles" href="https://minimax.io/news/minimax-m21">
    Detailed Introduction
  </Card>

  <Card title="Mini-Agent GitHub" icon="github" href="https://github.com/MiniMax-AI/Mini-Agent">
    Framework Source Code & Documentation
  </Card>

  <Card title="MiniMax Platform" icon="globe" href="https://platform.minimax.io">
    Get API Key
  </Card>
</Columns>
