Skip to main content

A self-improving agent framework built on LangChain and LangGraph

Project description

HyperFlow (Python)

Self-improving agent framework powered by LangChain and LangGraph.

Inspired by HyperAgents (Meta Research, 2026) -- ported to Python with a generic, pluggable architecture.

What it does

HyperAgents runs an evolutionary self-improvement loop where a MetaAgent rewrites a TaskAgent's code to make it better at solving tasks. Each generation:

  1. Select a parent agent from the archive
  2. MetaAgent reads past evaluation scores and edits the source code
  3. The modified TaskAgent is evaluated on domain tasks
  4. Score + code diff are saved to the archive
  5. Repeat

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

# 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hyperflow_ai-1.0.0.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hyperflow_ai-1.0.0-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

File details

Details for the file hyperflow_ai-1.0.0.tar.gz.

File metadata

  • Download URL: hyperflow_ai-1.0.0.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for hyperflow_ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 405077373388004ff5ccf773e7bd3f730d83d9cec6f8b2c0bfb57e92772ff6d4
MD5 7526a0ec2c9c42328aac9e55c891ac1c
BLAKE2b-256 8977dcca6d0ba7350ff987f12a3e785a279a24086c61471f1cd0c878489703b8

See more details on using hashes here.

File details

Details for the file hyperflow_ai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: hyperflow_ai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 39.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for hyperflow_ai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 958af1c77e795bf27627588cd9165b665578e534abeaaef735e94aad2b8608a3
MD5 5658763215dc05a3197f48e545c7f54d
BLAKE2b-256 9acb5f7c14e39e9f6f13ee472cfa87d87a35fb79fbae2b7665a2e1bdebf164e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page