MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / test_agent_bash_task

Function test_agent_bash_task

tests/test_agent.py:98–161  ·  view source on GitHub ↗

Test agent with a bash command task.

()

Source from the content-addressed store, hash-verified

96
97@pytest.mark.asyncio
98async def test_agent_bash_task():
99 """Test agent with a bash command task."""
100 print("\n=== Testing Agent with Bash Task ===")
101
102 # Load config
103 config_path = Path("mini_agent/config/config.yaml")
104 config = Config.from_yaml(config_path)
105
106 # Create temp workspace
107 with tempfile.TemporaryDirectory() as workspace_dir:
108 print(f"Using workspace: {workspace_dir}")
109
110 # Load system prompt (Agent will auto-inject workspace info)
111 system_prompt_path = Path("mini_agent/config/system_prompt.md")
112 if system_prompt_path.exists():
113 system_prompt = system_prompt_path.read_text(encoding="utf-8")
114 else:
115 system_prompt = "You are a helpful AI assistant that can use tools."
116
117 # Initialize LLM client
118 llm_client = LLMClient(
119 api_key=config.llm.api_key,
120 api_base=config.llm.api_base,
121 model=config.llm.model,
122 )
123
124 # Initialize tools
125 tools = [
126 ReadTool(workspace_dir=workspace_dir),
127 WriteTool(workspace_dir=workspace_dir),
128 BashTool(),
129 ]
130
131 # Create agent
132 agent = Agent(
133 llm_client=llm_client,
134 system_prompt=system_prompt,
135 tools=tools,
136 max_steps=10,
137 workspace_dir=workspace_dir,
138 )
139
140 # Task: List files using bash
141 task = "Use bash to list all files in the current directory and tell me what you find."
142 print(f"\nTask: {task}\n")
143
144 agent.add_user_message(task)
145
146 try:
147 result = await agent.run()
148
149 print(f"\n{'=' * 80}")
150 print(f"Agent Result: {result}")
151 print("=" * 80)
152
153 print("\n✅ Bash task completed!")
154 return True
155

Callers 1

mainFunction · 0.85

Calls 8

add_user_messageMethod · 0.95
runMethod · 0.95
LLMClientClass · 0.90
ReadToolClass · 0.90
WriteToolClass · 0.90
BashToolClass · 0.90
AgentClass · 0.90
from_yamlMethod · 0.80

Tested by

no test coverage detected