Repository navigation
fix(agent-server): re-probe a Canvas App backend after a missed health probe - #5759
Conversation
…h probe One status probe slower than the 1 s timeout marked a live backend `unhealthy`, and later status calls never probed it again, so the backend stayed offline (and the bridge answered 503) until stop + start. Status now re-probes a live process that only failed a probe and reports `ready` once its health path answers in time; `start` with the same revision does the same instead of echoing the stale status. Exited or failed-to-start backends stay `unhealthy`. Drops the known-bug marker from F28.status-probe-latch. Fixes #5646 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
||||||||||||||||||||
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Review: PR #5759 - re-probe a Canvas App backend after a missed health probe
Scope: In-repo. The change fixes Canvas App backend lifecycle behavior owned by this repository (openhands-agent-server/openhands/agent_server/canvas_extensions/backend.py); no cross-repo move or product/architecture decision is needed. Linked issue #5646 is open with bug + ready-for-dev.
Head reviewed: 0e0bfdea8fdc607df642eb6cf6fdbb9762f98356 (base main).
What the change does
status()now delegates to_refresh_unlocked(), which re-probes a live process that isready, orunhealthyonly because a probe failed (detail == _PROBE_FAILED_DETAIL). A successful probe restoresreadyand clearsdetail; a failed probe keepsunhealthy.- A process that exited (
returncode is not None) still latchesunhealthywith the exit detail and is terminated - unchanged. start()with the same revision on a live process now returns the refreshed status instead of the cached one.
Verification performed
- CI on the exact head is green, including
agent-server-tests,test (24.x),agent-server-api,coverage-report,security, and the build/publish jobs. - The new test
tests/agent_server/canvas_extensions/test_canvas_extension_backend.py::test_status_recovers_after_one_slow_health_probePASSED in theagent-server-testsjob log for this head (I confirmed the PASSED line in the job log). - I could not run the suite in my own sandbox: it has no
/usr/bin/python3, which the test fixture server's shebang requires, so both the new test and the pre-existingtest_prepare_start_logs_stop_and_preserve_datafail identically there. That is a sandbox limitation, not a regression on this head. - Correctness of the fix: the changed branch sets
ready/clears detail on success andunhealthy/sets detail on failure, so a later re-probe still qualifies; a process that exits is still handled by the first branch.ready_endpoint()only returns a livereadybackend, andstop()/_terminate_runtime()reset state and port, so no stalereadyendpoint is served after a stop. - This is a bug fix, not a new endpoint, so it needs no new feature-map owner and no REST contract/deprecation handling; the updated
F28.status-probe-latchbullet correctly drops its known-bug marker.
Non-blocking note
Re-probe eligibility keys off the exact human-readable string _PROBE_FAILED_DETAIL ("Backend health probe failed"). That string is also part of the public BackendStatus.detail contract, so a future rewording of the message would silently disable the recovery path. Routing this through a dedicated internal marker (e.g. a boolean on _Runtime) would be more robust. Not required for this fix.
✅ APPROVED
HUMAN:
This PR proposes a fix for a bug uncovered during the first full agentic run of
verify-agent-server.AGENT:
I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.
Requested by Engel · project thread
Why
GET /api/canvas-extensions/installed/{name}/backendprobes areadybackend's health path with a 1 s timeout. One slow answer set the state tounhealthy, and later status calls never probed again, so a live backend whose/healthanswers at once stayedunhealthy: the bridge answered 503,startwith the same revision echoed the stale status, and onlystop+startrecovered.Summary
status()now also re-probes a live process that isunhealthyonly because a probe failed (not one that exited or failed to start), and setsreadywhen the probe succeeds.start()with the same revision on a live process returns that refreshed status instead of the cached one.start); theF28.status-probe-latchmap bullet loses its known-bug marker.Issue Number
Fixes #5646
How to Test
uv run pytest tests/agent_server/canvas_extensions/test_canvas_extension_backend.py -k slow_health: fails on main (assert 'unhealthy' == 'ready'), passes here.uv run pytest tests/agent_server/canvas_extensions tests/agent_server/test_canvas_extensions_router.py: 186 passed;test_exited_leader_descendant_does_not_block_recovery[status]times out in my sandbox both on main and on this branch (unrelated to this change; it passes or fails identically with and without the diff).qa-f28-flakyserved by a threaded HTTP server):dfd8fe8):control-agent-server map run --file F28 --only F28.status-probe-latch --fresh --repeat 2 --checkout <main>reportsxfailin both attempts. Saved responses: slow probe200 {state: unhealthy, pid: 20124, detail: "Backend health probe failed"}, after/healthis fast again200 {state: unhealthy, pid: 20124, detail: "Backend health probe failed"}.--checkoutreportsxpassin both attempts. Slow probe200 {state: unhealthy, pid: 21786, ...}, after recovery200 {state: ready, pid: 21786, detail: null}(same process, no restart).control-agent-server map checkok,map run --file F28 --only F28.status-probe-latch --freshpasses.uv run pre-commit run --files <changed files>: passes. No API shape change, so the TypeScript client is unaffected.Video/Screenshots
n/a
Type
Notes
A backend that keeps missing probes still reads
unhealthy(each status call re-probes it, at most 1 s per call, as areadybackend already did).🤖 Generated with Claude Code
https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg
Generated by Claude Code
🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:0e0bfde-pythonRun
All tags pushed for this build
About Multi-Architecture Support
0e0bfde-python) is a multi-arch manifest supporting both amd64 and arm640e0bfde-python-amd64) are also available if needed