Skip to content
This repository was archived by the owner on Jul 27, 2026. It is now read-only.
This repository was archived by the owner on Jul 27, 2026. It is now read-only.

[ACP on Cloud] Persistence: durable config + native session storage across pod recycles #2116

Closed as not planned

Description

@simonrosenberg

Priority: P0. Part of OpenHands/OpenHands#15746.

The substrate reality (corrects the original "/workspace survives recycles" assumption)

/workspace is a per-runtime PVC that survives pause/resume of one runtime, but: STOP deletes the PVC (runtime-api/k8s.py:488; conversation-delete → /stop, app_conversation_router.py:754-772); the reaper destroys any runtime (incl. paused) at a creation-time TTL = 14 days prod/staging (runtime-api/cleanup.py:147-173; deploy/envs/{production,staging}/values.yaml); eval sets STOP_IDLE_RUNTIME=true → lost on idle; STORAGE_CLASS=standard-rwo, reclaimPolicy: Delete. Its ownerReference is the Deployment (the cited "durability") — which is also the cascade-delete vector (k8s.py:383-390). And HOME=/home/openhands is NOT on the PVC — only /workspace is (Dockerfile:135, k8s_resources.py:212) — so the CLI's ~/.claude/projects, ~/.codex/sessions, ~/.gemini/* are lost on container recreation. The SDK persists only its own resume token (acp_agent.py:1222-1237), not the CLI backing store. The relocation the epic treats as config is the actual work, and it's unbuilt.

Substrate decision — RESOLVED: object-store snapshot (not a Retain PVC / TTL bump)

Full design, comparison table, wiring plan and E2E: substrate-decision comment ↓.

Sequencing. Tier-A bootstrap resume (OpenHands#14640) ships first as the cloud MVP — all agents, no session persistence. This issue is Tier B: high-fidelity native session/load for Codex/Claude = the substrate decision (below) + the id half (OpenHands#14506 + OpenHands/software-agent-sdk#3506) + the files half, now tracked in #2088.

Decision. Snapshot the CLI's transcript subtree only into the same S3/GCS object store the events already use — no new PVC, no RUNTIME_DEAD_SECONDS bump, no runtime/infra config. It inherits the event store's properties (no PVC, no TTL, survives STOP), which is the actual parity bar — verified that native does not live-resume after STOP either: the sandbox goes MISSING → HTTP 410 archived (app_conversation_router.py:505-508), and nothing replays the event bucket back into a pod. "Persists for life" = the durable event store; a native agent's context is reconstructable from events, whereas an ACP CLI's session files are opaque (only session/load can use them).

Resume = two halves, both required; neither resumes alone on a wiped PVC:

Mechanism (reuses existing OpenHands plumbing — ~2 SDK methods + 2 webhook routes):

  • Boundary: route the blob through the app_server's existing webhook channel (session-API-key auth via valid_sandbox); the sandbox never gets bucket creds. Rejected: presigned URLs (no such code exists in either repo; adds sandbox→bucket egress + a bearer capability) and sandbox bucket creds (breaks the trust model).
  • Store/keying: write via the existing config.file_store (app_server/file_store/, S3/GCS backends) under the conversation's existing prefix, beside the events — users/<uid>/conversations/<hex>/acp_snapshots/<provider>.tar.zst.
  • Scope (security — allowlist, fail-closed): snapshot only Codex acp/codex/sessions/** and Claude acp/claude-code/projects/**. Never auth.json / .credentials.json / history.jsonl — they sit in the same per-conversation dir acp_isolate_data_dir creates (acp_agent.py:1635-1636). Auth is re-seeded on launch by materialisation (#1020/#1022), so sessions-only loses nothing and no refresh token rides to the bucket. At-rest: parity with the (already-unencrypted) events via bucket SSE; optional SDK Cipher wrap as hardening.
  • Triggers: snapshot on the idle/terminal turn-boundary (quiescent; bounds loss to one turn) + opportunistic flush on graceful shutdown; restore pre-spawn in _start_acp_server (before create_subprocess_exec, acp_agent.py:1932), seed-if-absent so a live PVC copy is never clobbered (the snapshot is a strict fallback to the PVC).
  • Degradation ladder (already partly built): restored blob → load_session; else Solution A bootstrap-prompt from durable events (OpenHands#14640); else new_session (the existing ACPRequestError fallback, acp_agent.py:2039).

Tasks

id half (in flight):

files half (Tier B — the object-store snapshot) → tracked in #2088:

done / superseded:

  • Per-conversation CLI data root (#1019 → SDK#3492 acp_isolate_data_dir) — gives the single per-conversation dir this snapshots.
  • Materialise file-content auth + CODEX_HOME-aware detection, seed-if-absent (#1020 → SDK#3474) — re-seeds auth on launch, so the snapshot can exclude it.
  • Substrate decision: Retain/long-lived volume or bump RUNTIME_DEAD_SECONDS → superseded by the object-store snapshot above (no new infra; the PVC options only raise a finite ceiling and keep auth.json on a long-lived volume).
  • Gemini: excluded from the snapshot (load_session unreliable + creds host-bound) → stays on bootstrap-prompt resume (OpenHands#14640); drop any ~/.gemini→PVC symlink.

E2E test

convo → turn → simulate STOP (kill pod / wipe the per-conversation dir — not just pause) → relaunch on a fresh sandbox → assert load_session (not new_session), transcript continuity, Codex token still valid, and crack the snapshot tar to assert no auth.json/history.jsonl leaked (the credential-leak gate).

Depends on

#2114 (per-conversation root, closed), #2115 (materialisation target, closed), OpenHands/software-agent-sdk#3506, OpenHands#14506.

Activity

  1. changed the title [-]ACP persistence — durable config + native session storage across pod recycles[/-] [+][ACP on Cloud] Persistence: durable config + native session storage across pod recycles[/+] on Jun 2, 2026
  2. simonrosenberg commented on Jun 4, 2026

    @simonrosenberg
    MemberAuthor

    Folding two OpenHands/OpenHands issues into this tracker (both closed in favor of OpenHands/OpenHands#15746):

    OpenHands/OpenHands#14260 — ACP conversations cannot be resumed after sandbox restart

    The original user-facing bug; it is the problem this issue solves. OpenHands-side implementations:

    OpenHands/OpenHands#14474 — Migrate ACP resume-transcript logic to SDK primitives once pinned (Solution-A cleanup)

    Once OpenHands pins an SDK release with software-agent-sdk#3323, route the duplicated transcript logic in live_status_app_conversation_service.py to the SDK primitives:

    • render_resume_transcript(events, …) replaces the inline event-render loop in _synthesize_acp_resume_initial_message (size caps → kwargs);
    • RESUME_CONTEXT_MARKER replaces _ACP_RESUME_CONTEXT_MARKER (producer and double-resume guard);
    • ACPToolCallEvent.is_patch_edit replaces _is_patch_edit; content_to_str replaces _content_to_text.
    • Stays in OpenHands (sandbox/Codex-specific, not protocol-layer): _sanitize_paths, _strip_terminal_boilerplate, _extract_output_text, _format_raw_input, _RAW_INPUT_NOISE_KEYS, and the pagination over event_service.search_events (the durable store the SDK doesn't know about).

    Originals: OpenHands/OpenHands#14260, OpenHands/OpenHands#14474.

  3. simonrosenberg commented on Jun 4, 2026

    @simonrosenberg
    MemberAuthor

    Substrate decision for ACP CLI session persistence — object-store snapshot of the per-conversation session subtree

    Proposed resolution for the open "Substrate decision" task in #2116. Recommends the object-store alternative to the Retain-PVC / RUNTIME_DEAD_SECONDS-bump options currently written there. Every load-bearing claim below was verified against the code; citations are file:line. Assumptions I could not close are called out in §5.


    TL;DR

    • Build it as a snapshot of the CLI's transcript subtree only, routed through the app_server's existing event/webhook channel, into the same object store the events already use. The sandbox never gets bucket creds; the app_server already has them; the agent-server already has an authenticated outbound channel to the app_server. Reuse all three.
    • Snapshot scope is an allowlist: acp/codex/sessions/** and acp/claude-code/projects/** — never auth.json / .credentials.json / history.jsonl / config at the provider-dir root. The auth files are re-established on launch by the existing materialisation path (#1020/#1022); excluding them loses nothing and keeps live refresh tokens out of the bucket.
    • This design persists one half of resume — the opaque CLI files. The other half — the acp_session_id — is persisted by feat(acp): persist ACP session id, redirect storage onto /workspace PVC (#14260 Solution B) OpenHands#14506 (Postgres mirror) + chore(deps): bump @docusaurus/theme-mermaid from 3.4.0 to 3.5.1 in /docs OpenHands#3343 (acp_resume_session_id). Both halves are required and they compose. Neither alone resumes a recycled ACP conversation.
    • It strictly beats the PVC options on the only axis that matters here: durability ceiling. The Retain-PVC and TTL-bump options raise the ceiling (longer, or stop-survivable) but never remove it, and both are new runtime/infra config. The object store has no PVC, no TTL, survives STOP — the same properties that already make the event store "durable for life."
    • Graceful degradation already exists: missing/corrupt/version-skewed blob → load_session raises ACPRequestError → SDK falls back to new_session (today's behaviour, acp_agent.py:2039), and Solution A (#14295) can backfill context from the durable events. Three tiers, each already partly built.

    0. Premise check — what's actually true today (verified)

    Before designing, I verified the three premises the task rests on. Two hold as stated; one needs a correction that strengthens the case.

    (a) Events are durable, written by the app_server, one-way out of the sandbox — TRUE.
    The sandbox POSTs events to POST /webhooks/events/{conversation_id}; on_event fans them into event_service.save_event(...) (webhook_router.py:408-420). The SaaS EventService is object-store-backed: GoogleCloudEventService._store_event writes one JSON blob per event via bucket.blob(path).open('w') (google_cloud_event_service.py:57-62); AwsEventService._store_event does s3_client.put_object(...) under an IAM role (aws_event_service.py:54-62). The key is per-conversation: users/<user_id>/<V1_CONVERSATIONS_DIR>/<conversation_id.hex>/<event_id.hex>.json (event_service_base.py:47-65,161-168). Bucket credentials are constructed inside the app_server injector (storage.Client() / boto3.client('s3')), never in the sandbox. This is the boundary that decides §1.

    (b) The ACP CLI session files are NOT durable past the weak tier — TRUE.
    acp_isolate_data_dir (#3492/#1019) relocates the provider's data root to <persistence_dir>/acp/<provider> (acp_agent.py:1609-1625, 1627-1688), which is /workspace/conversations/<conv_hex>/acp/<provider>/ — on the /workspace PVC. /workspace survives pause/resume (k8s scale 0↔1, same Deployment/PVC) but is deleted on STOP (runtime-api k8s.py:488 deletes the PVC; app_server delete → /stop, remote_sandbox_service.py:614) and at the 14-day creation-time TTL (cleanup.py:147-173; RUNTIME_DEAD_SECONDS default 86400, overridden to 1209600 in prod/staging). The SDK persists only its resume token — acp_session_id/acp_session_cwd into base_state.json (acp_agent.py:1441-1461) — never the CLI's backing files.

    (c) CORRECTION — "native conversations persist for life" means the durable event store persists; native does NOT rehydrate live agent working-state on a hard STOP either.
    I traced the native rehydration path end to end. There is no code that replays the event bucket back into a fresh sandbox, and no code that seeds base_state.json into one (repo-wide grep for replay|reconstruct|rehydrate|seed_events|import_events|restore_state in the app_server returns nothing). ConversationState.create() reads base_state.json purely from the local persistence_dir (state.py:392-429); ConversationService resumes only conversations whose meta.json is still on local disk. The conversation-start path sends no events — only an optional initial_message (AppConversationStartRequest has no history field). After a hard STOP the sandbox is MISSING and the conversation is archived → HTTP 410 on send-message (app_conversation_router.py:505-508).

    So the precise, verified asymmetry — and the honest parity target — is:

    A native agent is stateless between turns: its entire context is the event history, so the durable event store is sufficient to reconstruct it (Solution A, OpenHands/OpenHands#14295, is literally that reconstruction). An ACP CLI keeps opaque state in its own session files that the event log cannot reconstruct — only the CLI can, via session/load. The events give ACP display parity for free (they're already durable) and lossy bootstrap parity via OpenHands/OpenHands#14295; what's missing is high-fidelity parity: true session/load that survives the same STOP/TTL the events survive. That is exactly what this design adds.

    This correction matters for the comparison table (§3): the bar to clear is "match the event store's durability properties," not "match a mythical native live-resume." The object store clears that bar by construction; the PVC options do not.


    1. Recommended architecture

    1.1 The two halves of ACP resume (state the dependency explicitly)

    Resume a recycled ACP conversation  =  (i) the session id   +   (ii) the CLI's opaque backing files
                                              └ OpenHands/OpenHands#14506 mirrors        └ THIS DESIGN snapshots
                                                into Postgres            into the event object store
                                                conversation_metadata    (sessions/ , projects/)
                                              └ OpenHands/OpenHands#3343 feeds it back
                                                via acp_resume_session_id
    

    On a fresh PVC (post-STOP / post-TTL), both base_state.json (which holds the FS-persisted acp_session_id) and the CLI files are gone — they shared the dead PVC. OpenHands/OpenHands#14506+#3343 restore half (i) from durable Postgres; this design restores half (ii) from the durable bucket. _start_acp_server then reads the id from acp_resume_session_id (precedence over the absent FS id, per OpenHands/OpenHands#3343) and calls load_session, which now finds the restored files. Ship neither half expecting resume on its own.

    1.2 Process boundary & credential model — route through the app_server (not presigned URLs, not sandbox creds)

    The sandbox has exactly one privileged channel: the webhook POST to the app_server, authenticated by its X-Session-API-Key and validated by valid_sandbox (webhook_router.py:230-273), which resolves the owning user so the app_server can scope storage to users/<user_id>/…. Reuse it verbatim.

    Option Verdict Why
    (a) Route blob through app_server (new /webhooks/.../acp-snapshot PUT+GET, app_server does the bucket I/O) RECOMMENDED Reuses the existing auth (session API key), the existing user-scoping, the existing creds-in-app_server boundary, and the existing generic FileStore (it exists: file_store/files.py:7, with s3.py/google_cloud.py/local.py backends, wired as config.file_store, config.py:195). Symmetric with how every event already flows. Blob bytes transit the app_server — negligible at this data scale (KB–low-MB, snapshot per turn-boundary; events already transit this path every turn).
    (b) App_server mints a presigned/scoped PUT/GET URL; sandbox uploads direct Reject No presigned-URL code exists anywhere in either repo (verified: no generate_presigned_url / generate_signed_url / ExpiresIn). It would be the only such mechanism in the codebase, plus: a new bearer capability crossing the boundary (expiry/clock-skew handling), and a new bucket-egress requirement for the sandbox (today it egresses to the app_server, not to S3/GCS). The sole upside — offloading app_server bandwidth — doesn't apply at this size.
    (c) Give the sandbox scoped bucket creds Reject hard The sandbox runs arbitrary agent/CLI code in a user-controlled environment. Putting any long-lived bucket credential there breaks the existing trust model in which the sandbox never holds bucket creds.

    1.3 Where the bytes live — alongside the events, same bucket, same keying

    Write one object per provider under the conversation's existing prefix, e.g.:

    users/<user_id>/<V1_CONVERSATIONS_DIR>/<conversation_id.hex>/acp_snapshots/<provider>.tar.zst
                                             └ same prefix get_conversation_path() already computes (event_service_base.py:47-65)
    

    Two implementation choices, both satisfying "ride the same bucket abstraction, keyed by conversation id, alongside the events":

    • Preferred: a small AcpSnapshotService mirroring EventServiceBase's injector pattern (GCS/S3/filesystem backends, same get_conversation_path keying) — a sibling in the event/ package family. Faithful to "alongside the events," reuses the per-conversation keying and the credential plumbing.
    • Lighter: reuse config.file_store (FileStore.write(path, bytes)) directly. Confirm it points at the same bucket as the EventService in SaaS (§5 open question); if it does, this is a few lines.

    1.4 Trigger points

    Snapshot (capture) — primary trigger is the idle/terminal turn-boundary, not pod death.
    The agent-server already emits a ConversationStateUpdateEvent(key='execution_status') on every status change, and the app_server already detects exec_status.is_terminal() (webhook_router.py:457-461). That transition is the natural quiescent point: the ACP subprocess has flushed its session JSONL at end-of-turn and is idle. Snapshot there. This bounds worst-case data loss to a single in-flight turn — and that turn's events are still durable, so Solution A can backfill it.

    • Do NOT make pod-teardown the only trigger. The graceful path (SIGTERM → tini → uvicorn handle_exit → api_lifespan finally, api.py:208 → EventService.__aexit__, event_service.py:1238) runs within the 30 s terminationGracePeriodSeconds, but the stuck-pod force-kill (grace 0) and hard node failures skip it. Use graceful-shutdown as an opportunistic extra flush, never the sole capture.

    Restore — pre-spawn, seed-if-absent, before load_session.
    The single correct wire-in is _start_acp_server, after the env/cwd are finalised and before asyncio.create_subprocess_exec (acp_agent.py:1932). Restore writes the tar into acp/<provider>/<subtree> using the same seed-if-absent semantics the materialiser already uses (acp_agent.py:1746-1759): if the PVC already has the files (pause/resume — PVC intact), do not clobber them; only hydrate when absent (fresh PVC). This makes the snapshot a strict fallback to the PVC — the two tiers compose and the bucket copy can never regress live state. It is synchronous-before-spawn, so there is no restore-vs-subprocess race.

    1.5 Consistency / atomicity

    • One object per provider, written whole (tar, optionally zstd). The FileStore/bucket write of a single object is atomic (GCS blob write, S3 put_object, local os.replace), so a reader never sees a half-written snapshot. Build the tar in a temp path, then single write.
    • Capture at the idle boundary (§1.4) means the JSONL files are not mid-append. Even if a trailing record is truncated, the CLIs tolerate a partial final line, and worst case load_session → ACPRequestError → new_session.
    • Restore is write-then-spawn, seed-if-absent, into the provider subtree only with a path-safe extract (no absolute paths, no ..), mirroring the ACPFileSecretSpec validators (acp_providers.py:108-125).

    1.6 Security — the snapshot scope decision (the crux)

    Because acp_isolate_data_dir points CODEX_HOME at <persistence_dir>/acp/codex, that dir holds both sessions/ and auth.json (the live refresh token) — the relocation and the materialised credential "always agree on one directory" by design (acp_agent.py:1635-1636; spec acp_providers.py:354-359). I confirmed the same shape on disk for Claude: under CLAUDE_CONFIG_DIR the transcripts sit in projects/<cwd-hash>/<session-id>.jsonl (the filename is the load_session id), while the root holds credentials, a 2.4 MB global history.jsonl, caches and settings.

    Decision: snapshot an ALLOWLIST of the transcript subtree, nothing else.

    Provider Data root (env) Snapshot (allowlist) Exclude
    Codex CODEX_HOME=…/acp/codex sessions/** auth.json (refresh token), history.jsonl, config.toml, caches
    Claude Code CLAUDE_CONFIG_DIR=…/acp/claude-code projects/** .credentials.json, history.jsonl (2.4 MB global), settings*.json, *-cache.json
    Gemini CLI HOME=…/acp/gemini-cli nothing — excluded (see §1.7) everything (HOME blast radius: git/npm/etc.)
    • Allowlist, not denylist — fails closed. A denylist of today's known credential filenames would silently leak any new credential/state file a future CLI version writes at the root. The allowlist snapshots only the transcript subtree by construction.
    • Excluding auth loses nothing. Codex auth.json is independently re-seeded on launch from the secret channel (materialisation [ACP on Cloud] SDK: materialise reserved file-content auth secrets (Codex auth.json, Gemini Vertex SA) #2115/#1022, seed-if-absent); Claude's token is injected via env var. So sessions-only is sufficient for load_session, and live tokens never ride to the bucket.
    • At-rest: the transcript is sensitive, but no more sensitive than the event blobs already stored unencrypted in the same bucket (the events are the same conversation). Default to bucket-managed SSE (S3 SSE-S3/KMS, GCS default encryption) for parity with events. Offer an app-layer wrap with the SDK Cipher (Fernet/OH_SECRET_KEY, cipher.py:22 — already what encrypts acp_env) as opt-in hardening. Note the conditional: if we ever included auth files (we do not), Cipher-wrap would be mandatory; because we exclude them, it is optional defense-in-depth.

    1.7 Provider differences (who actually benefits)

    1.8 Failure ladder (graceful degradation — mostly already built)

    high-fidelity   restored blob present + valid  → load_session succeeds            (this design)
       ↓ (missing / corrupt / version-skew)
    lossy resume    Solution A synthesises a <<RESUMED CONVERSATION>> prompt
                    from the DURABLE EVENTS                                            (#14295, exists)
       ↓ (Solution A disabled / events unavailable)
    fresh           load_session raises ACPRequestError → new_session                  (acp_agent.py:2039, exists)
    
    • Partial upload: best-effort; single-object atomic write means no partial state is ever read. On write failure the prior snapshot remains; log and continue.
    • Version skew (CLI that wrote ≠ CLI that reads): stamp the snapshot with agent_name/agent_version (already captured at init, acp_agent.py:1453-1454) in the object metadata/key; skip restore on major-version mismatch and fall straight to Solution A, rather than feed an incompatible blob to load_session.

    2. Concrete wiring plan (new vs extended)

    Agent-server / SDK (owns the files; knows the dir layout): ~/repositories/software-agent-sdk

    • NEW ACPAgent.export_cli_session_blob(state) -> bytes | None — tar the provider's allowlisted subtree (sessions/ / projects/) from _acp_file_secret_dir(state, provider.key) (acp_agent.py:1609-1625); return None for Gemini/unknown. Pure, side-effect-free, credential-excluding.
    • NEW ACPAgent.import_cli_session_blob(state, blob) -> None — seed-if-absent extract into the same subtree, path-safe. Call it in _start_acp_server immediately before create_subprocess_exec (acp_agent.py:1932).
    • NEW field ACPAgent.acp_snapshot_session_blob: bool = False — the feature flag, presence-checked by the app_server exactly like acp_resume_session_id/acp_isolate_data_dir already are (the '…' in ACPAgent.model_fields guard pattern from feat(acp): persist ACP session id, redirect storage onto /workspace PVC (#14260 Solution B) OpenHands#14506). Off by default; the SDK owns the mechanism, downstream owns the policy.
    • EXTEND the agent-server's per-conversation lifecycle to drive when: on the idle/terminal execution_status transition (the same signal EventService already publishes, event_service.py:794), call export_cli_session_blob and POST it to the app_server over the existing webhook channel; opportunistically also flush in EventService.__aexit__ (event_service.py:1238). On conversation init, GET the blob and hand it to import_cli_session_blob before init_state.

    App_server (owns bucket creds + user-scoping): ~/repositories/OpenHands

    • NEW routes on the existing webhook router (webhook_router.py, already prefix='/webhooks', already valid_sandbox-authenticated): PUT /webhooks/conversations/{conversation_id}/acp-snapshot/{provider} and GET … — write/read the object via the chosen store (§1.3).
    • NEW AcpSnapshotService (or reuse config.file_store, config.py:195) — mirrors EventServiceBase keying so the object lands under the conversation's existing prefix (event_service_base.py:47-65).
    • EXTEND conversation GC: when a conversation is deleted, delete its acp_snapshots/ objects (parity with event cleanup).
    • No change to the runtime-api, the PVC, the Dockerfile, or any deploy value. That is the whole point.

    Prereqs already in flight (Phase 0): OpenHands/OpenHands#3343 (acp_resume_session_id + CLAUDE_CONFIG_DIR decoupling), OpenHands/OpenHands#14506 (Postgres session-id mirror, Solution B 2a/2b), OpenHands/OpenHands#3492/#1019 (acp_isolate_data_dir, the per-conversation dir this snapshots).


    3. Comparison vs #2116's currently-written substrate options

    Dimension Object-store snapshot (this proposal) Retain / ADDITIONAL_PVC long-lived volume Bump RUNTIME_DEAD_SECONDS
    Durability ceiling None — no PVC, no TTL, survives STOP. Matches the event store's "durable for life." Raised but finite: a Retain volume survives STOP but still needs lifecycle/GC; orphaned-PV sprawl; still tied to the runtime/zone. Just moves the 14-day wall out; STOP still deletes immediately; idle-stop envs still lose it.
    New infra / runtime config None beyond what events already use. Reuses bucket, webhook, FileStore, session-API-key auth. Yes — new StorageClass/reclaim policy, PV provisioning, the ADDITIONAL_PVC mechanism (k8s_resources.py:215-242), cross-pod attach semantics. Yes — a deploy-value change; blunt, affects all runtimes' cost/lifetime, not just ACP.
    Cost model Per-conversation KB–low-MB objects, written at turn boundaries; object-store $/GB is ~nothing; same bill as events. Per-conversation provisioned block volumes kept alive long-term — pay for idle capacity, the expensive resource. Every runtime lives longer → more idle pods/PVCs cluster-wide; largest blast radius on spend.
    Security Auth files excluded by allowlist; transcript at parity with already-stored events; optional Cipher-wrap. Whole /workspace (incl. auth.json, refresh tokens) persisted on a long-lived volume — larger at-rest credential exposure, longer. Same as today but for longer — auth.json sits on the PVC for the extended window.
    Parity with native High-fidelity session/load that survives exactly what the event store survives → the real target (§0). Pod-local fidelity, but bounded by volume lifecycle; doesn't use the durable store native relies on. Doesn't change the mechanism — just delays loss.
    Ops / blast radius Self-cleaning with conversation GC; no cluster-state growth. PV/PVC lifecycle, zone affinity, reclaim races, orphan cleanup. Cluster-wide runtime-count growth; reaper tuning becomes load-bearing.

    The PVC options keep ACP resume coupled to runtime/volume lifecycle — the exact coupling #2116 identifies as the failure (ownerReference → Deployment → cascade-delete vector). The object store decouples session durability from runtime lifecycle, which is why the events are durable in the first place.


    4. Phased implementation (each independently mergeable, feature-guarded)


    5. Open questions / risks

    1. Is config.file_store the same bucket as the EventService? Both are object-store-backed and creds-in-app_server (so "no new infra" holds either way), but the goal is for the blobs to sit alongside the events. The EventServices use raw boto3/GCS clients with a users/ prefix; file_store/ is a parallel stack. De-risk: confirm SaaS config maps both to the same bucket, or implement AcpSnapshotService against the EventService's injector so co-location is guaranteed.
    2. Does an archived (STOP/TTL) conversation get a fresh sandbox to restore into? The start path can provision one keyed by conversation_id.hex (live_status_app_conversation_service.py:734), but the send-message path 410s a MISSING sandbox (app_conversation_router.py:505-508). Whether re-opening an archived conversation routes through start (resurrect) or send (410) is a product-flow question. This design is agnostic — it makes the conversation resumable on any fresh PVC, which is the prerequisite for an "un-archive → resume" flow to ever work for ACP — but the flow itself is out of scope here and should be confirmed with whoever owns the conversation lifecycle.
    3. Codex sessions/ internal layout / multi-file rollouts across CLI versions — the allowlist tars the whole sessions/ subtree so it's layout-agnostic, but a version that splits state outside sessions/ would be missed. The version-stamp/skew guard (§1.8) is the backstop.
    4. Snapshot timing vs. the app_server's terminal-detection is today analytics-only (webhook_router.py:461). Driving snapshot from the agent-server side (where the files are) on the same idle signal avoids a round-trip, but confirm the agent-server has a clean per-turn idle hook to attach to (the EventService state-change callback, event_service.py:794, is the candidate).
    5. history.jsonl privacy — both CLIs keep a global command history at the data-root (2.4 MB observed). The allowlist excludes it; double-check no provider writes resumable session state into that global file (none observed, but version-watch).

    6. E2E validation plan

    Mechanism-level checks are already covered by passing SDK tests (test_codex_auth_json_materialises_to_conversation_root, test_claude_isolates_under_oauth_token, test_composes_with_materialised_codex_auth, and the TestACPSessionIdPersistence resume suite). The new end-to-end assertion is the STOP-simulating round trip:

    1. Convo → turn. Start a Codex ACP conversation with acp_isolate_data_dir=True and the new acp_snapshot_session_blob=True; run one turn. Assert files exist at …/acp/codex/sessions/** and auth.json at the root.
    2. Snapshot fired. Assert the app_server received the snapshot PUT and the object exists in the bucket under the conversation prefix. Crack the tar open and assert it contains sessions/** and not auth.json / history.jsonl (the credential-leak gate — this is the test that must never regress).
    3. Simulate STOP (not pause). Delete the per-conversation dir entirely (or kill the pod and let a fresh one come up on a new PVC) so both base_state.json and the CLI files are gone — the hard-STOP condition, not the pause condition.
    4. Relaunch on a fresh sandbox. Provide acp_resume_session_id from the Postgres mirror (#14506) and let restore pull the blob. Assert restore wrote sessions/** back, seed-if-absent (and did not fabricate an auth.json from the blob — auth comes only from materialisation).
    5. Assert session/load, not new_session. Hook the ACP connection and assert load_session(session_id, cwd) was called and succeeded (resumed id == prior id, acp_agent.py:1431-1435), transcript continuity holds, and new_session was not called.
    6. Negative / degradation. (a) Corrupt the blob → assert ACPRequestError → new_session (or Solution A if enabled), no crash. (b) Bump the stamped CLI major version → assert restore is skipped and it falls to Solution A. (c) Gemini → assert no snapshot is written and resume stays on bootstrap-prompt.

    A local approximation of steps 1–2 and the credential-leak gate (step 2) is runnable today with the locally-installed codex/codex-acp against a throwaway CODEX_HOME; the full fresh-PVC relaunch (steps 3–5) needs the cloud harness with OpenHands/OpenHands#14506 in place.

  4. simonrosenberg commented on Jun 9, 2026

    @simonrosenberg
    MemberAuthor

    Closing as won't-do per the ACP-cloud architectural pivot (2026-06-08): cloud ACP will behave like the regular OpenHands agent — pause/resume only, archive at the 14-day runtime TTL — so the survive-a-full-recycle resume stack this issue is part of is dropped. Replacement scope: #2057 (OpenHands: revert bootstrap + enable acp_isolate_data_dir) and #2061 (canvas: remove wake UI). See OpenHands/OpenHands#15746.

  5. transferred this issue fromOpenHands/OpenHandson Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions