Skip to content

fix(peer): hermes peer dm now reaches hidden canonical Bot Chats - #92854

Merged
teknium1 merged 1 commit into
mainfrom
fix/peer-dm-hidden-bot-chat
Aug 23, 2026
Merged

teknium1 merged 1 commit into
mainfrom
fix/peer-dm-hidden-bot-chat

Conversation

@teknium1

@teknium1 teknium1 commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

hermes peer dm now 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 via GET /api/sessions, whose handler uses list_sessions_rich() with the default include_hidden=False — so the existing hidden Bot Chat row 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: PATCHing hidden:false made stock peer dm work end-to-end.

Changes

  • api_server (gateway/platforms/api_server.py): GET /api/sessions accepts an exact-title lookup (?title=...) and honors include_hidden=1 only 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.
  • peer client (hermes_cli/subcommands/peer.py): _find_bot_chat() sends title=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.
  • Diagnosable older-peer failure: when the duplicate create is rejected with the UNIQUE(title) 400, _ensure_bot_chat() now raises a clear error naming the hidden canonical chat, suggesting a peer upgrade, and spelling out the PATCH /api/sessions/<id> {"hidden": false} workaround.
  • Tests: 4 new unit tests in 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 E2E tests/gateway/test_peer_dm_hidden_e2e.py — a real APIServerAdapter on a real loopback socket over a real SQLite state.db (own tmp HERMES_HOME) seeded with a hidden Bot 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_hidden without title stays visible-only).

Validation

Check Result
New unit + E2E tests (test_peer_cmd.py, test_peer_dm_hidden_e2e.py) ✅ 16 passed
Sabotage proof (fix reverted via git stash) ✅ 4 regression tests FAIL without the fix — E2E reproduces the exact reported trace: Peer 'spark' rejected the request (HTTP 400): Title already in use by session botchat_hidden_1
Existing session API suites (test_session_api.py, test_api_server_compaction_projection.py) ✅ 31 passed
ruff check on all 4 changed files ✅ All checks passed
scripts/audit_pr_attribution.py --fix ✅ all contributor emails mapped

Root-cause analysis and regression recipe by @kubaboski in #91583.

Infographic

Peer DM finds hidden Bot Chats

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
@github-actions

github-actions Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on a426e1b — fix(peer): resolve hidden canonical Bot Chats in hermes peer

⚠️ Warnings

OSV vulnerability scan · View job

7 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 2m53s vs 2m50s (+1.8%). 5 job(s) slower, 7 faster,

  • Python tests / Run tests: -29.0s
  • OS-specific tests / macOS-only tests: -29.0s
  • OS-specific tests / Windows-only tests: -15.0s
  • OSV scan / Scan lockfiles / osv-scan: -7.0s
  • Check contributors / check-attribution: +4.0s

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery area/sessions Session lifecycle, resume, persistence, history sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 23, 2026
@teknium1
teknium1 merged commit 231e613 into main Aug 23, 2026
38 checks passed
@teknium1
teknium1 deleted the fix/peer-dm-hidden-bot-chat branch August 23, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature/Bug]: Support peer-routed @mentions from remote gateways to This-device bots with reply relay

2 participants