fix: harden gateway status and Photon sidecar startup - #53868
Conversation
(cherry picked from commit faf3cc18c5dbffce680f2dd7154d3adaab980b7d)
(cherry picked from commit dce0a5614ef46f93c9d3d258626584cff42599c2)
(cherry picked from commit 59d9854c833a10af672cf3779498dd80722a7420)
(cherry picked from commit 23c20642cb5477b28e34c15c8ff2a1e19daeeadc)
(cherry picked from commit 5b5d3f0d5097aaf162e7854f4fb9be2523eba6f5)
(cherry picked from commit 541738da54f2673cf2e0e076059fc025c80775e6)
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Observation: High surface area (22 files, +1711/-44)
This PR introduces a new 365-line module (gateway/long_run_status.py) for optional gateway status enrichment, plus changes to gateway/run.py for noisy status filtering and a new handle_busy_turn_choice method.
Positive observations:
- The enrichment module is deliberately fail-soft (docstring is clear)
- Status line validation regex looks correct
- The
_GATEWAY_NOISY_STATUS_REexpansion to cover more platforms is a good improvement - The
handle_busy_turn_choicemethod is well-structured with clear branching
Areas for human review:
- 22 files is above the surface-area threshold for automated confidence
- The new
long_run_status.pymodule integrates with external services (Ollama, OpenRouter) — worth verifying the error handling covers all failure modes - The busy-turn choice feature touches gateway run.py core — confirm no prompt-caching impact
Recommend human review before merge due to surface area.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing several real gateway and Photon failure modes. The Photon premise is confirmed on current main: plugins/platforms/photon/sidecar/index.mjs:225-233 still exits the sidecar when the optional compatibility patch fails.
Problems
gateway/platforms/api_server.py:1292-1297advertises a handoff API but importsclarence_dbby injecting~/.openclaw/workspace/scriptsinto globalsys.path. The repository has noclarence_dbimplementation or declared dependency, andtests/gateway/test_api_server_claude_handoff.py:61-74succeeds only by injecting a fake module. A standard installation would return the endpoint's 500 path.gateway/long_run_status.py:318records the daily OpenRouter call beforeurlopen()succeeds (:320-323), so transient failures consume the quota.
Suggested changes
- Put the handoff write behind a declared, configured Hermes memory-provider surface and advertise/register it only when available; avoid request-time global
sys.pathmutation. - Record cloud usage only after a successful response, with a failed-request quota regression test.
Current main also still waits 180 seconds before the first long-turn notice (gateway/run.py:19336-19342), so the core notification and Photon fixes remain worth salvaging. This is an automated hermes-sweeper review.
| import sys as _sys | ||
| if str(workspace_scripts) not in _sys.path: | ||
| _sys.path.insert(0, str(workspace_scripts)) | ||
| from clarence_db import ClarenceDB # type: ignore |
There was a problem hiding this comment.
This advertised endpoint depends on an undeclared deployment-local module loaded by mutating global sys.path; the repository contains no clarence_db package or dependency, while the test injects a fake module. Please use a declared/configured Hermes memory-provider integration and gate the capability/route when it is unavailable.
| }, | ||
| method="POST", | ||
| ) | ||
| _record_cloud_call() |
There was a problem hiding this comment.
This increments the daily quota before urlopen() succeeds, so timeouts and transport failures consume the allowance. Record the call only after a successful response is accepted, and add a failed-request regression test.
Summary
Test plan
node --check plugins/platforms/photon/sidecar/index.mjsnode --check plugins/platforms/photon/sidecar/patch-spectrum-mixed-attachments.mjs./venv/bin/python -m py_compile gateway/platforms/api_server.py gateway/run.py gateway/long_run_status.py gateway/turn_usage.py gateway/slash_commands.py hermes_cli/config.py hermes_cli/gateway.py hermes_cli/status.py hermes_constants.py plugins/platforms/photon/adapter.py./venv/bin/python -m pytest -q tests/gateway/test_api_server.py tests/gateway/test_api_server_claude_handoff.py tests/gateway/test_gateway_long_running_notifications.py tests/gateway/test_long_run_status_enrichment.py tests/gateway/test_turn_usage.py tests/gateway/test_usage_command.py tests/hermes_cli/test_gateway.py tests/hermes_cli/test_gateway_service.py tests/hermes_cli/test_status_redaction.py tests/plugins/platforms/photon/test_mention_gating.py tests/plugins/platforms/photon/test_spectrum_patch.py tests/test_hermes_constants.py -o 'addopts='Local result: 513 passed, 112 warnings.