()
| 52 | |
| 53 | |
| 54 | async def main(): |
| 55 | args = parse_args() |
| 56 | |
| 57 | config.initialize(config_path=args.config, args=args) |
| 58 | logger.initialize(config=config) |
| 59 | logger.info(f"| Config: {config.pretty_text}") |
| 60 | |
| 61 | # Initialize model manager |
| 62 | logger.info("| 🧠 Initializing model manager...") |
| 63 | await model_manager.initialize() |
| 64 | logger.info(f"| ✅ Model manager initialized: {await model_manager.list()}") |
| 65 | |
| 66 | # Initialize prompt manager |
| 67 | logger.info("| 📁 Initializing prompt manager...") |
| 68 | await prompt_manager.initialize() |
| 69 | logger.info(f"| ✅ Prompt manager initialized: {await prompt_manager.list()}") |
| 70 | |
| 71 | # Initialize memory manager |
| 72 | logger.info("| 📁 Initializing memory manager...") |
| 73 | await memory_manager.initialize(memory_names=config.memory_names) |
| 74 | logger.info(f"| ✅ Memory manager initialized: {await memory_manager.list()}") |
| 75 | |
| 76 | # Initialize tools |
| 77 | logger.info("| 🛠️ Initializing tools...") |
| 78 | await tcp.initialize(tool_names=config.tool_names) |
| 79 | logger.info(f"| ✅ Tools initialized: {await tcp.list()}") |
| 80 | |
| 81 | # Initialize environments |
| 82 | logger.info("| 🎮 Initializing environments...") |
| 83 | await ecp.initialize(env_names=config.env_names) |
| 84 | logger.info(f"| ✅ Environments initialized: {ecp.list()}") |
| 85 | |
| 86 | # Initialize agents |
| 87 | logger.info("| 🤖 Initializing agents...") |
| 88 | await acp.initialize(agent_names=config.agent_names) |
| 89 | logger.info(f"| ✅ Agents initialized: {await acp.list()}") |
| 90 | |
| 91 | # Initialize version manager, must after tool, agent, environment initialized |
| 92 | logger.info("| 📁 Initializing version manager...") |
| 93 | await version_manager.initialize() |
| 94 | logger.info(f"| ✅ Version manager initialized") |
| 95 | |
| 96 | # Get the agent instance; use the synchronous get_info() helper to access AgentInfo and then use .instance. |
| 97 | agent = await acp.get("tool_calling") |
| 98 | |
| 99 | # Example task; replace with the task you want to optimize. |
| 100 | task = "Solve the equation x^2 + 2x - 3 = 0 with detailed steps and optimize the solution." |
| 101 | files = [] |
| 102 | |
| 103 | logger.info(f"| 📋 Task: {task}") |
| 104 | logger.info(f"| 📂 Files: {files}") |
| 105 | logger.info(f"| 🤖 Using Reflection optimization method") |
| 106 | logger.info(f"| 💡 Reflection optimizer uses the agent's own model for reflection and improvement") |
| 107 | |
| 108 | # Run the agent with Reflection optimization. |
| 109 | # Note: the Reflection optimizer relies on the agent's own model for reflection, so no extra optimizer_model is required. |
| 110 | optimizer = ReflectionOptimizer( |
| 111 | workdir=config.workdir, |
no test coverage detected