Skip to content
← all writing

Hermes Agent Cut 13,103 Tokens From Skill Activation by Dropping a Duplicated Path

  • hermes
  • token-optimization
  • skills
  • context-compression
  • prompt-engineering

When Hermes Agent activates a skill that ships supporting files, the activation message lists those files so the model knows what it can load. Until PR #98433, merged today by teknium1, every line in that listing repeated the skill's full absolute path. On a skill with 462 supporting files the activation message measured 42,145 tokens; after the change it measured 29,042 tokens. That is a reduction of 13,103 tokens, or 31.1 percent, on a single activation.

The mechanism

The supporting-files block emitted each entry as a relative path followed by its absolute form:

- scripts/run.js  ->  /home/user/hermes-agent-dev/scripts/run.js

The absolute form is skill_dir / relative, so the same directory prefix (/home/user/hermes-agent-dev/) was copied onto every line. The directory was already stated once in the [Skill directory: ...] header and again in the footer's worked example, which shows how to call skill_view or run a script by absolute path. The per-line copy added nothing the model did not already have.

Per the PR, each of the 462 lines in the test skill carried the duplicate prefix at roughly 18 tokens per line. The fix removes the absolute half of every line and notes in the block header that paths resolve against the skill directory stated above.

The PR states the root cause directly, per teknium1 in #98433:

the supporting-files block emitted - <relative> -> <absolute> per file, duplicating an identical directory prefix hundreds of times. The absolute base was already stated once in the [Skill directory: ...] header and the footer's worked example, so the per-line copy was pure redundancy.

After the change the line is the relative path only:

- scripts/run.js
Metric Before After
Activation message size (tokens, o200k_base) 42,145 29,042
Supporting files in the test skill 462 462
Token reduction -13,103 (-31.1%)

Why the saving scales with the skill

The activation message is part of the context on every turn for the lifetime of the session, so the cost is paid once per activation but then sits in the prompt. The duplication tax is proportional to the number of supporting files: a skill with 10 files loses a few hundred tokens, while a reference-heavy skill with hundreds of files loses tens of thousands. The 462-file dev skill is close to the worst case, which is why the measured delta lands at 31.1 percent.

The change is free at runtime. The absolute base remains available through the [Skill directory: ...] header and the footer example, so skill_view(name=..., file_path=...) and running a script by its absolute path both still work. Nothing about resolution changed; only the redundant copy was deleted.

The change itself

The fix is 17 additions and 8 deletions across two files: agent/skill_commands.py and tests/agent/test_skill_commands.py. The production change is a one-line edit in _build_skill_message that drops the -> {skill_dir / sf} suffix and updates the block header text. The test was repinned to the new format contract: relative-only lines, no absolute paths inside the block, header and footer example still present. The PR notes the test is sabotage-verified, meaning it fails against the old format.

Validation was measured live, not estimated. The PR reports a before/after on the real build_skill_invocation_message("/hermes-agent-dev") call with 462 supporting files, tokenized with o200k_base, and a live repro on origin/main confirming all 462 lines carried the duplicate prefix. The targeted test suite (tests/agent/test_skill_commands.py) passes 29 of 29.

The 31.1 percent figure is the measured delta: 42,145 minus 29,042 equals 13,103, and 13,103 divided by 42,145 equals 0.311. Smaller skills see a smaller absolute saving but the same structural win, since every supporting-file line stops carrying a prefix it does not need.

Termagotchi
_

Ryan Underdown

Autodidact. Rarely listens to advice.

Follow on X @catamarammed or GitHub @underdown