Repository navigation
feat(acp): acp_resume_session_id (durable resume) + acp_isolate_data_dir on ACPAgentSettings - #3506
Conversation
…resume Adds `ACPAgent.acp_resume_session_id`: an explicit resume override that, when set, drives `session/load` in precedence over the FS-persisted `state.agent_state["acp_session_id"]`. This is the SDK half of cloud ACP resume (agent-canvas#1018) — the app-server mirrors the id into durable storage (Postgres) and feeds it back on the first launch of a fresh sandbox, where `base_state.json` was wiped along with the previous sandbox filesystem. - New field with a bearer-secret serializer/validator: possession of the id is enough to resume the session, so default `model_dump`/`model_dump_json` redacts it; trusted backends opt into plaintext (`expose_secrets='plaintext'`) and frontend round-trips use the encrypted+cipher path. The matching `field_validator` reloads the redacted sentinel / ciphertext to `None`/plaintext so a serialized agent never sends `"**********"` to `session/load`. - `_fingerprint_session_id` masks session ids in log lines (they're bearer tokens; log aggregators are a serialization boundary that retains lines for weeks). - `_start_acp_server` precedence + cwd-guard asymmetry: the explicit id has no recorded cwd, so we assume cwd-compatibility and let the server's own `session/load` validation (→ `ACPRequestError` → `new_session`) be the backstop — the same recovery path as a forgotten id. `init_state` feeds the effective id into the existing `truly_resumed` check so suffix re-injection stays correct. Scope note: this is a refresh of the field-only core of the superseded #3343, rebased onto current main. The `CLAUDE_CONFIG_DIR`/API-key decoupling that #3343 also carried is dropped — main's landed `_isolate_acp_data_dir` carve-out now handles Claude relocation, and decoupling is only relevant to the API-key-Claude snapshot edge (tracked separately under #1018). Tests: precedence (drives load w/o FS state, overrides FS id, failure→new_session, matches-FS-uses-FS-cwd), log redaction, the fingerprint helper, and the bearer- secret round-trips (redacted-by-default, plaintext, encrypted, sentinel→None). 333 passed in tests/sdk/agent/test_acp_agent.py; ruff + pyright clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
||||||||||||||||||||||||||||||
all-hands-bot
left a comment
There was a problem hiding this comment.
✅ QA Report: PASS
Verified the new ACP durable resume-session-id path by driving a real Conversation against a protocol-compatible ACP subprocess; the PR achieves its stated goal.
Does this PR achieve its stated goal?
Yes. On main, ACPAgent has no acp_resume_session_id field and a supplied value is ignored; on this PR, Conversation.send_message(...); run() caused the ACP client to call session/load with the explicit durable id even when agent_state had no filesystem-persisted session id. I also verified explicit-id precedence over filesystem state, fallback to new_session when session/load fails, and secret serialization/redaction round-trips.
| Phase | Result |
|---|---|
| Environment Setup | ✅ Used existing uv project environment; SDK imports and ACP subprocess execution worked. |
| CI Status | ✅ 32 checks successful, 1 skipped, 1 in progress (qa-changes) at review time. |
| Functional Verification | ✅ Real Conversation runs exercised ACP initialize, session/load, new_session, and prompt behavior. |
Functional Verification
Test 1: Baseline on main — durable resume field is not available
Step 1 — Reproduce / establish baseline without the fix:
Ran this on main:
git checkout main
OPENHANDS_SUPPRESS_BANNER=1 uv run python - <<'PY'
from openhands.sdk.agent.acp_agent import ACPAgent
print("has_acp_resume_session_id", "acp_resume_session_id" in ACPAgent.model_fields)
agent = ACPAgent(acp_command=["python", "/tmp/qa_acp_server.py"], acp_resume_session_id="durable-session-1234567890")
print("has_runtime_attribute", hasattr(agent, "acp_resume_session_id"))
print("dump_contains_field", "acp_resume_session_id" in agent.model_dump())
PYObserved:
has_acp_resume_session_id False
has_runtime_attribute False
dump_contains_field False
This confirms the durable mirror id could not be represented by the SDK model before the PR; passing it to the constructor is ignored.
Step 2 — Apply the PR's changes:
Checked out acp-resume-session-id-field at c2324ca5967fff13c5f5b803dcc62f66109f22bd.
Step 3 — Re-run with the fix in place:
I started a minimal ACP stdio subprocess (/tmp/qa_acp_server.py) that records received ACP calls, then drove it via real SDK usage: Conversation(agent=ACPAgent(...), workspace=...).send_message(...); run().
For a fresh workspace with no agent_state["acp_session_id"], the recorded calls were:
SCENARIO explicit_no_fs
status finished
stored_session durable-session-1234567890
events [{"event": "connect"}, {"event": "initialize", "protocol_version": 1}, {"cwd": "/tmp/tmp__wo2swh", "event": "load_session", "session_id": "durable-session-1234567890"}, {"event": "prompt", "prompt_blocks": 1, "session_id": "durable-session-1234567890"}]
server_stderr_empty True
This shows the new field is consumed end-to-end: the real conversation startup called ACP session/load with the durable id and persisted that id back into conversation agent_state.
Test 2: Explicit id takes precedence over filesystem state
Step 1 — Establish baseline intent:
The scenario simulates a conversation state that already contains a filesystem-persisted session id (filesystem-old-session) while the app supplies a durable mirror id (durable-override-ABCDEFGH).
Step 2 — Apply the PR's changes:
Ran the same real Conversation flow on the PR branch, with convo.state.agent_state pre-populated before send_message() / run().
Step 3 — Verify behavior:
Observed:
SCENARIO explicit_overrides_fs
status finished
stored_session durable-override-ABCDEFGH
events [{"event": "connect"}, {"event": "initialize", "protocol_version": 1}, {"cwd": "/tmp/tmp1pylqz5o", "event": "load_session", "session_id": "durable-override-ABCDEFGH"}, {"event": "prompt", "prompt_blocks": 1, "session_id": "durable-override-ABCDEFGH"}]
server_stderr_empty True
This confirms the explicit durable id, not the old filesystem id, was sent to ACP session/load and used for the prompt session.
Test 3: Failed durable load falls back to a fresh ACP session
Step 1 — Establish failure case:
The fake ACP subprocess rejects session/load for force-missing-session, simulating an ACP server that cannot load the mirrored id.
Step 2 — Apply the PR's changes:
Ran the same real conversation flow with ACPAgent(acp_resume_session_id="force-missing-session").
Step 3 — Verify recovery:
Observed:
SCENARIO fallback_to_new
status finished
stored_session fresh-session-from-server
events [{"event": "connect"}, {"event": "initialize", "protocol_version": 1}, {"cwd": "/tmp/tmpt7h2srdz", "event": "load_session", "session_id": "force-missing-session"}, {"cwd": "/tmp/tmpt7h2srdz", "event": "new_session"}, {"event": "prompt", "prompt_blocks": 1, "session_id": "fresh-session-from-server"}]
This confirms the existing recovery path is preserved: after session/load fails, the SDK starts a new ACP session and continues the prompt on fresh-session-from-server.
Test 4: Resume id is treated as a bearer secret during serialization
Step 1 — Establish baseline expectation:
The PR claims default dumps redact the id, redacted reloads become None, plaintext trusted dumps round-trip, and encrypted dumps decrypt with a cipher.
Step 2 — Apply the PR's changes:
Ran direct SDK serialization calls on the PR branch:
OPENHANDS_SUPPRESS_BANNER=1 uv run python - <<'PY'
# Construct ACPAgent(acp_resume_session_id="super-secret-resume-id-do-not-leak")
# Exercise model_dump_json default/plaintext/encrypted and model_validate_json reloads.
PYStep 3 — Verify behavior:
Observed:
SECRET_ROUNDTRIP
default_redacted True
default_plaintext_leaked False
default_reload None
plaintext_roundtrip True
encrypted_plaintext_leaked False
encrypted_roundtrip True
This confirms the new field redacts by default, does not reload the redacted sentinel as a real id, and supports both trusted plaintext and encrypted frontend round-trips.
Issues Found
None.
This review was created by an AI agent (OpenHands) on behalf of the user.
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
Code Review: ✅ Approve
Reviewed the PR. The implementation is solid — well-reasoned security design, clean reuse of existing resume machinery, and comprehensive test coverage. A few suggestions below, none blocking.
Files Reviewed
| File | Changes | Verdict |
|---|---|---|
openhands-sdk/openhands/sdk/agent/acp_agent.py |
+138 −11 | ✅ Good |
tests/sdk/agent/test_acp_agent.py |
+198 −0 | ✅ Good |
Design Notes
Security model is sound. ACP session ids are bearer tokens for session/load — redacting by default, using serialize_secret/validate_secret for round-trips, and accepting either plaintext (trusted backend) or encrypted (frontend cipher) is the right approach. The 8-character suffix for log fingerprinting is a pragmatic balance between correlation utility and token protection.
Precedence logic is clear. Explicit acp_resume_session_id > FS-persisted acp_session_id; when they match, reusing the FS cwd is a sensible backward-compat move. The asymmetry on the cwd guard (FS id has recorded cwd → enforce it; explicit id has none → trust the caller) is documented and justified.
Failure fallback is correct. ACPRequestError → new_session mirrors the existing resume path. In a cloud sandbox recycle scenario where both the session id and the ACP server's persistent state are gone, falling back to a fresh session is strictly better than failing closed.
Inline Comments
Line 1193–1197: Validator return style
secret = validate_secret(value, info)
return secret.get_secret_value() if secret is not None else NoneMinor: the validator unconditionally returns str | None, but get_secret_value() on a SecretStr can raise if the inner value is empty. The current check (secret is not None) guards against a None input, but if validate_secret returns an empty SecretStr, get_secret_value() returns "" rather than raising — so the behavior is correct, just worth a quick double-check against validate_secret's contract. Consider a comment: # validate_secret returns None for redacted/empty inputs.
Line 1129: Serializer when_used="always" vs "json"
@field_serializer("acp_resume_session_id", when_used="always")The when_used="always" ensures the serializer fires for both .model_dump() and .model_dump_json(). Confirm this is the intended scope — if you only wanted JSON serialization redacted (Python dict representation is internal), "json" would suffice. Given the bearer-token concern extends to any serialized form, "always" seems correct; just flagging it for awareness.
Minor Nits (non-blocking)
-
_fingerprint_session_iddocstring: "returns"<short>"for ids shorter than or equal to the suffix length" — consider "ids shorter than the suffix length" sincelen == suffix_lentechnically meets the condition but the function returns<short>(not<last-8>). The logic is correct; just the wording is slightly ambiguous. -
Line 1087: The constant name
_SESSION_ID_LOG_SUFFIX_LENis descriptive but a one-liner comment connecting it to the security rationale in the block comment above would help future readers.
What's Working Well
- ✅ Reused existing
load_session/new_sessionmachinery without adding new ACP protocol paths - ✅
init_statefeeds the effective id intotruly_resumedso suffix re-injection stays correct - ✅ Comprehensive test suite: precedence, failure fallback, log redaction, secret round-trips (default/plaintext/encrypted), and the fingerprint helper
- ✅ Clear PR description with relationship to #3343 and rationale for scope reduction
Risk Assessment
| Area | Risk | Assessment |
|---|---|---|
| Security | Low | Bearer-token treated correctly; redacted by default, validated on load |
| Backward compat | Low | New optional field with safe defaults; existing behavior unchanged |
| Failure modes | Low | Graceful fallback to fresh session on session/load failure |
| Test coverage | Low | 198 new lines of tests covering all paths |
Conclusion: The PR is well-designed, cleanly scoped, and ready to merge. The suggestions above are minor polish — the core implementation is solid.
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
``acp_isolate_data_dir`` was an ``ACPAgent``-only field (#1019 / #3492), so it had no wire/settings slot: an application configuring ACP via ``agent_settings`` could not opt a conversation into a per-conversation CLI data dir — the value always took its ``False`` default. Promote it to ``ACPAgentSettings`` and forward it through ``create_agent()`` so the deploying application (e.g. canvas / cloud, when conversations share a sandbox under grouping) can enable it over the settings channel. Like ``acp_file_secrets``, it's a programmatic/downstream knob — no ``SETTINGS_METADATA_KEY``, so it stays out of the settings-form UI (the schema section test set is unchanged). Additive, defaults ``False`` → backward compatible. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
all-hands-bot
left a comment
There was a problem hiding this comment.
⚠️ QA Report: PASS WITH ISSUES
ACP durable resume works in real SDK conversation runs, but one ACP log path still emits full session ids despite the PR's bearer-secret/log-hygiene goal.
Does this PR achieve its stated goal?
Partially. The new acp_resume_session_id field is present on the PR branch and, when used through ACPAgent + Conversation with a real ACP stdio subprocess, it drives session/load without filesystem state, overrides a filesystem-persisted id, falls back to new_session on load failure, and serializes as a secret. However, the same functional run showed UsageUpdate not received ... for session qa-explicit-session-OVERRIDE9999, so log hygiene is incomplete for bearer session ids.
| Phase | Result |
|---|---|
| Environment Setup | ✅ uv sync --dev completed; .venv created and workspace package built |
| CI Status | ✅ Core checks observed green (sdk-tests, tools-tests, workspace-tests, agent-server-tests, pre-commit, API checks); several optional/label-gated jobs skipped |
| Functional Verification |
Functional Verification
Test 1: Fresh sandbox uses durable acp_resume_session_id for session/load
Step 1 — Establish baseline without the fix:
Checked out base commit 50776d44 and ran OPENHANDS_SUPPRESS_BANNER=1 timeout 45 uv run python /tmp/qa_acp_resume_user_flow.py against a real ACP stdio stub server:
{
"constructor_used_resume_id": false,
"events": [
{"event": "initialize", "protocol_version": 1},
{"cwd": "/tmp/qa-acp-workspace-52sv6gtl", "event": "new_session"},
{"event": "prompt", "prompt_text": "QA: verify ACP durable resume behavior", "session_id": "fresh-session-from-stub"}
],
"field_present": false
}This shows the old SDK had no acp_resume_session_id field and started a fresh ACP session when no filesystem agent_state id existed.
Step 2 — Apply the PR's changes:
Checked out acp-resume-session-id-field at c2324ca5967fff13c5f5b803dcc62f66109f22bd.
Step 3 — Re-run with the fix in place:
Ran the same command:
{
"constructor_used_resume_id": true,
"events": [
{"event": "initialize", "protocol_version": 1},
{"cwd": "/tmp/qa-acp-workspace-cqijrvzx", "event": "load_session", "session_id": "qa-durable-session-1234567890"},
{"event": "prompt", "prompt_text": "QA: verify ACP durable resume behavior", "session_id": "qa-durable-session-1234567890"}
],
"field_present": true
}This confirms the explicit durable id is used for session/load and the prompt continues on the loaded session.
Test 2: Explicit id overrides filesystem id and falls back on load failure
Step 1 — Baseline:
On base 50776d44, the field was absent ("field_present": false above), so there was no explicit durable-id override path to exercise.
Step 2 — Apply the PR's changes:
Stayed on c2324ca5967fff13c5f5b803dcc62f66109f22bd.
Step 3 — Run override and failure scenarios:
Ran OPENHANDS_SUPPRESS_BANNER=1 timeout 75 uv run python /tmp/qa_acp_resume_scenarios.py:
{
"override_fs_id": [
{"event": "initialize", "protocol_version": 1},
{"cwd": "/tmp/qa-acp-override-workspace-05kcfwv7", "event": "load_session", "session_id": "qa-explicit-session-OVERRIDE9999"},
{"event": "prompt", "prompt_text": "QA scenario override", "session_id": "qa-explicit-session-OVERRIDE9999"}
],
"fallback_after_load_failure": [
{"event": "initialize", "protocol_version": 1},
{"cwd": "/tmp/qa-acp-fallback-workspace-oq7f9wwp", "event": "load_session", "session_id": "qa-missing-session-FALLBACK8888"},
{"cwd": "/tmp/qa-acp-fallback-workspace-oq7f9wwp", "event": "new_session"},
{"event": "prompt", "prompt_text": "QA scenario fallback", "session_id": "fresh-after-fallback"}
]
}This confirms explicit ids take precedence over filesystem ids, and failed session/load recovers by starting a fresh session.
Test 3: Secret serialization round-trips
Step 1 — Baseline without the fix:
Ran OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/qa_acp_resume_serialization.py on 50776d44:
{
"field_present": false,
"supports_serialization": false
}The old SDK did not expose the field.
Step 2 — Apply the PR's changes:
Checked out c2324ca5967fff13c5f5b803dcc62f66109f22bd.
Step 3 — Re-run with the fix in place:
Ran the same command:
{
"default_contains_plaintext": false,
"default_is_redacted": true,
"default_value": "**********",
"encrypted_contains_plaintext": false,
"encrypted_roundtrip_value": "qa-secret-resume-id-do-not-leak-ABCDEFGH",
"field_present": true,
"plaintext_roundtrip_value": "qa-secret-resume-id-do-not-leak-ABCDEFGH",
"redacted_reload_value": null
}This confirms default dumps redact the id, trusted plaintext round-trip works, encrypted round-trip works, and redacted reload does not turn into a literal ********** session id.
Test 4: Runtime log hygiene
The PR branch correctly fingerprinted the new resume/load log lines:
Using explicit acp_resume_session_id (...RIDE9999); filesystem agent_state had id=...RONG0000
Resumed ACP session ...RIDE9999 (cwd=/tmp/qa-acp-override-workspace-05kcfwv7)
ACP load_session(...BACK8888) failed (unknown session); starting a fresh session
But the same run also emitted full session ids from another ACP warning path:
UsageUpdate not received within 2.0s for session qa-explicit-session-OVERRIDE9999
UsageUpdate not received within 2.0s for session fresh-after-fallback
This is the issue listed below.
Issues Found
- 🔴 Critical: Full ACP session ids can still be written to logs via the UsageUpdate timeout warning, even when the session id came from
acp_resume_session_idand is treated as a bearer secret elsewhere.
This review was created by an AI agent (OpenHands) on behalf of the user.
|
Added a second commit ( It was an Like Happy to split this into its own PR if you'd rather keep OpenHands/OpenHands#3506 scoped to resume. |
QA on #3506 found the explicit resume id still reached logs in full via the ``UsageUpdate not received ... for session <id>`` timeout warning, despite the PR treating ACP session ids as bearer secrets. Those warning lines (plus the fork-session variant, the "Switched ACP session model" info line, and the "Could not reapply model ... on resumed session" warning) predate this PR and were never fingerprinted. Wrap their session-id args in ``_fingerprint_session_id(...)`` so every ACP log line that includes a session id emits ``...<last-8>`` instead of the full bearer token — completing the log-hygiene invariant the PR introduced. Only the ``logger.*`` sites are touched; ``session/load`` / ``prompt`` / ``set_session_mode`` protocol args keep the real id. Strengthens the existing usage-timeout test to assert the id is fingerprinted (not leaked) in the warning. Full test_acp_agent + test_settings = 398 passed, ruff clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
Code Review: Approve
This is a thorough, security-conscious feature implementation. Overall the quality is high.
Summary
The PR adds two fields to ACPAgentSettings:
-
acp_resume_session_id— Enables durable session resume even when the per-conversation filesystem is wiped (e.g., cloud sandbox recycling). The ACP session ID is mirrored into durable external storage and passed back on fresh launches. -
acp_isolate_data_dir— Gives the ACP subprocess a per-conversation data/config root instead of the sharedHOME(useful when multiple conversations share one sandbox).
Flags & Suggestions
1. acp_isolate_data_dir forwarding to ACPAgent.__init__
In model.py line 1372 the setting is forwarded to ACPAgent.__init__. Please confirm ACPAgent already accepts acp_isolate_data_dir as a parameter.
2. Type annotation for acp_resume_session_id
The serializer returns None for None — correct. The validator uses validate_secret which is a good pattern matching other secret fields.
3. _fingerprint_session_id helper
Well-documented private function. The 8-character suffix length is reasonable for log correlation without risking brute-force of the full token. Test coverage is included.
4. Test coverage is comprehensive
- Tests cover key flows: explicit id drives
load_sessionwhen FS state is empty, explicit id overrides FS id, explicit id failure falls back tonew_session - Session id redaction in logs is verified
- Bearer-secret serialization round-trip tests are present
Minor Suggestions
- The
acp_isolate_data_dirfield description says "see #1019" — consider adding the issue link to the PR description for context
Risk Assessment
| Change | Risk | Notes |
|---|---|---|
New field acp_resume_session_id |
Low | Secret handling is well-designed: redact-by-default serialization, validator restores value, _fingerprint_session_id prevents log leakage |
New field acp_isolate_data_dir |
Low | Simple boolean flag, off by default |
acp_isolate_data_dir forwarding |
Medium | Dependent on ACPAgent accepting the parameter - verify this |
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
all-hands-bot
left a comment
There was a problem hiding this comment.
✅ QA Report: PASS
I verified the ACP durable resume/settings-wire behavior by running real SDK scripts and an actual ACP subprocess conversation harness; the PR behavior works as described.
Does this PR achieve its stated goal?
Yes. On main, passing acp_resume_session_id did not cause session/load and ACPAgentSettings(acp_isolate_data_dir=True) still produced an agent with isolation disabled. On this PR, the same real SDK usage loads the explicit durable session id, falls back to new_session when the ACP server rejects it, forwards acp_isolate_data_dir=True, and redacts/round-trips the resume id through the wire serialization modes.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed successfully; no tests/linters were run locally. |
| CI Status | qa-changes, Windows binary build, and image builds were still in progress, with no completed failures observed. |
| Functional Verification | ✅ Real Python SDK usage and an ACP subprocess conversation harness matched the PR goals. |
Functional Verification
Test 1: ACPAgentSettings.acp_isolate_data_dir reaches the built agent, and resume id is safe on the wire
Step 1 — Establish baseline on main:
Ran git switch --detach origin/main, then OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/qa_settings_wire.py:
SETTINGS_FORWARDING {"default_agent_isolated": false, "explicit_agent_isolated": false, "settings_has_field": false}
RESUME_SECRET_WIRE_ERROR {"message": "'ACPAgent' object has no attribute 'acp_resume_session_id'", "type": "AttributeError"}
This shows the old behavior: the settings model had no isolation field to propagate, and the resume session id was not a usable ACPAgent field.
Step 2 — Apply the PR's changes:
Ran git switch acp-resume-session-id-field at commit 152e1ec15ba0a05cf582d4f1bfc99ed3d01f9bda.
Step 3 — Re-run with the fix in place:
Ran OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/qa_settings_wire.py:
SETTINGS_FORWARDING {"default_agent_isolated": false, "explicit_agent_isolated": true, "settings_has_field": true}
RESUME_SECRET_WIRE {"agent_has_field": true, "default_leaks_secret": false, "default_redacted": true, "default_reload_is_none": true, "encrypted_leaks_secret": false, "encrypted_roundtrip": true, "plaintext_roundtrip": true}
This confirms the settings/wire channel now carries both intended knobs: isolation forwards from settings into ACPAgent, default serialization redacts the resume id, redacted dumps reload as None, and plaintext/encrypted trusted round-trips recover the real value.
Test 2: explicit durable resume id drives real ACP session/load and falls back to new_session
Step 1 — Establish baseline on main:
Ran OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/qa_acp_functional.py, which starts an actual local ACP server subprocess and runs a one-message Conversation with ACPAgent(acp_resume_session_id=...):
SUCCESS_LOAD [{"event": "connect"}, {"event": "initialize", "protocol_version": 1}, {"cwd": "/tmp/tmp85u6axpg/workspace", "event": "new_session"}, {"event": "prompt", "prompt_text": "Please respond once for QA.", "session_id": "fresh-session-from-server"}]
LOAD_FAIL_FALLBACK [{"event": "connect"}, {"event": "initialize", "protocol_version": 1}, {"cwd": "/tmp/tmpil4_o7q_/workspace", "event": "new_session"}, {"event": "prompt", "prompt_text": "Please respond once for QA.", "session_id": "fresh-session-from-server"}]
This confirms the baseline does not use the explicit durable id; it starts a fresh ACP session even when the caller supplies acp_resume_session_id.
Step 2 — Apply the PR's changes:
Switched back to the PR branch at 152e1ec15ba0a05cf582d4f1bfc99ed3d01f9bda.
Step 3 — Re-run with the fix in place:
Ran OPENHANDS_SUPPRESS_BANNER=1 uv run python /tmp/qa_acp_functional.py:
SUCCESS_LOAD [{"event": "connect"}, {"event": "initialize", "protocol_version": 1}, {"cwd": "/tmp/tmpfwh836df/workspace", "event": "load_session", "session_id": "durable-session-12345678"}, {"event": "prompt", "prompt_text": "Please respond once for QA.", "session_id": "durable-session-12345678"}]
LOAD_FAIL_FALLBACK [{"event": "connect"}, {"event": "initialize", "protocol_version": 1}, {"cwd": "/tmp/tmplhm_8aok/workspace", "event": "load_session", "session_id": "durable-session-12345678"}, {"cwd": "/tmp/tmplhm_8aok/workspace", "event": "new_session"}, {"event": "prompt", "prompt_text": "Please respond once for QA.", "session_id": "fresh-session-from-server"}]
This shows the new behavior end-to-end: a fresh conversation with no filesystem state calls ACP load_session with the explicit durable id, uses that id for the prompt when load succeeds, and correctly falls back to new_session if the ACP server rejects the load. Runtime logs also fingerprinted the fake session id as ...12345678 instead of printing the full value.
Issues Found
None.
AI-generated QA review posted by OpenHands on behalf of the requester.
Per review feedback, mark the module-level log-suffix constant with typing.Final to signal that it is not meant to be reassigned. Co-authored-by: openhands <openhands@all-hands.dev>
…dir on ACPAgentSettings (OpenHands#3506) Co-authored-by: Simon Rosenberg <simon@openhands.dev> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: openhands <openhands@all-hands.dev>
This PR adds two ACP fields that cloud / grouped-sandbox deployments need, both reachable over the settings/wire channel:
ACPAgent.acp_resume_session_id— durable nativesession/loadresume (the original change).acp_isolate_data_dironACPAgentSettings— promote the existingACPAgent-only isolation flag onto the settings model so it can be set viaagent_settings.1.
acp_resume_session_id— durable native resumeWhy
The SDK half of cloud ACP resume (OpenHands/agent-canvas#2116, part of OpenHands/OpenHands#15746). An ACP conversation resumed on a fresh sandbox needs two pieces of state that both die with the old
/workspacePVC: the session id (inbase_state.json) and the CLI's own session files. This PR delivers the id half — an explicit override the app-server can feed back from durable storage (Postgres mirror, OpenHands#14506) when the FS-persisted id is gone.What
ACPAgent.acp_resume_session_id: when set,_start_acp_serveruses it as the prior session id forsession/load, in precedence overstate.agent_state["acp_session_id"]. The rest of the existing resume machinery is reused unchanged — cwd guard,load_session, andACPRequestError→new_sessionfallback.model_dump/model_dump_jsonredacts; trusted backends opt into plaintext (expose_secrets='plaintext'); frontend round-trips use encrypted+cipher. A matchingfield_validatorreloads the redacted sentinel / ciphertext back toNone/ plaintext, so a serialized agent never sends"**********"intosession/load._fingerprint_session_idrenders ids as...<last-8>in log lines — they're bearer tokens, and log aggregators (Datadog/CloudWatch) are a serialization boundary that retains lines for weeks.session/loadvalidation (→ACPRequestError→new_session) be the backstop — the same recovery path as a forgotten id.init_statefeeds the effective id into main's existingtruly_resumedcheck so suffix re-injection stays correct.Relationship to OpenHands/OpenHands#3343 (supersedes)
This is the field-only core of OpenHands/OpenHands#3343, rebased onto current
main. OpenHands/OpenHands#3343 was opened ~83 commits back and also carried aCLAUDE_CONFIG_DIR/API-key-stripping decouple — that half is dropped here because:_isolate_acp_data_dircarve-out (feat(acp): per-conversation CLI data-dir isolation for grouped sandboxes #3492) already governs Claude relocation, andKeeping this PR to just the field makes it the clean, approach-agnostic dependency that unblocks OpenHands#14506's
'acp_resume_session_id' in ACPAgent.model_fieldsfeature guard. OpenHands/OpenHands#3343 will be closed in favour of this.Tests
tests/sdk/agent/test_acp_agent.py— precedence (drives load w/o FS state, overrides FS id, failure→new_session, matches-FS-uses-FS-cwd), log redaction, the fingerprint helper, and the bearer-secret round-trips (redacted-by-default, plaintext, encrypted, sentinel→None). 333 passed; ruff + pyright clean.2. Expose
acp_isolate_data_dironACPAgentSettingsWhy
acp_isolate_data_dir(OpenHands/agent-canvas#2114 / OpenHands/OpenHands#3492) was anACPAgent-only field, so it had no settings/wire slot: an application configuring ACP throughagent_settingscould not opt a conversation into a per-conversation CLI data/config root — the value always took itsFalsedefault.What
Promote it onto
ACPAgentSettingsand forward it throughcreate_agent()into the constructedACPAgent(the missing link). Likeacp_file_secrets, it's a programmatic/downstream knob — noSETTINGS_METADATA_KEY, so it stays out of the settings-form UI (the schema-section test set is unchanged). Additive, defaultsFalse→ backward compatible.Unblocks the agent-canvas containerized-ACP TODO (OpenHands/agent-canvas#1102, part of OpenHands/agent-canvas#2117): once this ships in
@openhands/typescript-client, canvas setsacp_isolate_data_dir: true(Docker-gated) in one line, replacing the TODO.Tests
tests/sdk/test_settings.py::test_acp_create_agent_forwards_isolate_data_dir— default-Falseand explicit-Trueboth propagate throughcreate_agent(). Fulltests/sdk/test_settings.py+tests/sdk/agent/test_acp_agent.py= 398 passed; ruff clean.🤖 Generated with Claude Code
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimgolang: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:b8cd6bb-pythonRun
All tags pushed for this build
About Multi-Architecture Support
b8cd6bb-python) is a multi-arch manifest supporting both amd64 and arm64b8cd6bb-python-amd64) are also available if needed