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

Function run_agent

mini_agent/cli.py:486–841  ·  view source on GitHub ↗

Run Agent in interactive or non-interactive mode. Args: workspace_dir: Workspace directory path task: If provided, execute this task and exit (non-interactive mode)

(workspace_dir: Path, task: str = None)

Source from the content-addressed store, hash-verified

484
485
486async def run_agent(workspace_dir: Path, task: str = None):
487 """Run Agent in interactive or non-interactive mode.
488
489 Args:
490 workspace_dir: Workspace directory path
491 task: If provided, execute this task and exit (non-interactive mode)
492 """
493 session_start = datetime.now()
494
495 # 1. Load configuration from package directory
496 config_path = Config.get_default_config_path()
497
498 if not config_path.exists():
499 print(f"{Colors.RED}❌ Configuration file not found{Colors.RESET}")
500 print()
501 print(f"{Colors.BRIGHT_CYAN}📦 Configuration Search Path:{Colors.RESET}")
502 print(f" {Colors.DIM}1) mini_agent/config/config.yaml{Colors.RESET} (development)")
503 print(f" {Colors.DIM}2) ~/.mini-agent/config/config.yaml{Colors.RESET} (user)")
504 print(f" {Colors.DIM}3) <package>/config/config.yaml{Colors.RESET} (installed)")
505 print()
506 print(f"{Colors.BRIGHT_YELLOW}🚀 Quick Setup (Recommended):{Colors.RESET}")
507 print(
508 f" {Colors.BRIGHT_GREEN}curl -fsSL https://raw.githubusercontent.com/MiniMax-AI/Mini-Agent/main/scripts/setup-config.sh | bash{Colors.RESET}"
509 )
510 print()
511 print(f"{Colors.DIM} This will automatically:{Colors.RESET}")
512 print(f"{Colors.DIM} • Create ~/.mini-agent/config/{Colors.RESET}")
513 print(f"{Colors.DIM} • Download configuration files{Colors.RESET}")
514 print(f"{Colors.DIM} • Guide you to add your API Key{Colors.RESET}")
515 print()
516 print(f"{Colors.BRIGHT_YELLOW}📝 Manual Setup:{Colors.RESET}")
517 user_config_dir = Path.home() / ".mini-agent" / "config"
518 example_config = Config.get_package_dir() / "config" / "config-example.yaml"
519 print(f" {Colors.DIM}mkdir -p {user_config_dir}{Colors.RESET}")
520 print(f" {Colors.DIM}cp {example_config} {user_config_dir}/config.yaml{Colors.RESET}")
521 print(f" {Colors.DIM}# Then edit {user_config_dir}/config.yaml to add your API Key{Colors.RESET}")
522 print()
523 return
524
525 try:
526 config = Config.from_yaml(config_path)
527 except FileNotFoundError:
528 print(f"{Colors.RED}❌ Error: Configuration file not found: {config_path}{Colors.RESET}")
529 return
530 except ValueError as e:
531 print(f"{Colors.RED}❌ Error: {e}{Colors.RESET}")
532 print(f"{Colors.YELLOW}Please check the configuration file format{Colors.RESET}")
533 return
534 except Exception as e:
535 print(f"{Colors.RED}❌ Error: Failed to load configuration file: {e}{Colors.RESET}")
536 return
537
538 # 2. Initialize LLM client
539 from mini_agent.retry import RetryConfig as RetryConfigBase
540
541 # Convert configuration format
542 retry_config = RetryConfigBase(
543 enabled=config.llm.retry.enabled,

Callers 1

mainFunction · 0.85

Calls 15

add_user_messageMethod · 0.95
runMethod · 0.95
LLMClientClass · 0.90
AgentClass · 0.90
initialize_base_toolsFunction · 0.85
add_workspace_toolsFunction · 0.85
print_bannerFunction · 0.85
print_session_infoFunction · 0.85
print_statsFunction · 0.85
_quiet_cleanupFunction · 0.85
print_helpFunction · 0.85
show_log_directoryFunction · 0.85

Tested by

no test coverage detected