A self-improving agent framework built on LangChain and LangGraph
Project description
HyperFlow (Python)
⚠️ EXPERIMENTAL: This project is currently in an experimental phase and is not recommended for production use.
Self-improving agent framework powered by LangChain and LangGraph.
Inspired by HyperAgents (Meta Research, 2026).
What it does
HyperFlow runs an evolutionary self-improvement loop where a MetaAgent rewrites its own source code (including prompts, tools, and logic) to make it better at solving tasks. It is self-referential: the mechanism that improves the agent is itself part of the editable code. Each generation:
- Select a parent generation from the archive
- MetaAgent reads past evaluation scores and edits the source code
- Evaluation scripts run in a sandbox to score the new agent
- Better agents are added back to the archive for future generations
[!IMPORTANT] This framework is currently in an Experimental state. See Limitations for more information.
The TaskAgent gets better over generations without manual intervention.
New here? Read docs/concepts.md for a detailed explanation of every concept with examples.
Installation
# Install from PyPI
pip install hyperflow-ai
# Or install from source for development
pip install -e .
Requirements
- Python 3.11+
- At least one LLM provider API key (e.g.
OPENAI_API_KEY,ANTHROPIC_API_KEY)
Quick Start
# Set your API key
export OPENAI_API_KEY="sk-..."
# Run the bash example (single eval)
cd examples/bash
python run.py
# Run with evolutionary loop
python run.py evolve
Project Structure
hyperflow/
__init__.py # Public API re-exports
agent/
base_agent.py # Abstract AgentSystem base class
llm.py # Multi-provider LLM factory
llm_with_tools.py # LangGraph ReAct chat loop
meta_agent.py # MetaAgent (mutation operator)
task_agent.py # TaskAgent (task solver)
tool_registry.py # Tool registration
core/
ensemble.py # Best-of-archive ensemble
generate_loop.py # Main evolutionary loop
select_parent.py # Parent selection strategies
domains/
base.py # Domain/DomainTask/EvalResult interfaces
evaluators.py # Static, LLM judge, human evaluators
harness.py # Evaluation harness
report.py # Report generation
prompts/
llm_judge.py # LLM judge prompt template
meta_agent.py # MetaAgent prompt template
task_agent.py # TaskAgent prompt template
tools/
__init__.py # get_framework_tools()
bash.py # Bash shell tool
editor.py # File editor tool
utils/
archive.py # JSONL archive CRUD
common.py # JSON extraction, file helpers
constants.py # Shared constants
docker.py # Docker container management
executor.py # Local/Docker execution
git.py # Git operations
examples/
bash/ # Bash command generation
calculator/ # Buggy tool fix demo
factcheck/ # True/false classification
git_evolution/ # Git-based evolution with patches
paper_review/ # Paper accept/reject prediction
scoring/ # Math grading self-improvement
Supported Models
from hyperflow import MODELS
# Available model presets
MODELS["OPENAI_GPT4O"] # "openai/gpt-4o"
MODELS["OPENAI_GPT4O_MINI"] # "openai/gpt-4o-mini"
MODELS["OPENAI_O3"] # "openai/o3"
MODELS["OPENAI_O4_MINI"] # "openai/o4-mini"
MODELS["CLAUDE_SONNET"] # "anthropic/claude-sonnet-4-5-20250929"
MODELS["GEMINI_PRO"] # "gemini/gemini-2.5-pro"
MODELS["OLLAMA_LLAMA3"] # "ollama/llama3"
Or use any "provider/model-name" string.
Environment Variables
| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key |
ANTHROPIC_API_KEY |
Anthropic API key |
GOOGLE_API_KEY |
Google Gemini API key |
OLLAMA_BASE_URL |
Ollama server URL (default: http://localhost:11434) |
HYPERFLOW_MODEL |
Default model for examples (e.g. openai/gpt-4o) |
Examples
Single Evaluation
cd examples/bash && python run.py
cd examples/factcheck && python run.py
cd examples/paper_review && python run.py
Evolutionary Self-Improvement
cd examples/bash && python run.py evolve
cd examples/factcheck && python run.py evolve
cd examples/scoring && python run.py
cd examples/calculator && python run.py
cd examples/git_evolution && python run.py
Git-Based Evolution (with patches)
cd examples/git_evolution && python run.py # 2 generations
cd examples/git_evolution && python run.py 5 # 5 generations
cd examples/git_evolution && python run.py --reset # start over
License
MIT
Citation
If you use this framework in your research, please cite the original HyperAgents paper:
@misc{zhang2026hyperagents,
title={Hyperagents},
author={Jenny Zhang and Bingchen Zhao and Wannan Yang and Jakob Foerster and Jeff Clune and Minqi Jiang and Sam Devlin and Tatiana Shavrina},
year={2026},
eprint={2603.19461},
archivePrefix={arXiv},
primaryClass={cs.AI},
url={https://arxiv.org/abs/2603.19461},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hyperflow_ai-1.1.0.tar.gz.
File metadata
- Download URL: hyperflow_ai-1.1.0.tar.gz
- Upload date:
- Size: 32.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0927292216ce966c724ee6034de318589a4f7014c92b8100265a37b124fd02d0
|
|
| MD5 |
92281fd252bce8e066eb2fb5c0229e04
|
|
| BLAKE2b-256 |
3fb60eb0f16355fc7f8e55615b2a96857c750e6afb88b357ad214580f5dc0356
|
File details
Details for the file hyperflow_ai-1.1.0-py3-none-any.whl.
File metadata
- Download URL: hyperflow_ai-1.1.0-py3-none-any.whl
- Upload date:
- Size: 40.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ece23e657b7125752ef85381d5f419afad46a0c6cc2baf286e61f998dc3fd56e
|
|
| MD5 |
da104de5f264184b16b088edd24a29f4
|
|
| BLAKE2b-256 |
bf1115c1cfdef1b4af3a6862935ccbc07c47ddba41fc8ea23f752aec379642b7
|