Add agent health monitoring and graceful shutdown support#15
Open
Add agent health monitoring and graceful shutdown support#15
Conversation
Contributor
Author
Code Review Summary0 blockers, 2 issues, 3 suggestions, 1 nit — reviewed by correctness, security, devdocs, testing, architecture agents. Fixed (2bed82d)
Skipped
|
2bed82d to
d22e5cb
Compare
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.
Summary
Phase 2 agent-side changes for the egress agent pull model improvements — goodbye event handling, graceful shutdown, heartbeat during backpressure, and instance ID tracking.
Goodbye Event Handling:
EventsClienthandles newgoodbyeSSE event type from orchestratorBaseEgressAgentService._handle_goodbyetriggers graceful shutdown on goodbyeGraceful Shutdown:
_trigger_graceful_shutdown: notifies orchestrator, stops threads, signals process to exitregister_signal_handlers: registers SIGTERM/SIGINT handlers (called from gunicornpost_worker_inithook or local dev main)_shutting_downflag prevents double shutdown when both goodbye and signal paths fireBackpressure Heartbeat:
OperationsPollersends heartbeat to orchestrator during backpressure to maintain activity trackingBackendClient.send_heartbeat:POST /api/v1/agent/heartbeatShutdown Notification:
BackendClient.notify_shutdown:POST /api/v1/agent/shutdown(15s timeout)Instance ID (Phase 3 prep):
BackendClientgenerates a UUID instance ID on constructionx-mcd-agent-instance-idheader (orchestrator ignores it for now)extra_headersonSSEClientReceiverOther:
stop())Test plan
kill -TERM <pid>→ agent notifies orchestrator → process exitsDependencies