File size: 5,789 Bytes
dc893fb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# Mini Agent Examples
This directory contains a series of progressive examples to help you understand how to use the Mini Agent framework.
## π Example List
### 01_basic_tools.py - Basic Tool Usage
**Difficulty**: β Beginner
**Content**:
- How to directly use ReadTool, WriteTool, EditTool, BashTool
- No Agent or LLM involved, pure tool call demonstrations
- Perfect for understanding each tool's basic functionality
**Run**:
```bash
python examples/01_basic_tools.py
```
**Key Learnings**:
- Tool input parameter formats
- ToolResult return structure
- Error handling approaches
---
### 02_simple_agent.py - Simple Agent Usage
**Difficulty**: ββ Beginner-Intermediate
**Content**:
- Create the simplest Agent
- Have Agent perform file creation tasks
- Have Agent execute bash command tasks
- Understand Agent execution flow
**Run**:
```bash
# Requires API key configuration first
python examples/02_simple_agent.py
```
**Key Learnings**:
- Agent initialization process
- How to give tasks to Agent
- How Agent autonomously selects tools
- Task completion criteria
**Prerequisites**:
- API key configured in `mini_agent/config/config.yaml`
---
### 03_session_notes.py - Session Note Tool
**Difficulty**: βββ Intermediate
**Content**:
- Direct usage of Session Note tools (record_note, recall_notes)
- Agent using Session Notes to maintain cross-session memory
- Demonstrate how two Agent instances share memory
**Run**:
```bash
python examples/03_session_notes.py
```
**Key Learnings**:
- How Session Notes work
- Note categorization management (category)
- How to guide Agent to use notes in system prompt
- Cross-session memory implementation
**Highlight**:
This is one of the core features of this project! Shows a lightweight but effective session memory management solution.
---
### 04_full_agent.py - Full-Featured Agent
**Difficulty**: ββββ Advanced
**Content**:
- Complete Agent setup with all features
- Integration of basic tools + Session Notes + MCP tools
- Full execution flow for complex tasks
- Multi-turn conversation examples
**Run**:
```bash
python examples/04_full_agent.py
```
**Key Learnings**:
- How to combine multiple tools
- MCP tool loading and usage
- Complex task decomposition and execution
- Production environment Agent configuration
**Prerequisites**:
- API key configured
- (Optional) MCP tools configured
---
## π Quick Start
### 1. Configure API Key
```bash
# Copy configuration template
cp mini_agent/config/config-example.yaml mini_agent/config/config.yaml
# Edit config file and fill in your MiniMax API Key
vim mini_agent/config/config.yaml
```
### 2. Run Your First Example
```bash
# Example that doesn't need API key
python examples/01_basic_tools.py
# Example that needs API key
python examples/02_simple_agent.py
```
### 3. Progressive Learning
Recommended to learn in numerical order:
1. **01_basic_tools.py** - Understand tools
2. **02_simple_agent.py** - Understand Agent
3. **03_session_notes.py** - Understand memory management
4. **04_full_agent.py** - Understand complete system
---
## π Relationship with Test Cases
These examples are all refined from test cases in the `tests/` directory:
| Example | Based on Test | Description |
| ------------------- | ---------------------------------------------------- | ------------------------------- |
| 01_basic_tools.py | tests/test_tools.py | Basic tool unit tests |
| 02_simple_agent.py | tests/test_agent.py | Agent basic functionality tests |
| 03_session_notes.py | tests/test_note_tool.py<br>tests/test_integration.py | Session Note tool tests |
| 04_full_agent.py | tests/test_integration.py | Complete integration tests |
---
## π‘ Recommended Learning Paths
### Path 1: Quick Start
1. Run `01_basic_tools.py` - Learn about tools
2. Run `02_simple_agent.py` - Run your first Agent
3. Go directly to interactive mode with `mini-agent`
### Path 2: Deep Understanding
1. Read and run all examples (01 β 04)
2. Read corresponding test cases (`tests/`)
3. Read core implementation code (`mini_agent/`)
4. Try modifying examples to implement your own features
### Path 3: Production Application
1. Understand all examples
2. Read [Production Deployment Guide](../docs/PRODUCTION_GUIDE.md)
3. Configure MCP tools and Skills
4. Extend tool set based on needs
---
## π§ Troubleshooting
### API Key Error
```
β API key not configured in config.yaml
```
**Solution**: Ensure you've configured a valid MiniMax API Key in `mini_agent/config/config.yaml`
### config.yaml Not Found
```
β config.yaml not found
```
**Solution**:
```bash
cp mini_agent/config/config-example.yaml mini_agent/config/config.yaml
```
### MCP Tools Loading Failed
```
β οΈ MCP tools not loaded: [error message]
```
**Solution**: MCP tools are optional and don't affect basic functionality. If you need them, refer to the MCP configuration section in the main README.
---
## π More Resources
- [Main Project README](../README.md) - Complete project documentation
- [Test Cases](../tests/) - More usage examples
- [Core Implementation](../mini_agent/) - Source code
- [Production Guide](../docs/PRODUCTION_GUIDE.md) - Deployment guide
---
## π€ Contributing Examples
If you have good usage examples, PRs are welcome!
Suggested new example directions:
- Web search integration examples (using MiniMax Search MCP)
- Skills usage examples (document processing, design, etc.)
- Custom tool development examples
- Error handling and retry mechanism examples
---
**β If these examples help you, please give the project a Star!**
|