Skip to main content

Universal context-token diet tool for Hermes Agent

Project description

๐Ÿซ’ Hermes Token Diet

Cut your Hermes Agent context-window burn by 30%+ โ€” without patching a single line of code.

CI Release Python License: MIT

Hermes ships with a kitchen-sink of toolsets and a huge skills catalog. That is great for a first-time user, but for a daily driver the context window fills up fast โ€” and every extra token is a token you pay for. Hermes Token Diet is a small, opinionated CLI that audits your real billed prompt_tokens, shows you exactly what is burning tokens, applies a safe preset, and proves the savings with a live before/after demo.

โšก๏ธ Config-only. Reversible. One-minute setup.


โœจ What it does

Before After ฮ”
~19,200 tokens just to say "hi" ~13,140 tokens -32% fixed overhead
~9,500 tokens/exchange growth ~371 tokens/exchange growth -96% per-exchange growth

Numbers above are from a live kimi-k2.6 / Ollama Cloud run on Hermes v0.17.0. Your mileage depends on your persona and tool usage, but the tool reports your actual numbers every time.


๐Ÿš€ Install

pipx (recommended)

pipx install git+https://github.com/deresolution20/hermes-token-diet.git

Run once without installing:

pipx run git+https://github.com/deresolution20/hermes-token-diet.git audit

uv

uv tool install git+https://github.com/deresolution20/hermes-token-diet.git

From source

git clone https://github.com/deresolution20/hermes-token-diet.git
cd hermes-token-diet
pip install -e ".[dev]"
pytest -q

๐ŸŽฏ Quick start

1. Measure your current baseline

hermes-token-diet audit
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Hermes Token Diet โ€” Fresh 'hi' audit โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
Hermes home: /home/brice/.hermes
Running hermes chat -q 'hi' from a neutral directory...

  Metric                                           Value
 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  Session ID                      20260702_090329_26536f
  Input tokens (fixed overhead)                   13,140
  Output tokens                                       73
  Target fixed overhead                         โ‰ค 15,000
  Status                                 โœ… under target

2. See what costs tokens

hermes-token-diet analyze

Shows every enabled toolset and skill category with estimated token cost, plus your current file_read_max_chars / tool_output.max_bytes caps.

3. Preview a diet profile

hermes-token-diet recommend --profile daily

4. Live before/after demo

hermes-token-diet demo --profile daily

This measures your current cost, applies the profile, measures again, and prints the delta โ€” with an automatic timestamped backup of ~/.hermes/config.yaml.

5. Verify long-session growth

hermes-token-diet verify

Runs a scripted 5-exchange working session and reports average token growth per turn. Target is โ‰ค 5,000 tokens/exchange.


๐Ÿ‘๏ธ Context Watch addon

Monitor live Hermes sessions for context-window fatigue. Reports metrics, warns when you cross configurable thresholds, and writes reports to ~/.hermes/scratch/context-diet-latest.md so Hermes can read its own diet advice.

Manual check

# Check the active session
hermes-token-diet check

# Check a specific session
hermes-token-diet check --session-id 20260702_090329_26536f

# Show the markdown report in the terminal too
hermes-token-diet check --show-report

Background watch (foreground)

hermes-token-diet watch --interval 300

Polls every 5 minutes and writes a report only when a session crosses from healthy into warning or critical. Stop with Ctrl+C.

Daemon mode

Run unattended with a PID file and log file:

# Start the daemon
hermes-token-diet watch --daemon

# Check status
hermes-token-diet watch --status

# Stop it
hermes-token-diet watch --stop

# Opt-in auto-apply: when a session hits critical, automatically apply the
# 'daily' diet profile (with a backup) and keep watching
hermes-token-diet watch --daemon --auto-apply

Daemon files live in ~/.hermes/scratch/:

  • context-watch-default.pid
  • context-watch-default.log

Install as an OS service

hermes-token-diet watch --install-service

This prints copy-and-paste instructions for systemd --user and macOS launchd using the templates in extras/.

Fine-tune thresholds

Add a token_diet_watch block to ~/.hermes/config.yaml:

token_diet_watch:
  thresholds:
    token_ratio_warning: 0.60
    token_ratio_critical: 0.80
    compactions_warning: 3
    compactions_critical: 6
    growth_per_exchange_warning: 4000
    growth_per_exchange_critical: 7000

Re-enable tools or skills on the fly

# Bring a toolset back
hermes-token-diet enable-tool browser

# Bring a skill back
hermes-token-diet enable-skill ascii-art

# Undo the last config change
hermes-token-diet revert

# List available backups
hermes-token-diet revert --list

๐Ÿ“ฆ Profiles

Profile Toolsets kept Caps Best for
minimal Core assistant only (file, terminal, memory, skills, todo, session_search, context_engine) 20K file / 8K output Minimal token budget, headless use
daily Core + web, browser, code_execution, cronjob 20K file / 8K output Coding / ops assistant (recommended)
balanced Daily + kept creative / media skills 30K file / 12K output Multimedia and research workflows

Add --usage-tuned to any profile to re-enable toolsets or skill categories you actually used in the last 14 days, pulled from ~/.hermes/state.db.


๐Ÿ›ก๏ธ How it stays safe

  • No Hermes patches. Every change is a documented edit to ~/.hermes/config.yaml.
  • Automatic backups. apply and demo create timestamped .yaml.bak.token-diet-* files before touching anything.
  • Skills stay loadable. Disabling a skill only removes it from the eager system-prompt index; skill_view(name='...') still works on demand.
  • MCP servers preserved. Platform-specific and MCP config is left untouched.
  • Uses the real Hermes venv. The tool discovers your Hermes Python interpreter and runs probes through it, so measurements match reality.

๐Ÿ”ง What actually changes in config.yaml

platform_toolsets:
  cli:
    - file
    - terminal
    - memory
    - skills
    - todo
    - session_search
    - context_engine
    - web
    - browser
    - code_execution
    - cronjob

file_read_max_chars: 20000
tool_output:
  max_bytes: 8000

skills:
  disabled:
    - apple-notes
    - apple-reminders
    - findmy
    - imessage
    # ... heavy / niche skill categories only

All changes are scoped, reversible, and tailored to the chosen profile.


๐Ÿงช Development & testing

# Clone and set up a local dev venv
git clone https://github.com/deresolution20/hermes-token-diet.git
cd hermes-token-diet
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

# Run the suite
pytest -q

CI runs on Ubuntu, macOS, and Windows for Python 3.10โ€“3.13.


๐Ÿ“– Documentation


๐Ÿ—บ๏ธ Roadmap

  • check / watch Context Watch addon with live session monitoring
  • revert command to restore from any timestamped backup
  • diff command to compare two profiles side by side
  • Per-provider token counting with tiktoken / local tokenizer fallbacks
  • --aggressive profile for very long personas
  • TUI mode for interactive exploration

๐Ÿ’ก Why context tokens matter

Hermes sends the entire system prompt + full transcript + tool schemas on every API turn. If your fixed overhead is 19K tokens and you grow by ~10K per exchange, a 256K window is half full after only ~23 turns. Compressing the fixed payload and capping tool-output retention keeps sessions cheaper, faster, and less likely to hit the context ceiling.

This tool makes that tuning measurable, repeatable, and reversible.


๐Ÿ“„ License

MIT ยฉ Brice Neal


Built with the Hermes Agent ecosystem in mind.

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

hermes_token_diet-0.2.1.tar.gz (57.7 kB view details)

Uploaded Source

Built Distribution

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

hermes_token_diet-0.2.1-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file hermes_token_diet-0.2.1.tar.gz.

File metadata

  • Download URL: hermes_token_diet-0.2.1.tar.gz
  • Upload date:
  • Size: 57.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hermes_token_diet-0.2.1.tar.gz
Algorithm Hash digest
SHA256 105f267ac70da74585524977d6fa254a5d0b06425df7f28eddf82410308528a3
MD5 2f3643a1feeea0294d0aa5f9a9b8fcc9
BLAKE2b-256 80f38babf0fcca63e3b0005f2ca2db7131fa31b8689c2036b0db7a597c863463

See more details on using hashes here.

Provenance

The following attestation bundles were made for hermes_token_diet-0.2.1.tar.gz:

Publisher: release.yml on deresolution20/hermes-token-diet

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hermes_token_diet-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for hermes_token_diet-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19d3b5b0aee3dd4366f5ccba42d22de600f42c34e7985dfc5f4e918de8a63657
MD5 541802563d2276ae557e9774003831c6
BLAKE2b-256 f8a95d2c4b4764daad82d034381ee6cd53e02d3792af3c75db23cd52ac92cd7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for hermes_token_diet-0.2.1-py3-none-any.whl:

Publisher: release.yml on deresolution20/hermes-token-diet

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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