The request landed in a terminal on September 2, more like a note left for a contractor than a prompt: massive simplification PRs, at least 30% fewer lines, god files broken up, duplicate helpers unified, no waiting for decisions. No excuses. Present the PR when it is done.
The contractor was Hermes Agent, the open source agent from Nous Research, and the codebase was Hermes itself. The repository had passed a million lines of non-test Python, and gateway/run.py alone had reached 34,847 lines.
That cleanup had sat on the team's list for months, losing to features and bug fixes. Teknium's staffing estimate for doing it by hand ran from $150,000 over two months to $1.8 million over two years. Nobody could justify scheduling it.
So he handed it to the agent he already uses to develop the agent. Months of corrections had been saved as skills, Markdown procedures the agent reloads on later tasks. He set a standing objective with /goal and walked away.
Nineteen Hours, Thirty-Six Buckets, One Desktop
The orchestrator did not start by writing code. It measured the codebase, divided it into 36 non-overlapping groups, and wrote its own assignments from the original objective and the accumulated skill.
Workers ran in git worktrees, separate checkouts where they could edit without clobbering a neighbor. Each brief named the code to simplify, the interfaces that had to survive, and the checks required before a commit. Some workers split their assignments again, so the tree ran three levels deep.
It all lived in one Python process on an i7 desktop with 64 GB of RAM, tools in local subprocesses and inference remote on Claude Fable 5.1. At the peak, 218 subagents ran at once out of 1,393 dispatched over nineteen active hours.
Fifty minutes in, the provider's authentication token expired. The failures cascaded and killed the run mid-flight.
The commits and briefs survived. Teknium opened a separate Hermes session to diagnose the failure and write a handoff, fed it back into the paused session, and sent workers into their saved changes to finish half-completed extractions.
What the Diff Actually Says
The PR merged on September 4, after the restart, a continuation session, and two rounds of community review. The before and after numbers are the part worth staring at.
- Non-test Python: 1,063,826 lines down to 698,363, a 34.4% cut
- Files over 5,000 lines: 37 down to 6
- Functions over 300 lines: 192 down to 2
- Longest if/elif chain: 92 branches down to 9
gateway/run.py: 34,847 lines down to 5,512
In the biggest file, workers separated message dispatch, streaming, RPC, and lifecycle handling into modules. Elsewhere they collapsed duplicate helpers and replaced name-based conditional chains with dispatch tables.
Nous also asked whether code that is easier for humans is cheaper for an agent to read. Simulating lookups of the same 4,000 symbols, average tokens returned per lookup fell from 2,218 to 993, and lookups needing a second read window fell from 628 to 184.
None of it was free. Splitting files raised the module count and the import graph, some entry points now import slower, and six files still exceed 5,000 lines. The median lookup actually returned more tokens, since fewer comments mean denser code in any fixed window.
Then came the regressions the tests missed. Reviewers found public names deleted because nothing inside the repository called them, though external plugins import them. An automated rewrite of suppress() calls shifted exception handling at roughly 65 sites.
Running 218 agents also exposed weaknesses in the agent. Worktrees had spun up about thirty copies of Pyright, eating 8.7 GB, so a follow-up change let them share one language server. References keeping finished agents in memory were fixed too.
The repository's instructions changed as well, with new guidance on file size and function complexity split by area, plus a check that flags removed public names for review.
The most reusable artifact is smaller than the PR. The hermes-agent-dev skill grew out of a habit: each time Teknium corrected the agent, it saved the lesson. One line now says a failing check should first be reproduced on origin/main in a clean environment. He sends that skill to the rest of the engineering team.
Nous frames the result as 1% of the cost and 1% of the time of the manual estimate, roughly $19,300 for the main run and about $25,000 with follow-ups. The more interesting number is not the money. The agent arrived knowing how this team likes its pull requests.
That is the loop worth watching. An agent that rewrites its own codebase, records what it learned, and hands those notes to the next agent compounds in a way no benchmark captures. On September 2 the loop turned once and the codebase came out roughly 365,000 lines lighter. The next turn decides whether this was a stunt or a method.
Comments