Maestro is an AI-assisted task decomposition and execution workflow framework. It uses the Anthropic API to call two AI models (Opus and Haiku) to work together: first Opus breaks down the goal into manageable subtasks, then Haiku executes them one by one, and finally the results are refined into a coherent final output. The project has been updated to support Claude 3.5 Sonnet and can be used with any API, including Anthropic, Gemini, OpenAI, Cohere, etc. Thanks to the rewrite of the codebase using LiteLLM, choosing models has become easier.
Main capabilities
- Use the Opus model to break down the goal into manageable subtasks.
- Use the Haiku model to execute each subtask.
- Provide the Haiku model with the memory of previous subtasks as context.
- Use the Opus model to refine the subtask results into the final output.
- Generate detailed exchange logs, recording the entire task decomposition and execution process.
- Save the exchange logs as Markdown files for easy reference.
- Use improved prompts for the Opus model to better evaluate task completion.
- Create code files and folders when working on code projects.
Usage Set the API keys in the script, for example: os.environ["OPENAI_API_KEY"] = "YOUR KEY" os.environ["ANTHROPIC_API_KEY"] = "YOUR KEY" os.environ["GEMINI_API_KEY"] = "YOUR KEY" and configure the models, for example: ORCHESTRATOR_MODEL = "gemini/gemini-1.5-flash-latest" SUB_AGENT_MODEL = "gemini/gemini-1.5-flash-latest" REFINER_MODEL = "gemini/gemini-1.5-flash-latest" You can also use gpt-3.5-turbo, etc.
Before running, dependencies need to be installed. First install litellm, and after installation is complete, run the script. If using the search function, you need to replace the Tavily API key (available from https://tavily.com/ ).
Running locally: can be used with LMStudio or Ollama. When using LMStudio, first download the application from https://lmstudio.ai/ , then run the local server in your preferred way; it is recommended to remove the system prompt in the application (leave the prompt field blank) so that the script's own prompt takes effect. When using Ollama, first from https://ollama.com/download Install the client, then pull the models, for example: ollama.pull('llama3:70b') ollama.pull('llama3:8b') It can be customized according to the required models; usually it only needs to be run once, or the models can be updated when a new version is released.
Requirements
- Python is installed.
- Anthropic API key.
- Required Python packages: anthropic and rich.
Run process Clone the repository or download the script file; install the required Python packages; replace the placeholder API key in the script with the actual key; if using search, replace the Tavily API; open a terminal or command prompt, navigate to the directory where the script is located; run the script; enter the objective when prompted. The script will begin the task decomposition and execution process, and display progress and results in the console through formatted panels. When complete, the script will display the refined final output and save the full exchange log as a Markdown file named after the objective.
Main functions
- opus_orchestrator(objective, previous_results=None): calls the Opus model to break the objective down into subtasks or provide the final output. It uses an improved prompt to evaluate task completion and includes the phrase "The task is complete:" when the objective is fully achieved.
- haiku_sub_agent(prompt, previous_haiku_tasks=None): calls the Haiku model to execute a subtask prompt and provides memory of previous subtasks.
- opus_refine(objective, sub_task_results): calls the Opus model to review and refine the subtask results into a coherent final output.
The script uses an iterative process, repeatedly calling the opus_orchestrator function to break the objective down into subtasks until it provides the final output. Each subtask is then executed by the haiku_sub_agent function, and the results are stored in the task_exchanges and haiku_tasks lists. When the Opus model includes "The task is complete:" in its response, the loop terminates, indicating that the objective has been fully achieved. Finally, the opus_refine function is called to review and refine the subtask results. The entire exchange log (including the objective, task decompositionand the refined final output) is saved to a Markdown file.
Customizable items
- Adjust the max_tokens parameter in the client.messages.create() call to control the maximum number of tokens generated by the AI model.
- Change models, for example replacing Haiku with Sonnet or Opus.
- Adjust the console output format by modifying the Panel and Console configuration of the rich library.
- Modify the relevant code sections to customize the exchange log format and file extension.
Other supported features
- Supports Groq, making use of its ultra-fast API responses.
- When creating subtask agents, Claude Opus performs searches to provide the subtask agents with the best answer references.
- Supports using GPT-4 as the orchestrator in maestro-gpt.py.
License This project is released under the MIT License.
Acknowledgments Thanks to Anthropic for providing the AI models and API; thanks to Rich for providing beautiful console formatting.