fix(honcho): normalize cwd when matching manual session overrides#13322
Open
Sanjays2402 wants to merge 1 commit into
Open
fix(honcho): normalize cwd when matching manual session overrides#13322Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
Closes NousResearch#13284. HonchoClientConfig.resolve_session_name() does: manual = self.sessions.get(cwd) which is a raw dict lookup on whatever string the caller passed in. When Hermes is launched from different shells the same project directory can be spelled multiple equivalent ways \u2014 with/without a trailing slash, as '~/proj' vs '/home/user/proj', via a '.' or '..' segment, etc. \u2014 and all but one miss the override, so Hermes silently falls through to the basename-derived session name and effectively starts a fresh Honcho session. Add a small _match_session_override() helper that tries the existing fast-path dict lookup first (so configs with already-normalized keys keep their exact behaviour) and then falls back to comparing the absolute, user-expanded, normalized form of both the lookup cwd and each override key. The normalization uses pathlib.Path.resolve(strict=False), so it doesn't require the directory to actually exist on disk \u2014 which matters for test fixtures and for remote-cwd callers. Tests added in tests/honcho_plugin/test_client.py: - trailing-slash equivalence (both directions) - './' and '..' path segments normalized away - '~/proj' override key resolves for '/home/user/proj' lookup
Collaborator
Contributor
Author
|
Hey @alt-glitch — just a note for context: this PR was opened ~10 minutes before #13333 (04:54:34Z vs 05:04:48Z), so #13333 is actually the duplicate here, not the other way around. Happy to defer to @sgaofen's implementation if maintainers prefer it, but wanted to make sure the timeline was clear. Either way, whichever lands first is fine by me. |
This was referenced Apr 22, 2026
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.
What does this PR do?
HonchoClientConfig.resolve_session_name()does a raw dict lookupself.sessions.get(cwd)on whatever string the caller passed in. When Hermes is launched from different shells the same project directory can be spelled multiple equivalent ways — with/without a trailing slash, as~/projvs/home/user/proj, with a.or..segment — and all but one miss the override, so Hermes silently falls through to the basename-derived session name and effectively starts a fresh Honcho session every time.Adds a small
_match_session_override()helper that tries the existing fast-path dict lookup first (so configs with already-normalized keys keep their exact behaviour) and then falls back to comparing the absolute,~-expanded, normalized form of both the lookup cwd and each override key.Normalization uses
pathlib.Path.resolve(strict=False), so it doesn't require the directory to actually exist on disk — which matters for test fixtures and remote-cwd callers. A defensive fallback toos.path.normpath(os.path.expanduser(...))covers pathological inputs.Related Issue
Fixes #13284
Type of Change
Changes Made
plugins/memory/honcho/client.py(+43 / −2): new_match_session_override()+_normalize_cwd()helpers;resolve_session_name()delegates to them.tests/honcho_plugin/test_client.py(+33): regression tests for normalized spellings and~expansion.How to Test
sessionsoverride in~/.hermes/config.yamlkeyed by~/proj(or with a trailing slash)./Users/you/proj(no trailing slash, no tilde).Run the regression suite:
Checklist
Code
fix(honcho):)pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.md— N/Apathlib.Path.resolveScreenshots / Logs
Verification
python3 -m py_compile plugins/memory/honcho/client.py tests/honcho_plugin/test_client.py→ clean.stat()— it's string/path-manipulation only — so it's safe for cwd values that don't exist locally (remote task cwds, etc.).Regression tests added
test_manual_override_matches_normalized_spellings(parametrized ×4)./segment,..segmenttest_manual_override_expands_tilde_in_override_key~/projoverride key resolves for/home/user/projlookupKept the existing
test_manual_overrideunchanged so the fast-path behaviour is still locked in.