fix(honcho): canonicalize gateway session keys - #50134
Conversation
Refresh the Honcho provider's cached session key on session switches and prefer stable gateway_session_key values over display titles when resolving gateway/WebUI Honcho storage keys. Add read-only diagnostics and regression coverage for legacy candidate lookup.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the cached-session-key writeback problem. The current-main premise is valid, but this branch needs rework before salvage.
Problems
plugins/memory/honcho/client.py:773makes a manual map win beforeper-sessionidentity. Current main deliberately makessession_idauthoritative in that mode (plugins/memory/honcho/client.py:703-722;tests/honcho_plugin/test_async_memory.py:158-170). Retain that contract; gateway-key precedence is already implemented on main (plugins/memory/honcho/client.py:696-701).plugins/memory/honcho/__init__.py:1145only carries switch inputs from_lazy_init_kwargs, but the initializer clears it at PR line 420. The switch fan-out does not passgateway_session_key(agent/memory_manager.py:871-875), so a ready gateway session will resolve to the new transcript id instead of its stable gateway key. This conflicts with the API-server contract that gateway keys persist while transcript ids rotate (gateway/platforms/api_server.py:1282-1287).
Suggested changes
- Preserve the current resolver semantics and focus the salvage on Honcho's missing
on_session_switchimplementation. - Store initial resolution inputs independently of lazy-init state, merge them on switch, and test the actual MemoryManager switch path after successful initialization.
Automated hermes-sweeper review.
|
|
||
| # Explicit/manual keys and gateway keys are source-level overrides that | ||
| # beat presentation metadata and strategy-based fallback resolution. | ||
| if candidate_map.get("manual_override"): |
There was a problem hiding this comment.
Current main makes per-session session_id authoritative over both a manual map and a title (tests/honcho_plugin/test_async_memory.py:158-170). Returning manual_override first reverses that current contract; retain the existing per-session precedence while preserving gateway-key priority.
There was a problem hiding this comment.
Addressed in 13504afbb: I removed the resolver changes from this PR, so client.py now matches current main and retains the existing precedence (gateway_session_key first, then authoritative per-session session_id, then manual map/title for non-per-session strategies). The remaining change is limited to the provider lifecycle/session-switch fix and its regression tests.
| # finishes and discards stale manager/key state. | ||
| self._session_generation += 1 | ||
|
|
||
| switch_kwargs = dict(self._lazy_init_kwargs or {}) |
There was a problem hiding this comment.
_lazy_init_kwargs is cleared after successful background initialization (line 420), and MemoryManager.on_session_switch() does not forward gateway_session_key. A ready gateway session therefore resolves from the new transcript id here. Persist the initial resolution inputs separately and add a test through the manager switch path.
# Conflicts: # plugins/memory/honcho/client.py # tests/honcho_plugin/test_async_memory.py # tests/honcho_plugin/test_client.py
|
Thanks for the detailed review — I reworked the PR in The previous resolver/CLI changes have been removed, so the resolver keeps current The remaining change is focused on the missing Honcho lifecycle behavior:
Validation: the full Honcho plugin suite passes ( Could you please take another look when you have a chance? |
What does this PR do?
Fixes two Honcho session-identity issues that can fragment gateway/WebUI memory writeback:
HonchoMemoryProvidernow refreshes its cached session key when the active Hermes session changes, so later sync/async writes do not keep using the previous session's Honcho key.HonchoClientConfig.resolve_session_name()now treatsgateway_session_keyas the canonical storage key for gateway/WebUI turns when present, ahead of displaysession_title. Titles remain a legacy/non-gateway fallback and are exposed as readback candidates.This keeps explicit
sessionsoverrides highest priority and preserves legacy candidate visibility through a read-only resolver/CLI path instead of migrating historical Honcho sessions.Related Issue
No single issue filed for this exact two-part bug.
Related open Honcho PRs found during duplicate search:
Type of Change
Changes Made
plugins/memory/honcho/__init__.pyon_session_switch(...)lifecycle handling.plugins/memory/honcho/client.pygateway_session_key→session_title→ strategy fallback.plugins/memory/honcho/cli.pyhermes honcho resolve-sessiondiagnostics for primary and legacy candidate keys.plugins/memory/honcho/README.mdtests/honcho_plugin/*How to Test
Targeted Honcho validation run against this PR branch:
PYTHONPATH=. /home/openclaw/.hermes/hermes-agent/venv/bin/python -m pytest tests/honcho_plugin/test_async_memory.py tests/honcho_plugin/test_cli.py tests/honcho_plugin/test_client.py -q180 passed, 3 warningsPYTHONPATH=. /home/openclaw/.hermes/hermes-agent/venv/bin/python -m pytest tests/honcho_plugin -q348 passed, 3 warningsPYTHONPATH=. /home/openclaw/.hermes/hermes-agent/venv/bin/python -m pytest tests/test_honcho*.py tests/honcho_plugin -q371 passed, 3 warningsgit diff --check upstream/main..HEADWarnings were dependency deprecations from
discord,lark_oapi, andwebsockets.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A
Screenshots / Logs
N/A — CLI/provider behavior covered by tests.
AI-Assisted Disclosure
AI assistance was used to inspect the existing Honcho code paths, prepare the patch, resolve the upstream rebase conflict, and draft this PR body. The final diff was reviewed locally, kept scoped to Honcho session identity/writeback behavior, and validated with the targeted test commands listed above.