Autonomous experiment platform for iterative LLM agent optimization
Project description
autocrucible
繁體中文 | English
A general-purpose autonomous experiment platform. Define what to edit, how to run, and what to measure — then let an LLM agent iterate indefinitely to optimize your metric.
Prerequisites
- Python 3.10+
- uv — Python package manager
# macOS / Linux curl -LsSf https://astral.sh/uv/install.sh | sh # or via Homebrew brew install uv
- Git — the platform uses git for version control of experiments
- Claude Code — the
claudeCLI must be installed and authenticated# Install npm install -g @anthropic-ai/claude-code # Authenticate (follow the prompts) claude
Install
# Install as a global CLI tool
uv tool install autocrucible
# Or install from a local clone
git clone https://github.com/suzuke/autocrucible.git
uv tool install ./crucible
Verify:
crucible --help
Updating
# From PyPI
uv tool install autocrucible --force
# From local source (after pulling changes)
uv tool install ./crucible --force
For development
git clone https://github.com/suzuke/autocrucible.git
cd crucible
uv sync # install in local .venv
uv run crucible --help # run from source
uv run pytest # run tests
Quick Start
# From example
crucible new ~/my-project -e optimize-sorting
cd ~/my-project
crucible run --tag run1
crucible run --tag run1 --max-iterations 5 # stop after 5 iterations
# Check results
crucible status --tag run1
crucible history --tag run1
crucible postmortem --tag run1
# Continue from best result
crucible run --tag run2
See crucible new . --list for all examples, or crucible wizard for AI-generated projects.
If your experiment needs third-party packages (numpy, torch, etc.), install them with uv sync in the project directory.
Validate before running
crucible validate
crucible validate --stability --runs 5 # check metric variance
Verbose logging
crucible -v run --tag run1 # debug-level output
How It Works
crucible run --tag run1
│
▼
┌─────────────────────────────────┐
│ 1. Assemble prompt │ instructions + history + state
│ 2. Claude Agent SDK │ agent reads/edits files
│ 3. Guard rails │ validate edits
│ 4. Git commit │ snapshot the change
│ 5. Run experiment │ python evaluate.py > run.log
│ 6. Parse metric │ grep '^metric:' run.log
│ 7. Keep or discard │ improved? keep : reset
│ 8. Loop │
└─────────────────────────────────┘
- Agent: Uses the Claude Agent SDK with a tool allowlist (Read, Edit, Write, Glob, Grep). The agent can read files, make targeted edits, and search the codebase — but cannot execute arbitrary commands.
- Environment: If your project has a
.venv/, crucible automatically activates it when running experiment commands, sopython3 evaluate.pyuses the correct interpreter and packages. - Git: Every attempt is committed. Improvements advance the branch; failures are tagged and reset, preserving the diff for analysis.
Examples
Bundled examples to get started quickly. Create a project from any example:
crucible new ~/my-project -e <example-name>
| Example | Metric | Direction | Description |
|---|---|---|---|
optimize-sorting |
ops_per_sec |
maximize | Pure Python sorting throughput optimization |
optimize-regression |
val_mse |
minimize | Synthetic regression with nonlinear interactions |
optimize-classifier |
val_accuracy |
maximize | Numpy-only neural network on 8-class dataset |
optimize-compress |
compression_ratio |
maximize | Lossless text compression (no zlib/gzip allowed) |
optimize-gomoku |
win_rate |
maximize | AlphaZero-style Gomoku agent training |
optimize-snake |
avg_score |
maximize | Snake AI heuristic search (no dependencies) |
Demo: optimize-compress
A showcase example where the agent builds a lossless text compressor from scratch:
crucible new ~/compress -e optimize-compress
cd ~/compress
crucible run --tag run1
Starting from a baseline RLE compressor (0.51x — worse than no compression), the agent typically:
- Iter 1: Implements LZ77 + Huffman → ~2.63x
- Iter 2: Adds optimal parsing DP + symbol remapping → ~2.81x (beats zlib's 2.65x)
- Iter 3+: Context modeling, arithmetic coding → 3.0x+
Project Structure
my-experiment/
├── .crucible/
│ ├── config.yaml # What to optimize, how to run, what to measure
│ └── program.md # Instructions for the LLM agent
├── solution.py # Code the agent modifies (editable)
├── evaluate.py # Fixed harness that measures the metric (hidden)
├── pyproject.toml # Experiment dependencies (NOT crucible itself)
├── results-{tag}.jsonl # Auto-generated experiment log (per run)
├── run.log # Latest experiment output
└── logs/ # Per-iteration logs
└── iter-1/
├── agent.txt # Agent reasoning
└── run.log # Experiment output
Crucible is installed as a global CLI tool — it is NOT a dependency of your experiment project. Your project's pyproject.toml only lists experiment-specific packages (numpy, torch, etc.).
Documentation
- Config Reference — all YAML fields, eval convention, git strategy, guard rails
- FAQ — local optima, single metric, parallel agents, safety, monitoring
- Changelog — version history and release notes
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 autocrucible-0.5.0.tar.gz.
File metadata
- Download URL: autocrucible-0.5.0.tar.gz
- Upload date:
- Size: 329.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b036bd6e390f7e62a345497a8de453bc0657c040dba8f5844f1be73110fabf3
|
|
| MD5 |
0432913c839c3a80dc36a0fadac64923
|
|
| BLAKE2b-256 |
b5bab04d895c4297ddfe08e32cbb9276da6e4292e87f3e5346c164af2cec03cc
|
File details
Details for the file autocrucible-0.5.0-py3-none-any.whl.
File metadata
- Download URL: autocrucible-0.5.0-py3-none-any.whl
- Upload date:
- Size: 218.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaab4e3fcaa6373c540fdc25e164cb2b6d378acb81d50a29099e2c0df53b216c
|
|
| MD5 |
1a319b346f57a2bcfdd830d03da8a45d
|
|
| BLAKE2b-256 |
e95c4a88ac88e5302eb499a2ac0da1ee3bf280623211e86d5779206eb1ccf207
|