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.0.tar.gz (52.0 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.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hone_ai-1.2.0.tar.gz
  • Upload date:
  • Size: 52.0 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.0.tar.gz
Algorithm Hash digest
SHA256 93635534b68df54632b45802dd7a30980baa8e7c8028eee39408ba89962ae096
MD5 ffad0f87d77213e72b610d02e9413afa
BLAKE2b-256 4d855255e98f974bb4a7511e5c26a8c4284b69ded5a6450e67f955869cd1117e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hone_ai-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7e422088db1cdb365dc72920e51c3ddea0147d0e73fd70b98cd956e1ee367ac
MD5 2ee178eab824ed0c4f77444347f1db87
BLAKE2b-256 eee1fede54a5b6002227c6462e87c30454ca32d91a31347ac2327728b2b8adef

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