Skip to content

fix(simplex): unwrap resp envelope for inbound, address DMs by name, stop idle reconnect churn - #37045

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-ecc3c998
Jun 1, 2026
Merged

fix(simplex): unwrap resp envelope for inbound, address DMs by name, stop idle reconnect churn#37045
teknium1 merged 2 commits into
mainfrom
hermes/hermes-ecc3c998

Conversation

@teknium1

@teknium1 teknium1 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

SimpleX bidirectional messaging now works: inbound messages reach the agent and replies get delivered.

Salvages @maxcz79's PR #27120 onto current main. Three adapter bugs, confirmed live by a community user (Grieschbrei) whose daemon-event shape log nailed the exact path.

Root cause (inbound): the daemon sends {"resp": {"type": "newChatItems", "chatItems": [...]}} but the adapter read event["chatItems"] (top-level, always empty), so every inbound item was silently dropped before becoming a gateway message.

Changes

  • plugins/platforms/simplex/adapter.py:
    • _handle_event: unwrap the resp envelope before dispatch, read resp["chatItems"]. Top-level shape still handled for back-compat.
    • Direct replies addressed by display name (@Name) instead of @[id]/@[Name] — the SimpleX CLI treats brackets literally, so @[4] never delivered.
    • Inbound routing split: chat_id = display name (reply target), user_id/sender_id = numeric contactId (stable auth key).
    • _health_monitor: stop force-reconnecting a quiet-but-healthy WebSocket. The websockets client already sends protocol pings; treating an absence of chat events as "stale" caused needless reconnect churn (the "WS idle for 120s, forcing reconnect" loop the reporter saw).
  • scripts/release.py: AUTHOR_MAP entry for the contributor email (CI gate).

Validation

Before After
Inbound resp.chatItems shape dropped (0 dispatched) dispatched to agent
Outbound DM @[4] — not delivered @DisplayName — delivered
Auth key (user_id) n/a numeric contactId (unchanged path)
Idle quiet WS force-reconnect loop no reconnect
  • Targeted suite: tests/gateway/test_simplex_plugin.py 28/28 pass.
  • E2E against the reporter's exact event shape: inbound extracted, user_id="4" (numeric, auth-safe), chat_id="Grieschbrei" (reply routing), outbound @Grieschbrei hello back, top-level back-compat shape still works.

Closes the inbound/outbound/idle-reconnect issues from PR #27120 and #26433. #26433 (@ruangraung) independently found the same nesting + bracket bugs first, credited below.

Contributor authorship preserved via rebase-merge.

Infographic

simplex-gateway-fix

maxcz79 and others added 2 commits June 1, 2026 15:17
Do not treat lack of application-level SimpleX events as a stale WebSocket. The websockets client already uses protocol ping/pong for connection liveness, so quiet but healthy connections should not be closed by the health monitor.
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-ecc3c998 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9586 on HEAD, 9583 on base (🆕 +3)

🆕 New issues (2):

Rule Count
unresolved-attribute 1
invalid-argument-type 1
First entries
plugins/platforms/simplex/adapter.py:311: [unresolved-attribute] unresolved-attribute: Attribute `get` is not defined on `None` in union `Unknown | None | dict[Unknown, Unknown]`
plugins/platforms/simplex/adapter.py:308: [invalid-argument-type] invalid-argument-type: Argument to bound method `SimplexAdapter._handle_new_chat_item` is incorrect: Expected `dict[Unknown, Unknown]`, found `Unknown | None | dict[Unknown, Unknown]`

✅ Fixed issues (1):

Rule Count
unresolved-import 1
First entries
tests/gateway/test_simplex_plugin.py:312: [unresolved-import] unresolved-import: Cannot resolve imported module `websockets.client`

Unchanged: 4966 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1
teknium1 merged commit f1237aa into main Jun 1, 2026
30 of 31 checks passed
@teknium1
teknium1 deleted the hermes/hermes-ecc3c998 branch June 1, 2026 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants