Stop publishing system stats for offline robots - #91
Merged
Conversation
The framework publishes system stats for every robot on every execution loop iteration, including robots the connector reports as offline. InOrbit answers those stats with a get_state request, the online status callback replies "offline", and the retained status message refreshes the robot's offline timestamp -- so an offline robot's offline_ts keeps moving forward for as long as the connector runs. Gate the publish on _is_fleet_robot_online(robot_id) inside __publish_pending_system_stats, where the stored-stats and default-values paths converge, so stats explicitly stored via publish_robot_system_stats() are dropped too rather than only the framework defaults. Nothing is lost by skipping: the forced state request only helps when the robot is online but InOrbit believes otherwise. The online check is subclass code and now runs once per robot per loop iteration instead of only on get_state, so it falls back to publishing if it raises (matching the edge-sdk's own get_state fallback) and the docstrings now require it to be cheap and non-blocking. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
leandropineda
approved these changes
Aug 27, 2026
Co-authored-by: Leandro <leandropineda.lp@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
__publish_pending_system_stats()runs once per execution loop iteration and publishes system stats for every robot with an active session — including robots the connector reports as offline.That drives a loop in the platform:
get_stateto resolve the discrepancy_handle_get_statecalls our online status callback, getsFalse, and publishes a retained offline status messageSo the robot's offline timestamp keeps moving forward for as long as the connector runs, and an offline robot never looks like it has been offline for any length of time.
Fix
Gate the publish on
_is_fleet_robot_online(robot_id)inside__publish_pending_system_stats, which is where the stored-stats path and the default-values path converge. One guard covers both, so stats explicitly stored viapublish_robot_system_stats()are dropped for an offline robot too — not just the framework's zeroed/host defaults. Guarding only the public setter would have left the defaults path still refreshing the timestamp.Nothing is lost by skipping: the forced state request only helps when the robot is online but InOrbit believes otherwise. For a robot we already consider offline, the reply just re-asserts offline.
Notes for review
get_state. It is subclass code, so it is wrapped intry/exceptand falls back to publishing on error — matching the edge-sdk's ownget_statefallback (robot.py:777-781), so a broken health check keeps today's behaviour instead of silently muting a robot. The_is_fleet_robot_online()/_is_robot_online()docstrings and the docs now require the implementation to be cheap and non-blocking.get_state. InOrbit still detects offline through its own data timeout, and a connector that keeps publishing pose or key-values for a dead robot will keep it looking online regardless.Testing
test_publish_pending_system_stats_skips_offline_robots— offline robot gets no publish, its stored stats are dropped, pending dict still clearedtest_publish_pending_system_stats_publishes_when_online_check_fails— raising online check still publishes for every robot🤖 Generated with Claude Code