Skip to content

fix(agent-server): re-probe a Canvas App backend after a missed health probe - #5759

Merged
enyst merged 1 commit into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-backend-probe-latch
Oct 13, 2026
Merged

enyst merged 1 commit into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-backend-probe-latch

Conversation

@enyst

@enyst enyst commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

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}/backend probes a ready backend's health path with a 1 s timeout. One slow answer set the state to unhealthy, and later status calls never probed again, so a live backend whose /health answers at once stayed unhealthy: the bridge answered 503, start with the same revision echoed the stale status, and only stop + start recovered.

Summary

  • status() now also re-probes a live process that is unhealthy only because a probe failed (not one that exited or failed to start), and sets ready when the probe succeeds.
  • start() with the same revision on a live process returns that refreshed status instead of the cached one.
  • Unit test with a real backend subprocess (slow probe, still slow, recovery, then the same via start); the F28.status-probe-latch map 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).
  • Map proof through the real agent server (Linux sandbox, fixture backend qa-f28-flaky served by a threaded HTTP server):
    • main (dfd8fe8): control-agent-server map run --file F28 --only F28.status-probe-latch --fresh --repeat 2 --checkout <main> reports xfail in both attempts. Saved responses: slow probe 200 {state: unhealthy, pid: 20124, detail: "Backend health probe failed"}, after /health is fast again 200 {state: unhealthy, pid: 20124, detail: "Backend health probe failed"}.
    • this branch: same command without --checkout reports xpass in both attempts. Slow probe 200 {state: unhealthy, pid: 21786, ...}, after recovery 200 {state: ready, pid: 21786, detail: null} (same process, no restart).
    • with the marker removed: control-agent-server map check ok, map run --file F28 --only F28.status-probe-latch --fresh passes.
  • uv run pre-commit run --files <changed files>: passes. No API shape change, so the TypeScript client is unaffected.

Video/Screenshots

n/a

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

A backend that keeps missing probes still reads unhealthy (each status call re-probes it, at most 1 s per call, as a ready backend 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

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:0e0bfde-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-0e0bfde-python \
  ghcr.io/openhands/agent-server:0e0bfde-python

All tags pushed for this build

ghcr.io/openhands/agent-server:0e0bfde-golang-amd64
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-golang-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-golang-amd64
ghcr.io/openhands/agent-server:0e0bfde-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:0e0bfde-golang-arm64
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-golang-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-golang-arm64
ghcr.io/openhands/agent-server:0e0bfde-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:0e0bfde-java-amd64
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-java-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-java-amd64
ghcr.io/openhands/agent-server:0e0bfde-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:0e0bfde-java-arm64
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-java-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-java-arm64
ghcr.io/openhands/agent-server:0e0bfde-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:0e0bfde-python-amd64
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-python-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-python-amd64
ghcr.io/openhands/agent-server:0e0bfde-python-node-runtime-amd64
ghcr.io/openhands/agent-server:0e0bfde-python-arm64
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-python-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-python-arm64
ghcr.io/openhands/agent-server:0e0bfde-python-node-runtime-arm64
ghcr.io/openhands/agent-server:0e0bfde-python-minimal-amd64
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-python-minimal-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-python-minimal-amd64
ghcr.io/openhands/agent-server:0e0bfde-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:0e0bfde-python-minimal-arm64
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-python-minimal-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-python-minimal-arm64
ghcr.io/openhands/agent-server:0e0bfde-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:0e0bfde-python-slim-amd64
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-python-slim-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-python-slim-amd64
ghcr.io/openhands/agent-server:0e0bfde-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:0e0bfde-python-slim-arm64
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-python-slim-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-python-slim-arm64
ghcr.io/openhands/agent-server:0e0bfde-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:0e0bfde-golang
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-golang
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-golang
ghcr.io/openhands/agent-server:0e0bfde-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:0e0bfde-java
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-java
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-java
ghcr.io/openhands/agent-server:0e0bfde-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:0e0bfde-python-minimal
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-python-minimal
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-python-minimal
ghcr.io/openhands/agent-server:0e0bfde-python-node-runtime-minimal
ghcr.io/openhands/agent-server:0e0bfde-python-slim
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-python-slim
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-python-slim
ghcr.io/openhands/agent-server:0e0bfde-python-node-runtime-slim
ghcr.io/openhands/agent-server:0e0bfde-python
ghcr.io/openhands/agent-server:0e0bfdea8fdc607df642eb6cf6fdbb9762f98356-python
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-backend-probe-latch-python
ghcr.io/openhands/agent-server:0e0bfde-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 0e0bfde-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 0e0bfde-python-amd64) are also available if needed

…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
@enyst enyst self-assigned this Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server/canvas_extensions
   backend.py5265989%52–53, 146, 153, 157–159, 174, 177, 206, 228, 256–258, 261–263, 266–267, 271, 278, 284, 289–291, 314, 320, 324, 328, 337, 340, 347, 371–372, 375, 394–396, 423–424, 504–505, 554, 560–561, 588, 591–592, 607–608, 617, 622, 629, 637, 650, 713–714, 759, 795
TOTAL497341986560% 

@enyst
enyst marked this pull request as ready for review October 13, 2026 21:26
@enyst
enyst requested a review from all-hands-bot October 13, 2026 21:29

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 is ready, or unhealthy only because a probe failed (detail == _PROBE_FAILED_DETAIL). A successful probe restores ready and clears detail; a failed probe keeps unhealthy.
  • A process that exited (returncode is not None) still latches unhealthy with 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_probe PASSED in the agent-server-tests job 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-existing test_prepare_start_logs_stop_and_preserve_data fail 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 and unhealthy/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 live ready backend, and stop()/_terminate_runtime() reset state and port, so no stale ready endpoint 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-latch bullet 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

@enyst
enyst merged commit 6a298a4 into main Oct 13, 2026
56 of 57 checks passed
@enyst
enyst deleted the claude/umbrella-bug-fixes-tgz9ai-backend-probe-latch branch October 13, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Canvas App backend stays 'unhealthy' after one slow health probe instead of returning to 'ready'

3 participants