fix(gateway): clear stale status for disabled platforms on startup - #63101
fix(gateway): clear stale status for disabled platforms on startup#63101mudrii wants to merge 1 commit into
Conversation
A platform explicitly disabled in the current config could retain a prior run's connected/paused/fatal entry (with stale error metadata) in gateway_state.json. The startup connect loop skips disabled platforms with `continue`, so nothing overwrote those entries and `hermes status`/readiness probes reported a turned-off platform as live. write_runtime_status gains a `disabled_platforms` argument that reconciles each named platform to a clean state=disabled record with error_code/error_message cleared, without touching enabled platforms or a platform updated in the same call. Gateway startup collects the disabled platforms from config and reconciles them before the connect loop runs.
There was a problem hiding this comment.
Pull request overview
This PR improves the gateway’s runtime status persistence so gateway_state.json no longer reports stale “connected/paused/fatal” statuses for platforms that are explicitly disabled in the current gateway run. It does this by reconciling disabled platforms to a clean state="disabled" record early in startup and by extending write_runtime_status() to support that reconciliation.
Changes:
- Extend
gateway.status.write_runtime_status()with adisabled_platformsargument to mark disabled platforms asdisabledand clear stale error metadata. - Reconcile all explicitly disabled platforms during
GatewayRunner.start()before connecting enabled adapters. - Add regression tests covering disabled-platform reconciliation, preservation of enabled entries, missing-entry creation, and coexistence with per-platform updates.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
gateway/status.py |
Adds disabled-platform reconciliation support to write_runtime_status(). |
gateway/run.py |
Calls disabled-platform reconciliation during gateway startup before adapter connects. |
tests/gateway/test_status.py |
Adds tests for disabled-platform reconciliation behaviors and edge cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if disabled_platforms is not _UNSET: | ||
| # Reconcile every explicitly-disabled platform to a clean "disabled" | ||
| # record for this run, clearing stale connection/error metadata a prior | ||
| # run may have left behind. Never touch a platform that was updated in | ||
| # THIS call (e.g. an enabled platform mid-connect) — the explicit | ||
| # `platform=` argument wins. | ||
| now = _utc_now_iso() | ||
| for name in disabled_platforms or []: | ||
| if name == platform: | ||
| continue | ||
| payload["platforms"][name] = { | ||
| "state": "disabled", | ||
| "error_code": None, | ||
| "error_message": None, | ||
| "updated_at": now, | ||
| } | ||
|
|
|
Thanks for tracing the stale-state path; current main does still skip disabled platform configs at Problems
Suggested changes
Automated hermes-sweeper review. |
What does this PR do?
Prevents
gateway_state.jsonfrom reporting a platform as connected, paused, or failed after that platform has been explicitly disabled for the current gateway run.The startup path now reconciles disabled platforms to a clean
state="disabled"record and clears stale error metadata before connecting enabled adapters.Related Issue
N/A — reproduced during a gateway state audit.
Type of Change
Changes Made
write_runtime_status.How to Test
./scripts/run_tests.sh tests/gateway/test_status.py.Checklist
Code
pytest tests/ -qsuite locally; repository-wide collection requires optional ACP/messaging dependencies not present in the minimal dev environment. The canonical changed-file suite passes.Documentation & Housekeeping
cli-config.yaml.example: N/A.CONTRIBUTING.md/AGENTS.md: N/A.