Skip to content

fix(memory): prefix Honcho gateway session key with ai_peer (#36160)#36820

Open
TumCucTom wants to merge 3 commits into
NousResearch:mainfrom
TumCucTom:fix/honcho-gateway-session-prefix
Open

fix(memory): prefix Honcho gateway session key with ai_peer (#36160)#36820
TumCucTom wants to merge 3 commits into
NousResearch:mainfrom
TumCucTom:fix/honcho-gateway-session-prefix

Conversation

@TumCucTom

Copy link
Copy Markdown
Contributor

Summary

Closes #36160.

When multiple Hermes profiles share one HERMES_HOME and the same chat, the gateway session key resolves identically for every profile, so all profiles collapse into one Honcho session. The reporter confirmed in production that four profiles under one home all wrote to session ID agent-main-telegram-dm-6412607285.

The other prefix branches in resolve_session_name (session_title, session_id, per-repo, per-directory) use peer_name (the human peer) as the prefix. That doesn't work for the gateway path — the human is shared per chat by definition. This PR uses ai_peer (the profile-distinguishing side) instead, mirroring the existing pattern.

What changed

plugins/memory/honcho/client.py:resolve_session_name() — gateway branch now prefixes gateway_session_key with ai_peer when session_peer_prefix is enabled, and passes the prefixed value to _enforce_session_id_limit so two profiles with the same chat get distinct truncated IDs if the 100-char Honcho limit is hit.

tests/test_honcho_client_config.py — new TestHonchoGatewaySessionPrefix class with three cases:

  • test_gateway_session_key_unprefixed_by_default — preserves legacy behavior when session_peer_prefix=False
  • test_gateway_session_key_prefixed_with_ai_peer_when_enabled — explicit ai_peer="alpha"
  • test_gateway_session_key_uses_default_ai_peer_hermes_when_enabled — out-of-the-box default

What stayed the same

  • No new config, no schema change, no API change.
  • Uses the existing sessionPeerPrefix config knob and the existing ai_peer attribute.
  • Forward-compatible with the v0.15.x s6 architecture refactor.
  • Default behavior (session_peer_prefix=False) is byte-identical to before — single-profile deployments are unaffected.

Test plan

pytest tests/test_honcho_client_config.py::TestHonchoGatewaySessionPrefix -v
pytest tests/test_honcho_client_config.py tests/test_honcho_session_context.py tests/honcho_plugin/test_async_memory.py -v

All 54 tests pass (3 new + 51 pre-existing across the three test files).

Platforms tested

  • macOS aarch64, Python 3.11.15, pytest 9.0.2

Related

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

@mxnstrexgl mxnstrexgl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated PR Review

Security Scan

  • ✓ No hardcoded secrets, injection sinks, unsafe deserialization, or dependency red flags found by this automated scan.

Code Quality

  • ✓ No blocking code-quality issues found by this automated scan.

Summary

Status: APPROVE — security findings: 0, quality suggestions: 0.

Automated review; raw diff content intentionally omitted.

@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers P3 Low — cosmetic, nice to have labels Jun 1, 2026
@TumCucTom

Copy link
Copy Markdown
Contributor Author

Pushed a follow-up commit that adds my contributor email to `scripts/release.py` AUTHOR_MAP so the new `Contributor Attribution Check` CI workflow passes:

```
"hf23482@bristol.ac.uk": "TumCucTom",
"tokbale@outlook.com": "TumCucTom",
```

Locally verified against the new HEAD:

```
$ git log origin/main..HEAD --format='%ae' --no-merges | sort -u
hf23482@bristol.ac.uk
$ grep -F '"hf23482@bristol.ac.uk"' scripts/release.py
"hf23482@bristol.ac.uk": "TumCucTom",
```

@maintainers — would you mind re-running the `check-attribution` job to confirm? The same fix is now on the other open PRs (#36931, #36943) and #36820.

TumCucTom and others added 2 commits June 1, 2026 22:58
…arch#36160)

When multiple Hermes profiles share one HERMES_HOME and a single
chat, the gateway session key resolves identically for every profile,
so all profiles collapse into one Honcho session.

The other prefix branches (session_title, session_id, per-repo,
per-directory) use `peer_name` (the human) as the prefix. That does
not work for the gateway path — the human is shared per chat by
definition. Use `ai_peer` (the profile-distinguishing side) instead,
mirroring the existing pattern.

No config change. Forward-compatible with the v0.15.x s6 architecture
refactor. The hash passed to `_enforce_session_id_limit` is taken over
the prefixed key so two profiles with the same chat get distinct
truncated IDs when the limit is hit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The new contributor-check CI workflow requires every new committer
email to be mapped to a GitHub username in scripts/release.py.
Adds both known emails for the same contributor.

Co-authored-by: Zippy AI <tomkinsbale@icloud.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@TumCucTom TumCucTom force-pushed the fix/honcho-gateway-session-prefix branch from b0bddf4 to a3839ca Compare June 1, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

3 participants