OpenAlpha_Evolve is an open-source Python framework inspired by the groundbreaking research on autonomous coding agents like DeepMind's AlphaEvolve.
Python
1,054
73 commits
updated May 31, 2025
OpenAlpha_Evolve is an open-source Python framework inspired by the groundbreaking research on autonomous coding agents like DeepMind's AlphaEvolve. It's a regeneration of the core idea: an intelligent system that iteratively writes, tests, and improves code using Large Language Models (LLMs) via LiteLLM, guided by the principles of evolution.
Our mission is to provide an accessible, understandable, and extensible platform for researchers, developers, and enthusiasts to explore the fascinating intersection of AI, code generation, and automated problem-solving.
Imagine an agent that can:
OpenAlpha_Evolve is a step towards this vision. It's not just about generating code; it's about creating a system that discovers and refines solutions autonomously.
OpenAlpha_Evolve employs a modular, agent-based architecture to orchestrate an evolutionary process:
PromptDesignerAgent): This agent crafts intelligent prompts for the LLM. It designs:
CodeGeneratorAgent): Powered by an LLM (currently configured for Gemini), this agent takes the prompts and generates Python code. If a "diff" is requested and received, it attempts to apply the changes to the parent code.EvaluatorAgent): The generated code is put to the test!
DatabaseAgent): All programs (code, fitness scores, generation, lineage) are stored, creating a record of the evolutionary history (currently in-memory).SelectionControllerAgent): The "survival of the fittest" principle in action. This agent selects:
TaskManagerAgent): The maestro of the operation, coordinating all other agents and managing the overall evolutionary loop.config/settings.py and .env../
โโโ code_generator/ # Agent responsible for generating code using LLMs.
โโโ database_agent/ # Agent for managing the storage and retrieval of programs and their metadata.
โโโ evaluator_agent/ # Agent that evaluates the generated code for syntax, execution, and fitness.
โโโ prompt_designer/ # Agent that crafts prompts for the LLM for initial generation, mutation, and bug fixing.
โโโ selection_controller/ # Agent that implements the selection strategy for parent and survivor programs.
โโโ task_manager/ # Agent that orchestrates the overall evolutionary loop and coordinates other agents.
โโโ config/ # Holds configuration files, primarily `settings.py` for system parameters and API keys.
โโโ core/ # Defines core data structures and interfaces, like `Program` and `TaskDefinition`.
โโโ tests/ # Includes unit and integration tests to ensure code quality and correctness.
โโโ main.py # The main entry point to run the OpenAlpha_Evolve system and start an evolutionary run.
โโโ requirements.txt # Lists all Python package dependencies required to run the project.
โโโ .env.example # An example file showing the environment variables needed, such as API keys. Copy this to `.env` and fill in your values.
โโโ .gitignore # Specifies intentionally untracked files that Git should ignore (e.g., `.env`, `__pycache__/`).
โโโ LICENSE.md # Contains the full text of the MIT License under which the project is distributed.
โโโ README.md # This file! Provides an overview of the project, setup instructions, and documentation.
Prerequisites:
pip for package managementgit for cloningClone the Repository:
git clone https://github.com/shyamsaktawat/OpenAlpha_Evolve.git
cd OpenAlpha_Evolve
Set Up a Virtual Environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install Dependencies:
pip install -r requirements.txt
Set Up Environment Variables (Crucial for API Keys):
.env file stores your sensitive credentials and configuration, overriding the default placeholders in config/settings.py.cp .env_example .env
Google Cloud authentication (e.g., via Application Default Credentials (ADC) or service account keys pointed to by GOOGLE_APPLICATION_CREDENTIALS) is a supported method for using Google's LLMs.
To set up your environment variables for Google Cloud, you can use one of the following methods. These should be added to your .env file:
# For Google Cloud (Vertex AI / AI Studio)
# Option 1: Using Application Default Credentials (ADC)
# Ensure you have authenticated via gcloud CLI:
# gcloud auth application-default login
# Or set the GOOGLE_APPLICATION_CREDENTIALS environment variable:
# GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-key.json"
# Option 2: Directly using an API Key for specific Google services (e.g., Gemini API)
# GEMINI_API_KEY="your_gemini_api_key"
This project uses LiteLLM to interface with various LLM providers. For providers other than Google Cloud (e.g., OpenAI, Anthropic, Cohere), please refer to the LiteLLM documentation for the specific environment variables required. Common examples include:
# OPENAI_API_KEY="your_openai_api_key"
# ANTHROPIC_API_KEY="your_anthropic_api_key"
# COHERE_API_KEY="your_cohere_api_key"
Add the necessary API key variables for your chosen LLM provider(s) to your .env file.
Run OpenAlpha_Evolve! Run the example task (Dijkstra's algorithm) with:
python -m main examples/shortest_path.yaml
Watch the logs in your terminal to see the evolutionary process unfold! Log files are also saved to alpha_evolve.log (by default).
Launch the Gradio Web Interface Interact with the system via the web UI. To start the Gradio app:
python app.py
Gradio will display a local URL (e.g., http://127.0.0.1:7860) and a public share link if enabled. Open this in your browser to define custom tasks and run the evolution process interactively.
Want to challenge OpenAlpha_Evolve with a new problem? It's easy! You can define your tasks in two ways:
Create a YAML file in the examples directory with the following structure:
task_id: "your_task_id"
task_description: |
Your detailed problem description here.
Be specific about function names, expected behavior, and constraints.
function_name: "your_function_name"
allowed_imports: ["module1", "module2"]
tests:
- description: "Test group description" # Describes a group of related tests
name: "Test group name" # A name for this test group
test_cases: # This should be a list of individual test cases
- input: [arg1, arg2] # First test case
output: expected_output # Expected result for this input
# Each test case uses either 'output' for direct comparison
# or 'validation_func' for more complex validation.
- input: [arg_for_validation_func_1, arg_for_validation_func_2] # Second test case
validation_func: |
def validate(output_from_function):
# Custom validation logic for this specific test case's output
# For example, check if output is within a certain range,
# or if it has specific properties.
return isinstance(output_from_function, bool) and output_from_function is True
See the example in examples/shortest_path.yaml
You can still define tasks programmatically using the TaskDefinition class:
from core.task_definition import TaskDefinition
task = TaskDefinition(
id="your_task_id",
description="Your detailed problem description",
function_name_to_evolve="your_function_name",
input_output_examples=[
{"input": [arg1, arg2], "output": expected_output},
# More examples...
],
allowed_imports=["module1", "module2"]
)
Crafting effective task definitions is key to guiding OpenAlpha_Evolve successfully. Consider these tips:
This is an open invitation to collaborate! Whether you're an AI researcher, a Python developer, or simply an enthusiast, your contributions are welcome.
git checkout -b feature/your-feature-name).Let's evolve this agent together!
This project is licensed under the MIT License. See the LICENSE.md file for details.
OpenAlpha_Evolve is proudly inspired by the pioneering work of the Google DeepMind team on AlphaEvolve and other related research in LLM-driven code generation and automated discovery. This project aims to make the core concepts more accessible for broader experimentation and learning. We stand on the shoulders of giants.
Disclaimer: This is an experimental project. Generated code may not always be optimal, correct, or secure. Always review and test code thoroughly, especially before using it in production environments.
151 followers ยท starred May 2025
513 followers ยท starred Jan 2026
208 followers ยท starred Jul 2026
3,001 followers ยท starred May 2025
OpenAlpha_Evolve is an open-source Python framework inspired by the groundbreaking research on autonomous coding agents like DeepMind's AlphaEvolve.
Python
1,054
73 commits
updated May 31, 2025
OpenAlpha_Evolve is an open-source Python framework inspired by the groundbreaking research on autonomous coding agents like DeepMind's AlphaEvolve. It's a regeneration of the core idea: an intelligent system that iteratively writes, tests, and improves code using Large Language Models (LLMs) via LiteLLM, guided by the principles of evolution.
Our mission is to provide an accessible, understandable, and extensible platform for researchers, developers, and enthusiasts to explore the fascinating intersection of AI, code generation, and automated problem-solving.
Imagine an agent that can:
OpenAlpha_Evolve is a step towards this vision. It's not just about generating code; it's about creating a system that discovers and refines solutions autonomously.
OpenAlpha_Evolve employs a modular, agent-based architecture to orchestrate an evolutionary process:
PromptDesignerAgent): This agent crafts intelligent prompts for the LLM. It designs:
CodeGeneratorAgent): Powered by an LLM (currently configured for Gemini), this agent takes the prompts and generates Python code. If a "diff" is requested and received, it attempts to apply the changes to the parent code.EvaluatorAgent): The generated code is put to the test!
DatabaseAgent): All programs (code, fitness scores, generation, lineage) are stored, creating a record of the evolutionary history (currently in-memory).SelectionControllerAgent): The "survival of the fittest" principle in action. This agent selects:
TaskManagerAgent): The maestro of the operation, coordinating all other agents and managing the overall evolutionary loop.config/settings.py and .env../
โโโ code_generator/ # Agent responsible for generating code using LLMs.
โโโ database_agent/ # Agent for managing the storage and retrieval of programs and their metadata.
โโโ evaluator_agent/ # Agent that evaluates the generated code for syntax, execution, and fitness.
โโโ prompt_designer/ # Agent that crafts prompts for the LLM for initial generation, mutation, and bug fixing.
โโโ selection_controller/ # Agent that implements the selection strategy for parent and survivor programs.
โโโ task_manager/ # Agent that orchestrates the overall evolutionary loop and coordinates other agents.
โโโ config/ # Holds configuration files, primarily `settings.py` for system parameters and API keys.
โโโ core/ # Defines core data structures and interfaces, like `Program` and `TaskDefinition`.
โโโ tests/ # Includes unit and integration tests to ensure code quality and correctness.
โโโ main.py # The main entry point to run the OpenAlpha_Evolve system and start an evolutionary run.
โโโ requirements.txt # Lists all Python package dependencies required to run the project.
โโโ .env.example # An example file showing the environment variables needed, such as API keys. Copy this to `.env` and fill in your values.
โโโ .gitignore # Specifies intentionally untracked files that Git should ignore (e.g., `.env`, `__pycache__/`).
โโโ LICENSE.md # Contains the full text of the MIT License under which the project is distributed.
โโโ README.md # This file! Provides an overview of the project, setup instructions, and documentation.
Prerequisites:
pip for package managementgit for cloningClone the Repository:
git clone https://github.com/shyamsaktawat/OpenAlpha_Evolve.git
cd OpenAlpha_Evolve
Set Up a Virtual Environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install Dependencies:
pip install -r requirements.txt
Set Up Environment Variables (Crucial for API Keys):
.env file stores your sensitive credentials and configuration, overriding the default placeholders in config/settings.py.cp .env_example .env
Google Cloud authentication (e.g., via Application Default Credentials (ADC) or service account keys pointed to by GOOGLE_APPLICATION_CREDENTIALS) is a supported method for using Google's LLMs.
To set up your environment variables for Google Cloud, you can use one of the following methods. These should be added to your .env file:
# For Google Cloud (Vertex AI / AI Studio)
# Option 1: Using Application Default Credentials (ADC)
# Ensure you have authenticated via gcloud CLI:
# gcloud auth application-default login
# Or set the GOOGLE_APPLICATION_CREDENTIALS environment variable:
# GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-key.json"
# Option 2: Directly using an API Key for specific Google services (e.g., Gemini API)
# GEMINI_API_KEY="your_gemini_api_key"
This project uses LiteLLM to interface with various LLM providers. For providers other than Google Cloud (e.g., OpenAI, Anthropic, Cohere), please refer to the LiteLLM documentation for the specific environment variables required. Common examples include:
# OPENAI_API_KEY="your_openai_api_key"
# ANTHROPIC_API_KEY="your_anthropic_api_key"
# COHERE_API_KEY="your_cohere_api_key"
Add the necessary API key variables for your chosen LLM provider(s) to your .env file.
Run OpenAlpha_Evolve! Run the example task (Dijkstra's algorithm) with:
python -m main examples/shortest_path.yaml
Watch the logs in your terminal to see the evolutionary process unfold! Log files are also saved to alpha_evolve.log (by default).
Launch the Gradio Web Interface Interact with the system via the web UI. To start the Gradio app:
python app.py
Gradio will display a local URL (e.g., http://127.0.0.1:7860) and a public share link if enabled. Open this in your browser to define custom tasks and run the evolution process interactively.
Want to challenge OpenAlpha_Evolve with a new problem? It's easy! You can define your tasks in two ways:
Create a YAML file in the examples directory with the following structure:
task_id: "your_task_id"
task_description: |
Your detailed problem description here.
Be specific about function names, expected behavior, and constraints.
function_name: "your_function_name"
allowed_imports: ["module1", "module2"]
tests:
- description: "Test group description" # Describes a group of related tests
name: "Test group name" # A name for this test group
test_cases: # This should be a list of individual test cases
- input: [arg1, arg2] # First test case
output: expected_output # Expected result for this input
# Each test case uses either 'output' for direct comparison
# or 'validation_func' for more complex validation.
- input: [arg_for_validation_func_1, arg_for_validation_func_2] # Second test case
validation_func: |
def validate(output_from_function):
# Custom validation logic for this specific test case's output
# For example, check if output is within a certain range,
# or if it has specific properties.
return isinstance(output_from_function, bool) and output_from_function is True
See the example in examples/shortest_path.yaml
You can still define tasks programmatically using the TaskDefinition class:
from core.task_definition import TaskDefinition
task = TaskDefinition(
id="your_task_id",
description="Your detailed problem description",
function_name_to_evolve="your_function_name",
input_output_examples=[
{"input": [arg1, arg2], "output": expected_output},
# More examples...
],
allowed_imports=["module1", "module2"]
)
Crafting effective task definitions is key to guiding OpenAlpha_Evolve successfully. Consider these tips:
This is an open invitation to collaborate! Whether you're an AI researcher, a Python developer, or simply an enthusiast, your contributions are welcome.
git checkout -b feature/your-feature-name).Let's evolve this agent together!
This project is licensed under the MIT License. See the LICENSE.md file for details.
OpenAlpha_Evolve is proudly inspired by the pioneering work of the Google DeepMind team on AlphaEvolve and other related research in LLM-driven code generation and automated discovery. This project aims to make the core concepts more accessible for broader experimentation and learning. We stand on the shoulders of giants.
Disclaimer: This is an experimental project. Generated code may not always be optimal, correct, or secure. Always review and test code thoroughly, especially before using it in production environments.
151 followers ยท starred May 2025
513 followers ยท starred Jan 2026
208 followers ยท starred Jul 2026
3,001 followers ยท starred May 2025