Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()usesos.getcwd()to find context files. The gateway process runs from the hermes-agent install directory, so it finds and loads the repo'sAGENTS.md,.cursorrules, etc. — none of which are relevant to the user's conversation.Fix
One-line change: pass
TERMINAL_CWD(which the gateway sets toMESSAGING_CWDor$HOME) as thecwdfor context file discovery instead of letting it default toos.getcwd().$HOME) — no more hermes repo junkTERMINAL_CWDis set to the user's actual project directoryImpact
~2x reduction in gateway input token usage per message.
Reported by keri on Discord.