> ## Content Index
> Fetch the complete content index at: https://www.tao.media/llms.txt
> Use this file to discover other available public pages before exploring further.

# Nous Research Says Hermes Agent Used 1,393 Subagents to Cut Its Own Codebase by 34%
- URL: https://www.tao.media/nous-research-says-hermes-agent-used-1-393-subagents-to-cut-its-own-codebase-by-34/
- Published: 2026-09-17T16:35:40.000Z
- Updated: 2026-09-17T16:35:40.000Z
- Description: The open-source agent’s self-refactor reduced non-test Python lines by 34.4%, though Nous says review caught real regressions before merge.
- Author: Bart Hillerich
- Tags: Nous Research, AI, News

[Nous Research](https://nousresearch.com/?ref=tao.media) says its Hermes Agent coordinated 1,393 subagents to refactor its own open-source codebase, cutting non-test Python source by 34.4% after a roughly nineteen-hour main run and several follow-up review rounds.

The company described the project in an [official blog post by Teknium](https://nousresearch.com/refactoring-hermes-with-1393-agents?ref=tao.media), who said he asked Hermes on September 2 to clean up a repository that had grown to more than one million lines of non-test Python. The pull request was merged on September 4 after a restart, continuation session, and community review.

Nous framed the run as a major example of agentic software engineering at production scale, saying in its [announcement on X](https://x.com/NousResearch/status/2099984561451028913?ref=tao.media) that Hermes saved the team “nearly $2m in engineering hours.”

Teknium estimated about $19,300 in model costs for the main run, roughly $25,000 including follow-ups, and a manual engineering equivalent between $150,000 and $1.8 million. Those figures exclude human review time.

## Hermes Was Asked to Simplify Itself

Hermes Agent is Nous Research’s open-source coding and automation agent. In this case, the assignment was unusually direct: Teknium asked Hermes to reduce lines of code by at least 30%, break up “god files,” unify reusable helpers, reduce long conditional routing chains, improve legibility, and return a pull request without waiting for additional human decisions.

The prompt was run through Hermes’s `/goal` mode, which gives the agent a standing objective and pushes it to continue rather than stopping after a short task. Hermes used its `hermes-agent-dev` skill, a reusable instruction set that had accumulated from Teknium’s previous work on the repository.

That skill included guidance such as reproducing failing checks on a clean `origin/main` baseline to determine whether a failure was introduced by the current change or already existed.

## How the 1,393-Agent Refactor Ran

The orchestrator first measured the codebase and split the work into 36 non-overlapping groups. Individual workers used Git worktrees so they could edit separate checkouts without overwriting each other. Some workers delegated parts of their assignments again, creating a tree that reached three levels below the original coordinator.

The top-level Hermes instance handled planning, written assignments, worker reports, integration, and checks rather than directly editing every file. At peak, the run had 218 agents active at once. Teknium said the coordination ran in one Python process on an i7 desktop with 64 GB of RAM, while tools ran locally and Claude Fable 5.1 handled inference remotely.

The run was not seamless. About 50 minutes in, a provider authentication token expired, causing failures that killed the run. Hermes preserved worker commits and briefs, and Teknium used a separate Hermes session to diagnose the failure and prepare a handoff before resuming the job.

For `gateway/run.py`, which was 34,847 lines before the project, workers separated message dispatch, streaming, RPC, and lifecycle handling into smaller modules. Across the repository, they consolidated helpers and replaced long name-based `if/elif` chains with dispatch tables.

## The Codebase Got Smaller, But Not Perfect

The headline result was a reduction in non-test Python from 1,063,826 lines to 698,363 lines. The number of files over 5,000 lines fell from 37 to six. Functions over 300 lines dropped from 192 to two. The longest `if/elif` chain shrank from 92 branches to nine, and `gateway/run.py` fell from 34,847 lines to 5,512.

Nous also tested whether the refactor made code easier for agents to inspect. In a lookup simulation covering the same 4,000 symbols before and after the change, average tokens returned per lookup fell from 2,218 to 993\. Lookups that required an additional read window fell from 628 to 184.

Teknium was careful not to overstate that benchmark. The test measured lookup cost, not whether agents completed engineering tasks more successfully. The median lookup actually returned more tokens, because fixed-size windows contained denser code after comments and docstrings were reduced. The average fell because the largest definitions became much smaller.

There were tradeoffs, too. Splitting files increased the number of modules and imports, and some entry points became slower to import. Six files were still above 5,000 lines after the refactor. Hermes made the codebase substantially smaller, but the result was not a clean-room rewrite or a cure for every coupling problem.

## Review Caught Real Regressions

The most useful part of the case study may be what went wrong.

Reviewers found that workers had removed public names that appeared unused inside the repository but were still needed by external plugins. An automated rewrite of `suppress()` calls also changed exception handling at roughly 65 sites.

These regressions were missed by existing tests and fixed before merge over two rounds of community review, with additional fixes following after the pull request landed. That makes the run a stronger engineering example than a flawless demo would have been, because it shows both the scale of work an agent system can coordinate and the limits of current automated verification.

The project also exposed operational issues in Hermes itself. Separate worktrees had launched about 30 Pyright language-server copies, consuming roughly 8.7 GB of memory.

Follow-up changes allowed worktrees to share one server, reduced duplicated HTTP transports, fixed memory references to finished agents, and added checks for removed public names.