hermes - ✅(Solved) Fix Bug: Honcho session override lookup misses configured cwd when path spelling changes [2 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

HonchoClientConfig.resolve_session_name() checks self.sessions.get(cwd) before any normalization. A configured per-directory override for /tmp/project is ignored when the same directory is passed as /tmp/project/ or via another equivalent spelling.

Root Cause

HonchoClientConfig.resolve_session_name() checks self.sessions.get(cwd) before any normalization. A configured per-directory override for /tmp/project is ignored when the same directory is passed as /tmp/project/ or via another equivalent spelling.

Fix Action

Fixed

PR fix notes

PR #13322: fix(honcho): normalize cwd when matching manual session overrides

Description (problem / solution / changelog)

Summary

Closes #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 — with/without a trailing slash, as ~/proj vs /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.

The fix

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, ~-expanded, normalized form of both the lookup cwd and each override key.

def _match_session_override(self, cwd: str) -> str | None:
    if not self.sessions:
        return None
    direct = self.sessions.get(cwd)           # fast path
    if direct:
        return direct
    target = self._normalize_cwd(cwd)
    for key, value in self.sessions.items():
        if self._normalize_cwd(key) == target:
            return value
    return None

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 to os.path.normpath(os.path.expanduser(...)) covers pathological inputs.

Regression tests

Added in tests/honcho_plugin/test_client.py::TestResolveSessionName:

TestScenario
test_manual_override_matches_normalized_spellings (parametrized ×4)Trailing slash on override / lookup, ./ segment, .. segment
test_manual_override_expands_tilde_in_override_key~/proj override key resolves for /home/user/proj lookup (uses monkeypatch.setenv('HOME', ...) + tmp_path for determinism)

Kept the existing test_manual_override unchanged so the fast-path behaviour is still locked in.

Diff

  • 2 files changed, +74 / −2.
  • plugins/memory/honcho/client.py: +43 / −2 (the helper pair + wire-up).
  • tests/honcho_plugin/test_client.py: +33 (regression tests only).

Verification

  • python3 -m py_compile plugins/memory/honcho/client.py tests/honcho_plugin/test_client.py → clean.
  • The fast-path dict lookup is tried before normalization, so there's zero cost for callers whose override keys already match exactly.
  • Normalization never calls the filesystem's stat() — it's string/path-manipulation only — so it's safe for cwd values that don't exist locally (remote task cwds, etc.).

Linked Issue

  • Closes #13284

Changed files

  • plugins/memory/honcho/client.py (modified, +41/-2)
  • tests/honcho_plugin/test_client.py (modified, +33/-0)

PR #13333: fix(honcho): normalize session override paths

Description (problem / solution / changelog)

Fixes #13284.

Root cause: Honcho session overrides checked the configured sessions map only with the raw cwd string. Equivalent directory spellings such as trailing slashes, relative paths, or symlinked paths missed the manual override and fell back to basename-derived sessions.

Fix summary:

  • Preserve exact sessions key lookup first so intentionally exact entries still win.
  • Add a normalized fallback lookup using Path(...).expanduser().resolve(strict=False) for both the requested cwd and configured session keys.
  • Add regression coverage for trailing slash, relative cwd, symlink cwd, and exact-key precedence.

Tests:

  • uv run --frozen --python 3.11 --extra dev pytest -o addopts= tests/honcho_plugin/test_client.py -q
  • git diff --check -- plugins/memory/honcho/client.py tests/honcho_plugin/test_client.py

Changed files

  • plugins/memory/honcho/client.py (modified, +16/-0)
  • tests/honcho_plugin/test_client.py (modified, +38/-0)

Code Example

cd /Users/genie/.hermes/hermes-agent
source venv/bin/activate
python - <<'PY'
from plugins.memory.honcho.client import HonchoClientConfig
cfg = HonchoClientConfig(sessions={'/tmp/project': 'manual-name'})
for cwd in ['/tmp/project', '/tmp/project/', 'project']:
    print(cwd, '=>', cfg.resolve_session_name(cwd=cwd))
PY

---

/tmp/project => manual-name
/tmp/project/ => project
project => project
RAW_BUFFERClick to expand / collapse

Summary

HonchoClientConfig.resolve_session_name() checks self.sessions.get(cwd) before any normalization. A configured per-directory override for /tmp/project is ignored when the same directory is passed as /tmp/project/ or via another equivalent spelling.

Affected files

  • plugins/memory/honcho/client.py:438-444

Why this is a bug

The sessions map is intended to provide a manual override for a working directory, but that override silently stops applying based on trailing slashes / path spelling instead of directory identity.

Minimal reproduction

cd /Users/genie/.hermes/hermes-agent
source venv/bin/activate
python - <<'PY'
from plugins.memory.honcho.client import HonchoClientConfig
cfg = HonchoClientConfig(sessions={'/tmp/project': 'manual-name'})
for cwd in ['/tmp/project', '/tmp/project/', 'project']:
    print(cwd, '=>', cfg.resolve_session_name(cwd=cwd))
PY

Observed output:

/tmp/project => manual-name
/tmp/project/ => project
project => project

Expected behavior

Equivalent paths for the same working directory should hit the same manual override.

Actual behavior

Only the exact string key matches; equivalent cwd spellings fall through to basename-based naming.

Suggested investigation direction

Normalize or resolve cwd and the configured sessions keys before lookup (for example via Path(...).resolve() / consistent absolute normalization, while preserving non-existent-path safety as needed).

extent analysis

TL;DR

Normalizing the cwd and sessions keys before lookup is likely to fix the issue with HonchoClientConfig.resolve_session_name() ignoring per-directory overrides due to trailing slashes or path spellings.

Guidance

  • Investigate using Path(...).resolve() to normalize both cwd and the keys in sessions before performing the lookup, ensuring consistent absolute normalization.
  • Consider preserving non-existent-path safety as needed to avoid potential issues with directories that do not exist.
  • Review the HonchoClientConfig class, specifically the resolve_session_name method, to understand how the normalization can be integrated without breaking existing functionality.
  • Test the normalization approach with various path spellings and edge cases to ensure it correctly applies the manual overrides as expected.

Example

from pathlib import Path

# Example of normalizing cwd and sessions keys
def normalize_path(path):
    return str(Path(path).resolve())

# Assuming cfg is an instance of HonchoClientConfig
cfg = HonchoClientConfig(sessions={'/tmp/project': 'manual-name'})
normalized_sessions = {normalize_path(key): value for key, value in cfg.sessions.items()}

for cwd in ['/tmp/project', '/tmp/project/', 'project']:
    normalized_cwd = normalize_path(cwd)
    print(cwd, '=>', normalized_sessions.get(normalized_cwd, 'default-name'))

Notes

The provided example is a simplified demonstration and might need adjustments to fit the actual implementation of HonchoClientConfig and its dependencies. The key concept is to apply path normalization to both the lookup key (cwd) and the keys in the sessions dictionary to ensure consistent matching.

Recommendation

Apply a workaround by normalizing paths before lookup, as directly upgrading to a fixed version is not mentioned in the issue. This approach allows for a controlled fix that can be tested and verified without waiting for an official update.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Equivalent paths for the same working directory should hit the same manual override.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING