Repository navigation
Fix #1722: fix: memory_search returned error - #2029
Memtensor-AI wants to merge 1 commit into
Conversation
…bridge Fixes MemTensor#1722 — after the Hermes agent runs for 1-2 hours every memory_search call surfaces `[timeout] memory.search did not respond within 30.0s` and the follow-up sync_turn fails with the same code. Three cooperating Python-side defects were repaired in the JSON-RPC adapter (no wire-protocol change; Node bridge untouched): 1. MemosBridgeClient._read_loop now wraps its dispatch in try/finally and, on any exit (EOF or exception), calls the new _abort_pending helper that wakes every parked waiter with a transport_closed error in <1s — instead of letting each caller time out individually after 30s. 2. MemosBridgeClient.request short-circuits with transport_closed when Popen.poll() reports the subprocess has already exited, preventing writes into an OS-buffered dead pipe. 3. MemTensorProvider._start_bridge_keepalive now reconnects on BridgeError('timeout', …) or any error observed while the subprocess is dead, in addition to the existing transport_closed trigger, via the new _should_reconnect_after_keepalive_failure gate. 4. MemTensorProvider.handle_tool_call routes every read-path memory tool (memos_search / memos_get / memos_timeline / memos_environment / memos_skill_list / memos_skill_get) through _bridge_request_with_retry, mirroring the write-path pattern used by sync_turn. Tests: added 7 new unit cases covering all four layers; 33 bridge tests + 16 pipeline tests pass; ruff check + ruff format clean.
🤖 Open Code ReviewTarget: PR #2029 🔍 OpenCodeReview found 22 issue(s) in this PR. 1.
|
Description
Fixes #1722 — the Hermes plugin's memory_search / turn.end calls stopped returning "[timeout] … did not respond within 30.0s" after the Node bridge subprocess dies quietly. Three cooperating Python-side defects in apps/memos-local-plugin were repaired in the JSON-RPC adapter without touching the wire protocol or the Node bridge.
Layered changes: (1) MemosBridgeClient._read_loop is now wrapped in try/finally and, on any exit (EOF or exception), calls the new _abort_pending helper that wakes every parked JSON-RPC waiter with BridgeError("transport_closed", …) in under one second, instead of letting each caller time out individually after 30 s. (2) MemosBridgeClient.request short-circuits with transport_closed when Popen.poll() reports the subprocess has already exited, preventing writes to a dead pipe. (3) MemTensorProvider._start_bridge_keepalive now reconnects on BridgeError("timeout", …) or any error observed while the subprocess is dead, via the new _should_reconnect_after_keepalive_failure gate — a live subprocess with a generic parse error still does NOT reconnect (avoids reconnect storms). (4) MemTensorProvider.handle_tool_call routes every read-path memory tool (memos_search / memos_get / memos_timeline / memos_environment / memos_skill_list / memos_skill_get) through the new _bridge_request_with_retry helper, mirroring the existing sync_turn write-path reconnect+retry.
Verification: 7 new unit tests added, covering reader-thread abort, fast-fail poll(), the three keepalive branches, and the read-path retry (both success and second-failure). Full test run:
python3 -m unittest tests.python.test_bridge_client tests.python.test_hermes_provider_pipeline→ 49 tests OK;ruff checkandruff format --checkclean.Related Issue (Required): Fixes #1722
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.
Reviewer Checklist