Skip to content

fix(gateway): stop loading hermes repo AGENTS.md into gateway sessions (~10k wasted tokens)#2891

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-gateway-context
Mar 25, 2026
Merged

fix(gateway): stop loading hermes repo AGENTS.md into gateway sessions (~10k wasted tokens)#2891
teknium1 merged 1 commit intomainfrom
hermes/hermes-gateway-context

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Problem

Gateway sessions use ~15-20k input tokens vs CLI's ~6-8k. The extra ~10k comes from the hermes-agent repo's own AGENTS.md (16k chars, 390 lines) being loaded as project context.

Root cause: build_context_files_prompt() uses os.getcwd() to find context files. The gateway process runs from the hermes-agent install directory, so it finds and loads the repo's AGENTS.md, .cursorrules, etc. — none of which are relevant to the user's conversation.

Fix

One-line change: pass TERMINAL_CWD (which the gateway sets to MESSAGING_CWD or $HOME) as the cwd for context file discovery instead of letting it default to os.getcwd().

  • Gateway: context files from the user's configured messaging directory (default: $HOME) — no more hermes repo junk
  • CLI: unchanged — TERMINAL_CWD is set to the user's actual project directory

Impact

~2x reduction in gateway input token usage per message.

Reported by keri on Discord.

…s cwd

The gateway process runs from the hermes-agent install directory, so
os.getcwd() picks up the repo's AGENTS.md (16k chars) and other dev
context files — inflating input tokens by ~10k on every gateway message.

Fix: use TERMINAL_CWD (which the gateway sets to MESSAGING_CWD or
$HOME) as the cwd for build_context_files_prompt(). In CLI mode,
TERMINAL_CWD is the user's actual project directory, so behavior
is unchanged.

Before: gateway 15-20k input tokens, CLI 6-8k
After:  gateway ~6-8k input tokens (same as CLI)

Reported by keri on Discord.
@teknium1 teknium1 merged commit 7efaa59 into main Mar 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant