Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧬 DGM Self-Improving Agent Prototype

An autonomous evolutionary framework for LLM-based agents. Inspired by the Darwin Gödel Machine (DGM) research, this prototype demonstrates how an agent can recursively improve its own source code to survive an increasingly complex benchmark environment.


🏗️ System Architecture

The core of the system is a Recursive Meta-Evolution Loop. Unlike static agents, DGM treats its own source code as its "DNA" and uses an LLM as a genetic engineer to patch itself based on empirical failure.

🔄 The DGM Loop

graph TD
    A[Seed DNA: src/agents/seed_agent.py] --> B[Evaluation: Local Sandbox]
    B --> C{Fitness Test: problems.json}
    C -->|Failure Logs| D[Mutator: GPT-4o]
    D --> E[Propose New DNA: New Source Code]
    E --> B
    C -->|100% Success| F[Champion: winner_agent.py]
Loading

🧠 Core Components:

  • The DNA: Source code found in src/agents/seed_agent.py. It starts as a "low-intelligence" organism.
  • The Laboratory (Local Environment): Evaluation happens in isolated temporary directories. This ensures that mutated code doesn't interfere with your host system while maintaining high-speed testing.
  • The Mutator: Uses GPT-4o as a "Recursive Coder" that receives the current code and the exact failure logs from the laboratory.
  • The Fitness Function: A rigorous 30-case benchmark testing high-level algorithmic logic, math, and data structures.

📊 Analysis & Results

This project focuses on Empirical Proof. We generate high-fidelity visualizations and cross-model comparisons to validate the intelligence jump.

1. Evolution Dashboard

After running the evolution, generate the research-grade dashboard:

uv run python visualizer.py

Reference Files:

  • outputs/dgm_dashboard.png: A 4-panel analysis including:
    • Fig 1: Population Fitness Trace: Scatter plot of every agent ever created vs. the optimization frontier.
    • Fig 2: Capability Breakthroughs: Heatmap tracking which logic domains (Math, Logic, String) were mastered at which evolution step.
    • Fig 3: Phylogeny Tree: A linked graph showing how the winner evolved from the seed through specific parent-child mutations.
    • Fig 4: Champion Task Matrix: Green/Red breakdown of all 30 specific tasks passed by the final winner.

2. Scientific Comparison (DGM vs. Single-Shot LLM)

To prove that evolution is necessary, we pit the "Winner" against a one-shot LLM generation:

uv run python comparison.py

Reference Files:

  • outputs/comparison_results.png: Comparison bar chart showing the performance gap.
  • outputs/comparison_data.json: An audit trail containing the entire conversation log, questions, and raw responses from both models for review.

🧪 Quick Start Guide

1. Installation

Ensure you have uv installed and your OPENAI_API_KEY in the .env file.

uv venv
source .venv/bin/activate
uv pip install -e .

2. Reset Ecosystem

Prepare for a fresh evolution experiment:

rm src/agents/winner_agent.py src/agents/history/* outputs/*

3. Start Evolution

uv run python main.py

4. Review Raw Data

For deep technical review, all lineages and logs are stored in:

  • outputs/evolution_data.json: The complete family tree and logs for every agent generated.
  • src/agents/history/: Snapshots of the "Worst" and "Intermediate" agents for code comparison.

🔬 Benchmark Scope

The agent is tested on 30 tasks including:

  • Mathematical: GCD, LCM, Collatz Steps, Pascal's Triangle, Armstrong Numbers.
  • Algorithmic: Matrix Transpose, Binary Search, Balanced Brackets, LRU Cache simulation.
  • String Logic: Caesar Cipher, Run-Length Encoding, Word Frequency analysis.

About

An autonomous evolutionary framework for LLM-based agents. Inspired by the **Darwin Gödel Machine (DGM)

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages