Test basic agent usage with file creation task. This is the integration test for basic agent functionality, converted from example.py.
()
| 17 | |
| 18 | @pytest.mark.asyncio |
| 19 | async def test_basic_agent_usage(): |
| 20 | """Test basic agent usage with file creation task. |
| 21 | |
| 22 | This is the integration test for basic agent functionality, |
| 23 | converted from example.py. |
| 24 | """ |
| 25 | print("\n" + "=" * 80) |
| 26 | print("Integration Test: Basic Agent Usage") |
| 27 | print("=" * 80) |
| 28 | |
| 29 | # Load configuration |
| 30 | config_path = Path("mini_agent/config/config.yaml") |
| 31 | if not config_path.exists(): |
| 32 | pytest.skip("config.yaml not found") |
| 33 | |
| 34 | config = Config.from_yaml(config_path) |
| 35 | |
| 36 | # Check API key |
| 37 | if not config.llm.api_key or config.llm.api_key == "YOUR_MINIMAX_API_KEY_HERE": |
| 38 | pytest.skip("API key not configured") |
| 39 | |
| 40 | # Use temporary workspace |
| 41 | with tempfile.TemporaryDirectory() as workspace_dir: |
| 42 | # Load system prompt (Agent will auto-inject workspace info) |
| 43 | system_prompt_path = Path("mini_agent/config/system_prompt.md") |
| 44 | if system_prompt_path.exists(): |
| 45 | system_prompt = system_prompt_path.read_text(encoding="utf-8") |
| 46 | else: |
| 47 | system_prompt = "You are a helpful AI assistant." |
| 48 | |
| 49 | # Initialize LLM client |
| 50 | llm_client = LLMClient( |
| 51 | api_key=config.llm.api_key, |
| 52 | api_base=config.llm.api_base, |
| 53 | model=config.llm.model, |
| 54 | ) |
| 55 | |
| 56 | # Initialize basic tools |
| 57 | tools = [ |
| 58 | ReadTool(workspace_dir=workspace_dir), |
| 59 | WriteTool(workspace_dir=workspace_dir), |
| 60 | EditTool(workspace_dir=workspace_dir), |
| 61 | BashTool(), |
| 62 | ] |
| 63 | |
| 64 | # Add Note tools for session memory |
| 65 | memory_file = Path(workspace_dir) / ".agent_memory.json" |
| 66 | tools.extend( |
| 67 | [ |
| 68 | SessionNoteTool(memory_file=str(memory_file)), |
| 69 | RecallNoteTool(memory_file=str(memory_file)), |
| 70 | ] |
| 71 | ) |
| 72 | |
| 73 | # Load MCP tools (optional) - with timeout protection |
| 74 | try: |
| 75 | # MCP tools are disabled by default to prevent test hangs |
| 76 | # Enable specific MCP servers in mcp.json if needed |
no test coverage detected