Skip to content

feat(sdk): expose restart recovery provenance and outcome dispositions - #6778

Merged
simonrosenberg merged 1 commit into
mainfrom
crash-recovery-provenance-6769
Nov 12, 2026
Merged

simonrosenberg merged 1 commit into
mainfrom
crash-recovery-provenance-6769

Conversation

@simonrosenberg

@simonrosenberg simonrosenberg commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

A restart recovery error and the original tool's late completion can coexist in the raw log. Recording consumers need machine-readable recovery provenance and the SDK's existing first-outcome selection rule without matching error text or rewriting events.


AGENT:

Why

A restart recovery error and the original tool's late completion can coexist in the raw log. Recording consumers need machine-readable recovery provenance and the SDK's existing first-outcome selection rule without matching error text or rewriting events.

Summary

  • Add optional AgentErrorEvent.recovery_reason="server_restart" on the restart recovery producer, preserving the INTERNAL, non-retryable classification and legacy event loading.
  • Expose immutable ObservationDisposition records through get_observation_dispositions() and share selection with ObservationUniquenessProperty.
  • Cover both outcome orders, ordinary observations/rejections/errors, legacy persistence, the real restart/late-completion lifecycle, and existing REST/WebSocket delivery. Document the contract in docs(sdk): explain recording outcome selection and restart provenance docs#1127.

REST API contract changes

Compared with base OpenAPI 9f7d5cb11b12 for public /api/** paths.

--- base public OpenAPI
+++ head public OpenAPI
@@ -1140,0 +1141 @@
+schema AgentErrorEvent property recovery_reason optional schema=anyOf=[type="string" const="server_restart",type="null"]

Issue Number

Fixes #6769

How to Test

uv run pytest tests/sdk/context/view tests/sdk/event tests/cross/test_conversation_lease_behavior.py --show-capture=no -q
uv run pytest tests/cross/test_remote_conversation_live_server.py::test_recovery_provenance_served_over_http_and_websocket --show-capture=no -q
uv run pytest tests/agent_server/test_event_service.py -k TestEventServiceStartWithRunningStatus --show-capture=no -q

318 relevant tests passed: 312 view/event/lifecycle tests, the live HTTP/WebSocket test, and five server startup tests. All changed files pass pre-commit (including Pyright).

The adjacent test_start_initializes_workspace_as_git_repo fails because the fresh workspace lacks .git; it fails identically on unchanged base commit 9f7d5cb11, verified in a separate detached worktree using the same dependency environment. This PR does not change workspace git initialization.

The lifecycle test persists an in-flight action, reloads a RUNNING conversation through lease takeover, observes the real recovery producer, appends the late completion, and verifies canonical selection against View.from_events() while preserving the original persisted event bytes.

Video/Screenshots

Design Doc

Type

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

Notes

The disposition reports observation uniqueness in input order. Branch selection, condensation, and other view filters remain separate. There are no new endpoints, failure classification values, or TypeScript client mirrors. Companion docs: OpenHands/docs#1127.


🐳 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:69a800c-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:69a800c-golang-amd64
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-golang-amd64
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-golang-amd64
ghcr.io/openhands/agent-server:69a800c-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:69a800c-golang-arm64
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-golang-arm64
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-golang-arm64
ghcr.io/openhands/agent-server:69a800c-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:69a800c-java-amd64
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-java-amd64
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-java-amd64
ghcr.io/openhands/agent-server:69a800c-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:69a800c-java-arm64
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-java-arm64
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-java-arm64
ghcr.io/openhands/agent-server:69a800c-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:69a800c-python-amd64
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-python-amd64
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-python-amd64
ghcr.io/openhands/agent-server:69a800c-python-node-runtime-amd64
ghcr.io/openhands/agent-server:69a800c-python-arm64
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-python-arm64
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-python-arm64
ghcr.io/openhands/agent-server:69a800c-python-node-runtime-arm64
ghcr.io/openhands/agent-server:69a800c-python-minimal-amd64
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-python-minimal-amd64
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-python-minimal-amd64
ghcr.io/openhands/agent-server:69a800c-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:69a800c-python-minimal-arm64
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-python-minimal-arm64
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-python-minimal-arm64
ghcr.io/openhands/agent-server:69a800c-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:69a800c-python-slim-amd64
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-python-slim-amd64
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-python-slim-amd64
ghcr.io/openhands/agent-server:69a800c-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:69a800c-python-slim-arm64
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-python-slim-arm64
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-python-slim-arm64
ghcr.io/openhands/agent-server:69a800c-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:69a800c-golang
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-golang
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-golang
ghcr.io/openhands/agent-server:69a800c-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:69a800c-java
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-java
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-java
ghcr.io/openhands/agent-server:69a800c-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:69a800c-python-minimal
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-python-minimal
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-python-minimal
ghcr.io/openhands/agent-server:69a800c-python-node-runtime-minimal
ghcr.io/openhands/agent-server:69a800c-python-slim
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-python-slim
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-python-slim
ghcr.io/openhands/agent-server:69a800c-python-node-runtime-slim
ghcr.io/openhands/agent-server:69a800c-python
ghcr.io/openhands/agent-server:69a800caf7192b88dd48546b3cd9b70999401ed6-python
ghcr.io/openhands/agent-server:crash-recovery-provenance-6769-python
ghcr.io/openhands/agent-server:69a800c-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 69a800c-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., 69a800c-python-amd64) are also available if needed

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@simonrosenberg
simonrosenberg marked this pull request as ready for review November 12, 2026 09:23
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   event_service.py112311090%165, 171–172, 305–306, 436, 440, 445, 472, 479, 514, 517–518, 522–523, 534, 540, 611–612, 618, 674–675, 796, 816, 843, 852, 876–877, 881, 929, 964, 968–969, 1004, 1011, 1017, 1231, 1261, 1264, 1342, 1360, 1374, 1544–1545, 1600, 1634, 1790–1793, 1797, 1840, 1844, 1851, 1865, 1879, 1903, 1950–1952, 2036, 2058, 2061–2062, 2087, 2093, 2095, 2111, 2113, 2120, 2128, 2130–2131, 2135, 2152, 2204, 2210, 2219–2220, 2227, 2242, 2253, 2294–2297, 2377–2378, 2380–2387, 2389–2390, 2400, 2411, 2427–2428, 2439, 2466, 2472, 2478, 2487–2488, 2510, 2520
openhands-sdk/openhands/sdk/event/llm_convertible
   observation.py82693%129–130, 135, 207–208, 213
TOTAL55470872784% 

@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).

Assessment: no material findings.

The change stays squarely in this repository's ownership (SDK events, view selection, agent-server recovery producer, canonical REST/WebSocket delivery) and delivers the issue #6769 acceptance criteria on the current head:

  • AgentErrorEvent.recovery_reason is additive and optional (Literal["server_restart"] | None, default None), so legacy payloads without it still load under the model's extra="forbid" config; the legacy-payload round-trip test through the real EventLog path covers this, and the live-server test proves the field flows through HTTP retrieval and WebSocket delivery.
  • get_observation_dispositions() and ObservationUniquenessProperty.enforce now share one selection implementation, so the disposition's canonical choice agreeing with the LLM view is structural, not merely tested. The refactored enforce is semantically identical to the previous seen-set loop (first observation-like event per tool_call_id in view order wins).
  • Provenance is set only at the restart-recovery producer in event_service.py; other AgentErrorEvent producers (pause orphans, validation failures, tool execution errors, parallel executor) correctly remain untagged, and the INTERNAL / non-retryable classification is preserved and asserted.
  • The disposition surface is read-only: frozen dataclass, and tests assert neither model_dump_json() output nor persisted event bytes change.
  • The restart/late-completion lifecycle test exercises the real path (persisted in-flight action, RUNNING reload through lease takeover, real recovery producer, late completion, canonical selection against View.from_events()).

CI on this head is green for all review-gating checks (pre-commit, sdk-tests, cross-tests, agent-server-tests, REST API/OpenAPI, integration-test, public-type-budget). I additionally ran the PR's focused test groups in the workspace: 309 view/event tests, 3 lease-behavior lifecycle tests, the live HTTP/WebSocket provenance test, and 6 TestEventServiceStartWithRunningStatus startup tests all pass.

The recording-consumer contract is documented in the companion PR OpenHands/docs#1127 (open at review time). No new endpoints, failure-classification values, or TypeScript client mirrors are needed for an additive optional field, consistent with the PR notes.

✅ APPROVED

@all-hands-bot
all-hands-bot requested a review from enyst November 12, 2026 09:31
@simonrosenberg
simonrosenberg merged commit 2cca5ba into main Nov 12, 2026
53 checks passed
@simonrosenberg
simonrosenberg deleted the crash-recovery-provenance-6769 branch November 12, 2026 09:56
enyst added a commit that referenced this pull request Nov 12, 2026
- F05.restart-hard-tool-call: a hard restart during a tool call ends it
  with recovery_reason server_restart (#6778).
- F06.send-during-tool-call (known bug #6729) and F07.snapshot-compact-stats
  (known bug #6741): open bugs filed since the baseline, reproduced live.
- F02.default-bind uses LiteLLM's local cost map offline (#6749 is F24's).
- F09: claude-agent-acp 0.99.1 (#5994) answers an unknown model with 400 and
  offers effort levels on haiku.
- F10.fork-run-memory: match DeepSeek's 'Authentication Fails' wording.
- F21.ts-payload-types: #6747 is fixed in v1.62.0; the known-bug marking goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ArwwNZe7p1P7oMgnFNYcy
enyst added a commit that referenced this pull request Nov 12, 2026
- F25.long-description: a long skill description is cut with an
  invoke_skill pointer and no file path (#6664).
- F26.conversation-resume-disabled drives the MCP half: a disabled ambient
  plugin's MCP server is dropped on resume (#5756).
- F27.tool-schema-keywords: known bug #6766, reproduced through the server;
  F27 owns tool/schema.py; F27.import-modules uses LiteLLM's local cost map
  under env -i (#6749).
- F31.crash-tool-call checks recovery_reason and classification (#6778).
- F34.manager-batch-over-limit: the TypeScript client splits more than 99
  ids into batches (#6771).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ArwwNZe7p1P7oMgnFNYcy
enyst added a commit that referenced this pull request Nov 12, 2026
- S02: deepseek-v4.1-flash is vision-capable (#5524); new Responses bullets
  for the streamed reasoning summary (known failure #6695) and cache-write
  tokens (known failure #6691), with the fake provider's new opt-ins.
- S06.observation-dispositions: after recovery the first outcome per tool
  call is canonical and a late observation leaves the view (#6778).
- S08.ambient-plugins: a disabled ambient plugin's skills and MCP servers are
  dropped on resume (#5756).
- S04.cancel-token captures the token from an event callback.
- Known failures that reproduced today carry today's date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ArwwNZe7p1P7oMgnFNYcy
@enyst enyst mentioned this pull request Nov 12, 2026
1 of 5 tasks
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.

Expose crash-recovery outcome provenance for native recording consumers

2 participants