Skip to main content

Production hardening pack for Hermes Agent — per-topic model routing, fallback chains, rate limiting, and cost tracking via gateway hooks

Project description

hermes-kit

Production hardening pack for Hermes Agent.

Self-hosted Hermes gateways are powerful but built for single-user setups. Multi-user deployments hit walls: no per-topic model routing, API failures surface as hard errors, one heavy user can burn your API budget with no alert.

hermes-kit fills these gaps with production-grade hooks.

⚠️ How it works: hermes-kit monkey-patches Hermes Agent's internal model resolver at runtime. This is intentionally fragile — Hermes Agent updates may break your setup. We're working on an upstream PR to replace the patch with native hook return values. Until then, test after every Hermes upgrade.

Prerequisites

  • Python ≥ 3.11
  • Hermes Agent v0.16.0 (pinned)
  • Hermes configured with a working model + provider — hermes-kit is a plugin, not standalone. Hermes must be able to respond to messages BEFORE installing hooks.
  • A configured gateway (Telegram, Discord, etc.)

Verify Hermes works first

Critical: hermes-kit won't fix a broken Hermes setup. Make sure your gateway responds to messages with the model you want BEFORE installing hooks.

# Set your model (pick one from opencode-go)
hermes /model opencode-go/mimo-v2.5-pro

# Or via config.yaml at ~/.hermes/config.yaml:
cat > ~/.hermes/config.yaml << 'EOF'
model:
  default: opencode-go/mimo-v2.5-pro
  provider: opencode-go

providers:
  opencode-go:
    api_key: OPENCODE_GO_API_KEY
    base_url: https://opencode.ai/zen/go/v1
EOF

# Ensure API keys in ~/.hermes/.env
echo "OPENCODE_GO_API_KEY=sk-..." >> ~/.hermes/.env
echo "GATEWAY_ALLOW_ALL_USERS=true" >> ~/.hermes/.env

# Start gateway
hermes gateway run

# Send a test message on Telegram → verify you get a response
# Only then install hermes-kit

Gateway Management

# Start (with hooks)
hermes-kit gateway run --accept-hooks

# Stop
# Press Ctrl+C in the terminal running the gateway

# Restart after config changes
# Ctrl+C then:
hermes-kit gateway run --accept-hooks

# Check status
hermes-kit status

Install

pip install hermes-agent-kit

🔵 Naming — same project, two names:

Context Name
PyPI / pip install hermes-agent-kit
GitHub repo srmdn/hermes-agent-kit
CLI command hermes-kit

Why the split? PyPI name matches the repo (hermes-agent-kit). The short CLI alias (hermes-kit) keeps commands terse — hermes-kit install router instead of hermes-agent-kit install router. Same project, same code, two names.

Quickstart

# Install all hooks in one command
hermes-kit install router fallback rate-limiter cost-tracker model-switch

# Verify
hermes-kit doctor

# Start gateway with bridge auto-patched
hermes-kit gateway run --accept-hooks

# If new users get "I don't recognize you":
GATEWAY_ALLOW_ALL_USERS=true hermes-kit gateway run --accept-hooks

Hooks land in ~/.hermes/hooks/<name>/. Hermes discovers them on restart.

Modules

router — Per-Topic Model Routing

Route Telegram topics to different AI models. Finance chat uses Qwen, coding chat uses DeepSeek, everything else falls back to GPT-4o-mini.

Via CLI:

hermes-kit router set-default --model opencode-go/qwen3.6-plus
hermes-kit router add 42 --model opencode-go/deepseek-v4-pro
hermes-kit router show

Via YAML (~/.hermes/hooks/router/topic_router.yaml):

default:
  model: "opencode-go/qwen3.6-plus"

topics:
  "42":
    model: "opencode-go/deepseek-v4-pro"

Multi-provider — route specific topics to native providers:

hermes-kit router add 42 --model gpt-4o --provider openai
hermes-kit router add 7 --model claude-sonnet-4-20250514 --provider anthropic

Hermes resolves API keys from ~/.hermes/.env (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.). See providers guide for all supported providers and model IDs.

fallback — Automatic Fallback Chain

Define a chain of models to try when the primary fails.

Via YAML (~/.hermes/hooks/fallback/fallback_chain.yaml):

chains:
  global:
    - "opencode-go/deepseek-v4-pro"     # primary
    - "opencode-go/kimi-k2.6"      # fallback
    - "opencode-go/qwen3.6-plus"          # last resort

After a failure, call hermes_kit.bridge.retry_with_fallback(session_key) to advance to the next model.

rate-limiter — Per-User Rate Limiting

Prevent a single user or chat from draining your API budget.

Via YAML (~/.hermes/hooks/rate-limiter/rate_limits.yaml):

limits:
  global:
    max_messages_per_window: 100
    window_seconds: 3600
  per_user:
    "123456789":
      max_messages_per_window: 50

Rate limiter enforces limits at the bridge level — exceeding users get RateLimitExceeded on every request until their window resets. Set window_seconds to control reset timing.

cost-tracker — Real-Time Cost Tracking

Track token costs per session and alert when thresholds are exceeded.

Via YAML (~/.hermes/hooks/cost-tracker/cost_tracker.yaml):

alert_threshold_usd: 1.0

Set to 0 to disable alerts but continue tracking.

Docs

License

MIT

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_agent_kit-0.3.5.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

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

hermes_agent_kit-0.3.5-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file hermes_agent_kit-0.3.5.tar.gz.

File metadata

  • Download URL: hermes_agent_kit-0.3.5.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hermes_agent_kit-0.3.5.tar.gz
Algorithm Hash digest
SHA256 4520aa8c0f80f06378463df770e6f048ea75ee512f60e10f9eed648c9cf540bd
MD5 95ba00f82fd38e0c0f3a8a8515578624
BLAKE2b-256 ea648856bd656d675357ff04ca37d5894289ed8ad6265d616fba51d1ca15abd3

See more details on using hashes here.

File details

Details for the file hermes_agent_kit-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: hermes_agent_kit-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hermes_agent_kit-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6a6c99384681286f0aa069e149ee8f10c91f08a439daf29d7c01317c6f832391
MD5 0b1f2d39f21022f107b7fe230b34ac5a
BLAKE2b-256 0b5bb38830b73a349d43672f5e16ca093bbe4e426162027d01cdddadc5b9c68f

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