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

Function demo_bash_task

examples/02_simple_agent.py:115–190  ·  view source on GitHub ↗

Demo: Agent executes bash commands.

()

Source from the content-addressed store, hash-verified

113
114
115async def demo_bash_task():
116 """Demo: Agent executes bash commands."""
117 print("\n" + "=" * 60)
118 print("Demo: Agent-Driven Bash Commands")
119 print("=" * 60)
120
121 # Load configuration
122 config_path = Path("mini_agent/config/config.yaml")
123 if not config_path.exists():
124 print("❌ config.yaml not found")
125 return
126
127 config = Config.from_yaml(config_path)
128
129 if not config.llm.api_key or config.llm.api_key.startswith("YOUR_"):
130 print("❌ API key not configured")
131 return
132
133 with tempfile.TemporaryDirectory() as workspace_dir:
134 print(f"📁 Workspace: {workspace_dir}\n")
135
136 # Load system prompt (Agent will auto-inject workspace info)
137 system_prompt_path = Path("mini_agent/config/system_prompt.md")
138 if system_prompt_path.exists():
139 system_prompt = system_prompt_path.read_text(encoding="utf-8")
140 else:
141 system_prompt = "You are a helpful AI assistant that can use tools."
142
143 # Initialize LLM
144 llm_client = LLMClient(
145 api_key=config.llm.api_key,
146 api_base=config.llm.api_base,
147 model=config.llm.model,
148 )
149
150 # Tools
151 tools = [
152 ReadTool(workspace_dir=workspace_dir),
153 WriteTool(workspace_dir=workspace_dir),
154 BashTool(),
155 ]
156
157 # Create agent
158 agent = Agent(
159 llm_client=llm_client,
160 system_prompt=system_prompt,
161 tools=tools,
162 max_steps=10,
163 workspace_dir=workspace_dir,
164 )
165
166 # Task: Use bash to get system info
167 task = """
168 Use bash commands to:
169 1. Show the current date and time
170 2. List all Python files in the current directory
171 3. Count how many Python files exist
172 """

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