Skip to content

fix(agent-server): preserve legacy conversations in Docker catalogs - #5128

Merged
neubig merged 8 commits into
mainfrom
fix/docker-catalog-legacy-local
Sep 17, 2026
Merged

neubig merged 8 commits into
mainfrom
fix/docker-catalog-legacy-local

Conversation

@neubig

@neubig neubig commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

I tested this on my own canvas and it is working properly.


AGENT:

Why

Switching an existing installation to Docker runtime mode made every historical local conversation disappear: catalog loading requested a Docker identity cipher for each directory, and legacy local conversations have no provisioning manifest.

Summary

  • Fall back to the host cipher only when a Docker provisioning identity is explicitly absent; present Docker identities retain their isolated per-conversation cipher, and invalid identities still fail closed.
  • Add ConversationInfo.runtime_info to catalog search, detail, and batch responses. Historical local entries report missing and can_resume=false; stopped provisioned Docker conversations remain missing and resumable.
  • Serve read-only event history directly from the shared persisted event log without hydrating a workspace or acquiring a runtime lease; keep event writes and sockets routed to the Docker runtime.
  • Cover the mixed historical-local/new-Docker catalog, cipher boundary, runtime status distinction, and response shape with focused tests.

REST API contract changes

Compared with base OpenAPI 632894b716ef for public /api/** paths.

--- base public OpenAPI
+++ head public OpenAPI
@@ -1326,0 +1327 @@
+schema ConversationInfo property runtime_info optional schema=anyOf=[ConversationRuntimeInfo,type="null"]

Issue Number

Closes #5127.

How to Test

  1. Run uv run pytest -q tests/agent_server/docker_runtime/test_provisioning.py tests/agent_server/docker_runtime/test_registry.py tests/agent_server/docker_runtime/test_routes.py tests/agent_server/test_conversation_router.py (112 passed locally).
  2. Run uv run pytest -q tests/agent_server/test_api.py tests/agent_server/test_models.py tests/agent_server/test_openapi_discriminator.py tests/agent_server/test_conversation_service.py (171 passed locally).
  3. Run uv run pre-commit run --files <changed files> and npm run format:check && npm run build in clients/typescript.
  4. For the end-to-end upgrade case, start once in local runtime mode to create a conversation, restart with Docker runtime mode, and call GET /api/conversations/search. The local record remains present with runtime_info={"runtime_status":"missing","can_resume":false,"runtime_error":null}; a provisioned stopped Docker record reports missing with can_resume=true.
  5. Open the historical conversation through Canvas. GET /api/conversations/{id}/events/search returns 200 from persisted storage, no runtime WebSocket is opened, and the read-only history renders with the archived banner.
  6. Open a live Docker conversation through Canvas. Its event history is read from the append-only persisted log and returns 200 while writes and sockets remain routed to the child server. Stop the runtime and reload the same conversation: history still returns 200 and does not start a container. The focused routing/runtime suite passes (141 tests), as do all 114 EventService tests.

Video/Screenshots

With SDK main, Docker mode omits the historical host-local conversation from the catalog:

Before

With this branch and Canvas #17500, the same persisted conversation is visible as read-only history:

After

Design Doc

The API reuses the existing generic ConversationRuntimeInfo model. Canvas can map only runtime_status === "missing" && can_resume === false to its archived/MISSING presentation without adding Docker-specific UI fields.

Type

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

Notes

The local REST compatibility check reported no breaking changes. oasdiff was unavailable locally, so CI remains authoritative for its comparison.


🐳 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:5bb12b2-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:5bb12b2-golang-amd64
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-golang-amd64
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-golang-amd64
ghcr.io/openhands/agent-server:5bb12b2-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:5bb12b2-golang-arm64
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-golang-arm64
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-golang-arm64
ghcr.io/openhands/agent-server:5bb12b2-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:5bb12b2-java-amd64
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-java-amd64
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-java-amd64
ghcr.io/openhands/agent-server:5bb12b2-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:5bb12b2-java-arm64
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-java-arm64
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-java-arm64
ghcr.io/openhands/agent-server:5bb12b2-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:5bb12b2-python-amd64
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-python-amd64
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-python-amd64
ghcr.io/openhands/agent-server:5bb12b2-python-node-runtime-amd64
ghcr.io/openhands/agent-server:5bb12b2-python-arm64
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-python-arm64
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-python-arm64
ghcr.io/openhands/agent-server:5bb12b2-python-node-runtime-arm64
ghcr.io/openhands/agent-server:5bb12b2-python-minimal-amd64
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-python-minimal-amd64
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-python-minimal-amd64
ghcr.io/openhands/agent-server:5bb12b2-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:5bb12b2-python-minimal-arm64
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-python-minimal-arm64
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-python-minimal-arm64
ghcr.io/openhands/agent-server:5bb12b2-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:5bb12b2-python-slim-amd64
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-python-slim-amd64
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-python-slim-amd64
ghcr.io/openhands/agent-server:5bb12b2-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:5bb12b2-python-slim-arm64
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-python-slim-arm64
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-python-slim-arm64
ghcr.io/openhands/agent-server:5bb12b2-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:5bb12b2-golang
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-golang
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-golang
ghcr.io/openhands/agent-server:5bb12b2-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:5bb12b2-java
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-java
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-java
ghcr.io/openhands/agent-server:5bb12b2-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:5bb12b2-python-minimal
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-python-minimal
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-python-minimal
ghcr.io/openhands/agent-server:5bb12b2-python-node-runtime-minimal
ghcr.io/openhands/agent-server:5bb12b2-python-slim
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-python-slim
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-python-slim
ghcr.io/openhands/agent-server:5bb12b2-python-node-runtime-slim
ghcr.io/openhands/agent-server:5bb12b2-python
ghcr.io/openhands/agent-server:5bb12b2bc059e31031a6325fc5ef2389e77e641c-python
ghcr.io/openhands/agent-server:fix-docker-catalog-legacy-local-python
ghcr.io/openhands/agent-server:5bb12b2-python-node-runtime

About Multi-Architecture Support

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

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   conversation_router.py2691594%193, 320, 402, 448, 508, 678–681, 693–696, 736, 774
   conversation_service.py125613289%202–203, 212, 239–240, 244–245, 250, 396–397, 400–401, 417–418, 432, 599–600, 661, 765, 772–773, 874, 960, 1011–1012, 1019, 1051–1052, 1068, 1099, 1103, 1117, 1150–1153, 1159–1160, 1169, 1171, 1237, 1247, 1272, 1280–1281, 1285–1286, 1294, 1321, 1327, 1421, 1427, 1432, 1438, 1446–1447, 1456–1459, 1468, 1480, 1488, 1534, 1540–1541, 1544–1546, 1573, 1625, 1674–1675, 1679, 1769–1770, 1841, 1896–1898, 1900–1901, 1904–1905, 1942, 2016–2017, 2049, 2054, 2061–2063, 2066–2067, 2071–2073, 2076–2077, 2081–2083, 2086–2087, 2116, 2125, 2168, 2178–2180, 2240, 2243, 2270, 2280, 2285–2288, 2302, 2313, 2325–2326, 2358, 2454, 2511, 2569, 2584–2585, 2717, 2963, 3016, 3019
   dependencies.py46296%57, 85
   event_router.py56886%196–199, 209–210, 232–233
   event_service.py92012087%184–185, 307, 311, 316, 343, 350, 384, 387–388, 392–393, 404, 410, 439–441, 444–445, 534–535, 656, 676, 703, 727–728, 732, 740, 743, 759, 791, 802, 809, 815, 875, 878, 893–894, 982, 1012, 1015, 1053, 1093, 1111, 1125, 1268, 1388–1391, 1395, 1435, 1439, 1446, 1460, 1475, 1522–1524, 1604, 1629, 1635, 1637, 1647, 1649, 1656, 1666, 1668–1669, 1673, 1687–1692, 1694, 1721, 1727, 1736–1737, 1743–1746, 1754–1757, 1801–1803, 1858–1859, 1861–1868, 1870–1871, 1880–1881, 1883–1884, 1891–1892, 1894–1895, 1906, 1931, 1937, 1943, 1952–1953, 1975, 1985
   runtime_router.py52787%39, 55–60
openhands-agent-server/openhands/agent_server/docker_runtime
   provisioning.py1251390%40, 51, 60, 73, 88–90, 92–93, 106, 113, 145, 147
   registry.py2004677%53, 58, 61, 158, 172–173, 176, 184, 199–203, 209, 212–213, 219–229, 261, 319, 326, 334–336, 339–347, 356–359
   routers.py1738949%45, 52–58, 76–81, 83–84, 88–90, 92–93, 96–99, 101–111, 117–120, 124–128, 131–134, 136–140, 151, 160, 170, 173–175, 185–187, 196, 218, 234, 240–241, 262, 278–280, 299, 301–314, 327, 336
TOTAL439491816559% 

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
  ✅ **PR Artifacts Cleaned Up**

  The `.pr/` directory is no longer present.

@neubig
neubig requested review from all-hands-bot and removed request for all-hands-bot September 17, 2026 14:19
@all-hands-bot

Copy link
Copy Markdown
Collaborator

🤖 OpenHands is reviewing this PR.

Head commit: af1d4441c1a170981041e551b2ef9a8c553236e1
View the conversation: https://oss-agent-canvas.ngrok.dev/conversations/159b48c5-fbc2-4c3f-9809-07c74f975b4f

This comment was posted by an AI agent (OpenHands).

@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 created by an AI agent (OpenHands) on behalf of the repository maintainers.

Summary

The fix is well-targeted: load_optional cleanly distinguishes a genuinely-absent provisioning manifest (legacy host-local conversation -> fall back to the host cipher) from a present-but-corrupt one (-> raise, fail closed). That preserves per-conversation cipher isolation for real Docker identities and only degrades to the host key for conversations that were originally encrypted with it. The runtime_info distinction (legacy = missing/can_resume=false, stopped Docker = missing/can_resume=true) is consistent and the cipher-boundary tests cover both directions. The REST contract change (optional runtime_info on ConversationInfo) is additive and non-breaking.

One design concern worth confirming before merge (see inline), plus a minor type-safety note.

Risk Assessment: MEDIUM

The change touches the conversation catalog + event-read routing path in Docker mode. The cipher fallback is sound and fail-closed, but proxy_event_read will start a Docker container on a read-only history request for stopped Docker conversations, which has resource/surprise implications the author should confirm is intentional.

Verdict: COMMENT (requesting maintainer confirmation on the container-start-on-read behavior)


Inline finding (registry.py, proxy_event_read): A GET /events/{search,count,id} for a stopped Docker conversation calls get_or_create, which spins up the conversation container. runtime_info reports such conversations as missing + can_resume=true, so the UI presents them as not-running -- yet a read-only history browse will actually resume (start) the runtime. The persisted events live in conversation_dir (a host path the outer ConversationService can already decrypt via runtime_cipher_resolver), so the outer catalog could serve them without a container start. The add_execution_routes comment even states persisted history is "safe to read from the outer catalog." Worth confirming that proxying reads -- and therefore starting a container per history view -- is intended, vs. serving persisted reads from the outer catalog and only proxying when a live lease is actually held.

Minor -- type safety (event_router.py): The four return proxied # type: ignore[return-value] sites return a Response from handlers declared to return JSONResponse/int/Event/list. Widening those handler return types to Response (or JSONResponse | Response) would remove the ignores rather than silencing the checker.

@neubig

neubig commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

Addressed both automated review findings in 2c1cb3d: stopped Docker history reads stay in persisted outer storage, and the event handlers now use accurate return types without ignores. The focused event/runtime/OpenAPI suite passes (82 tests). Ready for another look and explicit approval.

@all-hands-bot

Copy link
Copy Markdown
Collaborator

🤖 OpenHands is reviewing this PR.

Head commit: 2c1cb3d0e0323b5af36aafa985206b95ba073173
View the conversation: https://oss-agent-canvas.ngrok.dev/conversations/7589bc73-1e52-406e-af35-a3a942877f55

This comment was posted by an AI agent (OpenHands).

@neubig
neubig removed the request for review from all-hands-bot September 17, 2026 14:46
@neubig

neubig commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

The fresh automated review identified one more cipher-boundary issue before its GitHub token hit a secondary API limit while submitting: opening stopped Docker history constructed the outer EventService with the host cipher even though catalog metadata used the runtime cipher. Commit 09679b7 fixes the shared construction point to use _cipher_for(stored.id) and extends the mixed legacy/Docker test through actual event-service hydration. The focused 142-test routing/runtime suite and pre-commit pass. I will re-request the bot on this corrected head after its API limit clears.

@neubig

neubig commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

Live Canvas validation exposed one more boundary: hydrating the full outer EventService for a stopped Docker conversation tried to open the container-only /workspace. Commit 5bb12b2 removes that hydration path. Docker-mode GET event routes now reuse the existing append-only EventLog directly from shared persistence; writes and sockets still go to the runtime. This also removes the live-read proxy machinery, reducing the implementation. Local validation: 141 focused Docker/routing tests, all 114 EventService tests, pre-commit, and Pyright pass.

@neubig

neubig commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

The matched live deployment now passes the full lifecycle: profile-selected /workspace start (201), agent run (finished), runtime release (204), stopped history reload (200 with the expected reply), and zero container starts during history read. Please review head 5bb12b2 and explicitly approve if no blocking findings remain.

@all-hands-bot

Copy link
Copy Markdown
Collaborator

🤖 OpenHands is reviewing this PR.

Head commit: 5bb12b2bc059e31031a6325fc5ef2389e77e641c
View the conversation: https://oss-agent-canvas.ngrok.dev/conversations/4f058065-d222-4da3-a97d-d78d0170ae12

This comment was posted by an AI agent (OpenHands).

@neubig
neubig merged commit 365ceb3 into main Sep 17, 2026
54 checks passed
@neubig
neubig deleted the fix/docker-catalog-legacy-local branch September 17, 2026 15:46
@github-actions github-actions Bot mentioned this pull request Sep 17, 2026
1 of 7 tasks
@neubig

neubig commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

@all-hands-bot the v1.49.2 release security scan found that the merged head changed after its prior approval. Please review the final merged head commit 5bb12b2bc059e31031a6325fc5ef2389e77e641c and submit an APPROVE review against that exact commit if there are no blocking findings.

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

Security review — merged head 5bb12b2bc059e31031a6325fc5ef2389e77e641c

Reviewed the final merged head (commit 5bb12b2bc — "fix: read Docker history without hydrating runtimes") plus the full PR diff against main. No blocking findings; submitting APPROVE against this exact commit.

What the change does

Docker-mode read-only event routes (GET /events/{search,count,id,batch}) are now served from the outer catalog's persisted EventLog instead of proxying into (and therefore starting) the conversation container. Writes (POST /events, /respond_to_confirmation) and sockets still go to the runtime via the existing Docker proxy. Legacy host-local conversations (no provisioning identity) keep working because persisted history is cipher-agnostic on the read path.

Security-relevant checks

Cipher boundary (the prior finding) — resolved and fail-closed.

  • RuntimeProvisioningStore.load_optional returns None only for a genuinely-absent manifest; a present-but-corrupt manifest still raises ValueError (provisioning.py). resolve_persisted_cipher falls back to the host key only when the identity is absent, so a corrupt/foreign identity never silently degrades to the host key. Covered by test_present_invalid_identity_does_not_fall_back_to_host_cipher.
  • _start_event_service and _load_persisted_state_sync now construct the cipher via self._cipher_for(stored.id) rather than the bare host self.cipher, so base-state hydration uses the correct per-runtime key.

No secret exposure on the persisted read path.

  • EventService.for_persisted_events opens only the append-only EventLog under conversations_dir/<id.hex>/events. It never sets cipher, never calls load_meta/save_meta, and never hydrates base_state.json or /workspace. The prior "hydrate full outer EventService" path that touched the container-only workspace is removed entirely.
  • Event payloads are plaintext JSON and contain no SecretStr fields; Event.model_validate_json is invoked without a cipher context, so any **********-redacted values in ConversationStateUpdateEvent snapshots stay redacted. No plaintext secret material is reachable through this path.

Path traversal / injection — not present.

  • conversation_dir is built from stored.id.hex (UUID-derived). EventLog filenames are validated by EVENT_NAME_RE (event-\d{5,}-[0-9a-fA-F-]{8,}.json) and _path constructs only {EVENTS_DIR}/{pattern}. LocalFileStore.get_full_path sandboxes every read/write under the store root. No user-controlled path component reaches the filesystem.

Auth — preserved.

  • event_read_router is mounted under api_router, which carries check_session_api_key + require_initialized. Docker's add_execution_routes mounts only event_read_router + docker_conversation_router (both under the same authenticated api_router). The write router (event_write_router) is not mounted in Docker mode, so the persisted-only EventService (which has no _conversation) can never receive a send_message/respond_to_confirmation call — those still proxy to the live container.

Fail-closed 404.

  • get_event_service now raises 404 when the persisted record is absent rather than returning None for the proxy to interpret. Existence is already disclosed by search_conversations, so this leaks no new information and prevents a None service from flowing into handlers.

Risk assessment: LOW

The change narrows the Docker read path to append-only, immutable, cipher-agnostic persisted files served through the existing authenticated router group, and removes the live-read proxy machinery that previously started containers. The cipher fallback is sound and fail-closed, and tests cover the mixed legacy/Docker cipher case through actual EventService hydration plus a persisted-read assertion.

Generated by OpenHands AI on behalf of the user.

@neubig

neubig commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

@all-hands-bot Please review the requested final merged head 5bb12b2bc059e31031a6325fc5ef2389e77e641c and submit an APPROVE review on this PR if there are no blocking findings. The v1.49.2 release security check requires an approval on this exact head.

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

Re-reviewing final merged head 5bb12b2bc059e31031a6325fc5ef2389e77e641c (the post-approval drift flagged by the release security scan).

Reviewed the delta since the prior approval (046fc8877 → 5bb12b2b):

  • event_service.py: adds for_persisted_events() opening an append-only EventLog rooted at conversations_dir / stored.id.hex (UUID hex, no traversal) and _events_for_read() selecting the persisted log when present, falling back to the live conversation's event store. Read methods (get_event, search, count, batch_get) use it uniformly.
  • conversation_registry.py / docker_runtime/registry.py: replaces the per-request HTTP proxy of event reads with a serves_persisted_event_reads property; Docker runtime serves read-only history from shared persisted storage without hydrating a runtime lease.
  • dependencies.py / event_router.py: read routes now depend on get_event_service (no longer Optional) and route to persisted storage when the registry opts in; the proxy fallback path is removed.
  • conversation_service.py: get_persisted_event_service reconciles the catalog record and uses _cipher_for(stored.id) so present Docker identities retain their isolated cipher while absent ones fail closed.
  • PR-only .pr/*.png artifacts removed; tests updated.

No blocking findings: read-only access is confined to the conversation's own persisted event dir; no new untrusted-input-to-path mapping, no network egress, no secret exposure. The proxy-removal simplifies the read surface. Approving.

Generated by OpenHands AI on behalf of the user.

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

Security review - final merged head 5bb12b2bc059e31031a6325fc5ef2389e77e641c

Re-reviewed the final merged head (commit 5bb12b2bc - "fix: read Docker history without hydrating runtimes") against main (merge base 632894b7). No blocking findings; submitting APPROVE against this exact commit.

Scope reviewed

The full PR diff (632894b7..5bb12b2bc) across the agent-server: Docker provisioning/registry, EventService persisted-read path, the event_read_router/event_write_router split, the ConversationInfo.runtime_info addition, and the get_event_service persisted-vs-runtime dispatch in dependencies.py.

Security-relevant findings

Cipher boundary - sound and fail-closed.

  • RuntimeProvisioningStore.load_optional returns None only for a genuinely absent manifest; a present-but-corrupt manifest still raises ValueError (provisioning.py). DockerConversationRegistry.resolve_persisted_cipher falls back to the host key only when the identity is absent, so a corrupt/foreign identity never silently degrades to the host cipher. Covered by test_present_invalid_identity_does_not_fall_back_to_host_cipher and test_optional_load_distinguishes_missing_from_invalid_identity.
  • _start_event_service / _load_persisted_state_sync now build the cipher via self._cipher_for(stored.id) rather than the bare host self.cipher, so base-state hydration uses the correct per-runtime key.

No secret exposure on the persisted read path.

  • EventService.for_persisted_events opens only the append-only EventLog under conversations_dir/<id.hex>/events. It never sets a cipher, never calls load_meta/save_meta, and never hydrates base_state.json or the container-only /workspace. The previous "hydrate full outer EventService" path that touched the container workspace is removed entirely.
  • Event payloads are plaintext JSON with no SecretStr fields; Event.model_validate_json is invoked without a cipher context, so any **********-redacted values in ConversationStateUpdateEvent snapshots stay redacted. No plaintext secret material is reachable via this path.

Path traversal / injection - not present.

  • conversation_dir is built from stored.id.hex (UUID-derived). EventLog filenames are validated by EVENT_NAME_RE (event-\d{5,}-[0-9a-fA-F-]{8,}.json) and _path constructs only {EVENTS_DIR}/{pattern}. LocalFileStore.get_full_path sandboxes every read/write under the store root. No user-controlled path component reaches the filesystem.

Auth - preserved.

  • event_read_router is mounted under api_router, which carries check_session_api_key + require_initialized. In Docker mode add_execution_routes mounts only event_read_router + docker_conversation_router (both under the same authenticated api_router). The write router (event_write_router) is not mounted in Docker mode, so the persisted-only EventService (which has no _conversation) can never receive a send_message / respond_to_confirmation call - those still proxy to the live container via proxy_conversation.

Fail-closed 404.

  • get_event_service raises 404 when the persisted record is absent rather than returning None for a proxy to interpret. Existence is already disclosed by search_conversations, so this leaks no new information and prevents a None service from flowing into handlers.

Test coverage

The added tests exercise the security-critical paths directly: persisted event history read with no container start (test_docker_event_history_reads_persistence_without_starting_a_container - asserts get_or_create is never awaited), the missing-vs-invalid identity distinction, and the mixed legacy/Docker cipher isolation through the catalog listing test.

Risk assessment: LOW

The change narrows the Docker read path to append-only, immutable, cipher-agnostic persisted files served through the existing authenticated router group, and removes the live-read proxy machinery that previously started containers on history views. The cipher fallback is sound and fail-closed, and tests cover the mixed legacy/Docker case. Approving.

Generated by OpenHands AI on behalf of the user.

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.

Keep historical local conversations visible after switching to Docker runtime

4 participants