[codex] stabilize Hermes Feishu gateway lifecycle - #24337
[codex] stabilize Hermes Feishu gateway lifecycle#24337foras910521-lab wants to merge 6 commits into
Conversation
|
Draft upstream de-dup note after rechecking main on 2026-05-12:
Proposed next step: keep this PR as an umbrella draft, then split or narrow it into focused PRs rather than asking for review in its current shape. |
|
Additional Feishu lifecycle note from local re-diagnosis: this umbrella draft should not be promoted as-is. The local runtime still shows Lark SDK event-loop lifecycle errors ( |
|
Follow-up split: the narrower Feishu websocket readiness work has been separated into draft PR #24358. That PR starts from main, waits for the SDK websocket |
|
Follow-up split: retryable gateway startup degradation has been separated into draft PR #24364. It aligns with #17984 by keeping the process alive in |
What does this PR do?
Stabilizes Hermes gateway behavior around Feishu websocket startup/reconnect, Hindsight local_external health checks, API server memory-provider cleanup, and macOS launchd restart handoff.
The fixes keep retryable Feishu startup failures inside the gateway lifecycle instead of letting service managers spin in restart loops. They also make Hindsight local_external availability reflect the actual local HTTP endpoint, and close memory providers after API server runs.
Root Cause
gateway run --replace, mixing service-manager restart semantics with Hermes replace handoff.local_externalavailability was config-only and could report healthy while127.0.0.1:9177was unreachable.Changes Made
gateway/platforms/feishu.py: wait for websocket readiness, improve disconnect/CLOSE handling, reduce sensitive SDK URL logging, and drop stale replayed messages after reconnect.gateway/run.py: keep the gateway alive for retryable startup platform failures and let the reconnect watcher recover.plugins/memory/hindsight/__init__.py: require reachable/healthor/versionforlocal_externalavailability.gateway/platforms/api_server.py: shut down memory provider infinallyafter run handling.hermes_cli/gateway.py: stop adding--replaceto macOS launchd plist generation.How to Test
venv/bin/python -m ruff check .scripts/run_tests.sh tests/gateway/test_runner_startup_failures.py tests/gateway/test_platform_reconnect.py tests/gateway/test_feishu.py tests/hermes_cli/test_gateway_service.py tests/hermes_cli/test_update_gateway_restart.py tests/plugins/memory/test_hindsight_provider.py tests/gateway/test_api_server.py tests/gateway/test_api_server_runs.pyai.hermes.gatewayand confirm ProgramArguments arepython -m hermes_cli.main gateway runwithout--replace.running, starts the reconnect watcher, and Feishu later returns toconnected.{"status":"healthy","database":"connected"}.Validation Performed
670 passed.origin/mainatdd0923bb8.--replace, Hindsight healthy, Feishu connected.Platform Tested
Notes
This PR intentionally does not modify system networking, Wi-Fi, DNS, proxy services, or third-party proxy app configuration. The stability work stays inside Hermes gateway and provider lifecycle boundaries.