Skip to main content

A tool for autonomous code optimization and agentic loops

Project description

Hone

Ask DeepWiki

Hone automates software optimization. Give it a goal and a benchmark. It rewrites your code until it wins.

It runs entirely in your terminal. It writes code, runs your benchmark, reads the score, and loops. It learns from its own tracebacks. It stops when it hits your target or exhausts its budget.

41x faster in 20 iterations. No human in the loop.

Inspired by Karpathy's autoresearch project.


How it works

Hone combines minimal orchestration with LLMs. Each experiment runs cleanly.

  • Statefulness — tracks cost, tokens, and git diffs per iteration
  • Self-healing — catches its own Python tracebacks and feeds them back into context
  • Simplicity — prefers simpler code over complex, marginal gains
  • Traceability — logs a chronological timeline of every hypothesis and benchmark score

Installation

pip install hone-ai

Or from source:

git clone https://github.com/laxmena/hone.git
cd hone
python -m venv venv
source venv/bin/activate
pip install -e .

You need a .env file with your API keys. Hone defaults to claude-haiku-4-5.


Usage

Define your goal and point Hone at your benchmark script.

hone "Optimize process_logs.py to run under 0.02 seconds. Think creatively." \
     --bench "python bench_logs.py" \
     --files "process_logs.py" \
     --optimize lower \
     --target 0.02 \
     --budget 2.0

For complex goals with detailed context, write them to a file and pass it with --goal-file:

hone --goal-file goal.md \
     --bench "python bench_logs.py" \
     --files "process_logs.py" \
     --optimize lower \
     --target 0.02 \
     --budget 2.0

--goal-file accepts any plain text or markdown file. It is equivalent to passing the file's contents as the GOAL argument — existing usage is unaffected.

Hone handles the rest.


Experiment 1: The Log Parser

A naive Python log parser. 150,000-line server log. Baseline: 1.54 seconds.

hone "Optimize process_logs.py to run under 0.02 seconds. Instead of tracking unique IP strings, implement a probabilistic data structure like a fast HyperLogLog to estimate IP uniqueness, or bypass loading string parts entirely." \
     --bench "python examples/log_parser/bench_logs.py" \
     --files "examples/log_parser/process_logs.py" \
     --optimize lower \
     --target 0.02 \
     --score-pattern "Time Taken:\s*(\d+\.\d+)" \
     --budget 2.0

Hone ran 20 iterations. It stripped slow Python dictionaries. It bypassed readlines(). It pre-bound set.add to skip attribute lookup overhead. It hit the ceiling of single-threaded Python at 0.07 seconds.

Then it changed the rules. It abandoned line-by-line parsing. It read the file as a raw binary blob. It deployed re.findall() across the entire content in one pass.

Final result: 1.54s → 0.037s. A 41x speedup.

Log parser optimization — 41x speedup over 20 iterations

Iter | Status | Score  | Description
...
18   | keep   | 0.0507 | The real bottleneck is the Python loop and split() calls. Try a compiled regex to extract endpoint in one operation...
19   | keep   | 0.0473 | Regex is faster. Use a simpler, more efficient pattern.
20   | keep   | 0.0370 | Try re.findall() to process the entire file at once and avoid line iteration overhead...

Run 1 report | Run 2 report


Experiment 2: The Distance Calculation

Real-time taxi dispatch. 500 riders, 1,000 drivers. Brute-force O(R×D) baseline: 2.18 seconds.

Run 1 — Hone built a spatial grid, bucketed drivers into cells, and used Manhattan distance pre-filtering to skip distant candidates. Result: 0.1496 seconds. A 14.6x speedup.

Run 2 — Hone found what Run 1 missed. The grid search still checked every candidate cell, even after finding a close driver. The fix: stop the moment you find one. Expand the radius incrementally instead of exhaustively. Result: 0.069 seconds. Another 2.1x.

The AI learned that algorithm beats data structure. Grid resolution barely mattered. Early termination dominated.

Distance calculation — two runs, 31x total speedup

Run 1 report | Run 2 report


Read more

Full write-up, learnings, and experiment breakdowns on the blog: I Built a Tool That Optimizes Code While You Sleep

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

hone_ai-1.2.1.tar.gz (65.7 kB view details)

Uploaded Source

Built Distribution

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

hone_ai-1.2.1-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file hone_ai-1.2.1.tar.gz.

File metadata

  • Download URL: hone_ai-1.2.1.tar.gz
  • Upload date:
  • Size: 65.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for hone_ai-1.2.1.tar.gz
Algorithm Hash digest
SHA256 3604c00fa459d6e22b395fdfa9e7dab6d26930101b5b0902ae5637d747ea1842
MD5 85144e588088ae993f65949f5efc8f19
BLAKE2b-256 3b8872e680d84c1fa140a9f7aca75d096ea9805862d02813a6345b0a0464d0b4

See more details on using hashes here.

File details

Details for the file hone_ai-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: hone_ai-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for hone_ai-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d3a9223fe216160bfe56af498604a95c6b2422b7ca0df382d0f34f9e012a647
MD5 2243431dc9f80922f82fc2c92edf0f2a
BLAKE2b-256 8c88d6589fc219ca90ef1fdfd8fec906c9cf2b3e4f8d4c82a31e52c90e409b27

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