fix(peer): hermes peer dm now reaches hidden canonical Bot Chats - #92854
Merged
Merged
Conversation
Bot Mode always hides canonical 'Bot Chat' sessions, but _find_bot_chat's GET /api/sessions listing used the default include_hidden=False path, so the existing hidden row was invisible, _ensure_bot_chat tried to create a duplicate, and the peer DB's UNIQUE(title) guard rejected it — DM failed. - api_server: GET /api/sessions now accepts an exact-title lookup (?title=...) and honors include_hidden=1 ONLY alongside a title filter, so canonical hidden rows resolve without exposing a blanket hidden listing on the client surface. The title needle is pushed into SQL (search_query) so old hidden rows outside the recency window are found. - peer dm client: _find_bot_chat sends title + include_hidden=1; older peers ignore the unknown params and degrade to today's behavior. - Clear diagnosable error on the older-peer duplicate-create rejection, naming the hidden canonical chat and the PATCH hidden:false workaround. - Unit tests (hidden resolution, no duplicate create, older-peer error, older-peer visible fallback) + real-gateway E2E over a real state.db. Root-cause analysis and regression recipe by @kubaboski in #91583. Fixes #91583
Contributor
૮ >ﻌ< ა ci reviewran on a426e1b — fix(peer): resolve hidden canonical Bot Chats in hermes peer
|
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.
hermes peer dmnow reaches hidden canonical Bot Chats — resolving the peer's existing hidden 'Bot Chat' session instead of failing on a duplicate-title create (fixes #91583, defect 1).Problem
Bot Mode always hides canonical chats.
_find_bot_chat()listed the peer's sessions viaGET /api/sessions, whose handler useslist_sessions_rich()with the defaultinclude_hidden=False— so the existing hiddenBot Chatrow was invisible._ensure_bot_chat()then attempted to create a duplicate, the peer DB's UNIQUE(title) guard rejected it with HTTP 400, and the DM failed. Reporter-confirmed workaround: PATCHinghidden:falsemade stockpeer dmwork end-to-end.Changes
gateway/platforms/api_server.py):GET /api/sessionsaccepts an exact-title lookup (?title=...) and honorsinclude_hidden=1only alongside a title filter — canonical hidden rows resolve, but no blanket hidden listing is exposed on this client surface. The title needle is also pushed into SQL (search_query) so a hidden/old canonical row outside the recency window is still found; exact-match is enforced after the substring query.hermes_cli/subcommands/peer.py):_find_bot_chat()sendstitle=Bot Chat&include_hidden=1. Older peers ignore the unknown query params and return the ordinary visible listing, so the single request degrades to exactly the previous behavior — no capability probe, no second request._ensure_bot_chat()now raises a clear error naming the hidden canonical chat, suggesting a peer upgrade, and spelling out thePATCH /api/sessions/<id> {"hidden": false}workaround.tests/hermes_cli/test_peer_cmd.py(hidden row resolves; no duplicate create attempted; older-peer clear error; older-peer visible-chat fallback) + new real-gateway E2Etests/gateway/test_peer_dm_hidden_e2e.py— a realAPIServerAdapteron a real loopback socket over a real SQLitestate.db(own tmp HERMES_HOME) seeded with a hiddenBot Chat, driven by the stock peer-dm client with real key auth; only the model turn is stubbed. A second E2E asserts the server-side bound (include_hiddenwithouttitlestays visible-only).Validation
test_peer_cmd.py,test_peer_dm_hidden_e2e.py)git stash)Peer 'spark' rejected the request (HTTP 400): Title already in use by session botchat_hidden_1test_session_api.py,test_api_server_compaction_projection.py)ruff checkon all 4 changed filesscripts/audit_pr_attribution.py --fixRoot-cause analysis and regression recipe by @kubaboski in #91583.
Infographic