Repository navigation
refactor(anthropic): replace handwritten Claude sessions with Agent SDK - #128131
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 4:33 AM ET / 08:33 UTC. ClawSweeper reviewWhat this changesReplaces the Anthropic plugin’s handwritten warm Claude CLI session transport with Anthropic’s Agent SDK and a generic host-owned reusable-session interface. Merge readinessKeep open for maintainer review: this replaces a security- and availability-sensitive Claude execution path and adds a public CLI-plugin transport; no concrete code defect was found, but the pinned SDK contract could not be directly audited and two current check lanes are failing. Priority: P2 Review scores
Verification
How this fits togetherLocal Claude CLI agent turns are prepared by the Anthropic plugin, executed through the core CLI runner, and returned as normalized agent output. This change moves Claude subprocess/session handling into the official SDK while core retains admission, tool approval, MCP capture, and cleanup ownership. flowchart LR
A[Agent turn] --> B[Anthropic CLI plugin]
B --> C[Core CLI runner]
C --> D[Host-owned session and approval gate]
D --> E[Anthropic Agent SDK]
E --> F[Installed Claude Code process]
F --> G[Streamed agent output]
D --> H[Gateway MCP tools]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The new SDK-backed custom spawn and permission path needs an exact-version dependency audit before merge. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Complete a direct audit of the resolved Agent SDK version and land only after exact-head validation demonstrates safe upgrade behavior for existing Claude CLI sessions. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a runtime refactor rather than a report of a separately reproducible user defect; the PR body supplies post-change runtime evidence. Is this the best way to solve the issue? Unclear: the generic host-owned seam is coherent, but direct inspection of the exact Agent SDK contract is still required before calling this the best implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3e5b935edf3f. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
Related: #144392 Supersedes #145788 by @Marvinthebored. Thanks to @EnotionZ for the issue report. The original commit and authorship are preserved. ## What Problem This Solves Canceling a reply makes the next turn forget the conversation, even though earlier messages still appear in history. ## User Impact Stopping a reply keeps the established conversation available for the next turn. Invalid sessions and account boundaries still receive their existing checks. ## Why This Change Was Made Retain established native bindings on cancellation. Clear unfinished replacements on both thrown errors and returned partial-output interruptions. An incomplete fork claim is restored by current-owner cleanup even when the signal is aborted. New claims, successor publication, and recovery arming retain their abort guards; all writes retain session, lifecycle, writer, and source-binding checks. This preserves partial-output reporting from #126883 while removing cancellation-only binding invalidation. No schema, migration, configuration, protocol, or dependency change. ## Final-head evidence Head `b068bf05618ddcd3e1b28894c68ad734e0eac997` includes a one-line test-type correction that passes the existing defined session entry; the command still reloads persisted state before choosing the next native binding. All 157 tests in that file, targeted lint, and formatting pass. Production source is unchanged from `2c163fd9eb57100ae3a2eec38cb6038e5f752851`. The complete affected owner suites passed on fresh merge `4b66a1a18209c21b5e92986452b2b98b95ae6fa1`, with parents `2c163fd9eb57100ae3a2eec38cb6038e5f752851` and main `9542320aa5cdcc4af53e3b05ad75160992a34407`. All **28 complete canonical groups exited 0**: 46,971 labeled passes and 88 skips. Three cases are unlabelled in the native support summary; no status is inferred. This includes both fork-restoration cases and all four abort/timeout × established/replacement command cases. Complete current group membership, exact commands, numeric exits, and raw logs are retained. ```sh env -u NO_COLOR -u FORCE_COLOR node --import tsx scripts/ci-run-node-test-shard.mts ``` Hosted [CI run 34774482283, attempt 1](https://github.com/openclaw/openclaw/actions/runs/34774482283) passed except `checks-node-compact-small-32` and its aggregate gate. Its QA-profile routing assertion is **base-red**: the same test fails on plain main `28887b564210326174413d0d8ade72b38268d5f3` and fresh candidate/main merge `7ea7374fcf62570c9b3fa631cf17072ef5eda2d6`, both exit 1. #143968 (`07b96d9b4122e1afdd0efbb662b2335eb716dfec`) added `qa-profile-run-status.test.ts` as a sixth workflow reader without updating the five-target expectation. This PR changes none of those routing inputs. ```sh OPENCLAW_E2E_USE_PREBUILT_DIST=1 node scripts/run-vitest.mjs run \ test/scripts/test-projects.test.ts -t 'routes QA Profile Evidence' ``` ## Fork-claim correction Candidate `2c163fd9eb57100ae3a2eec38cb6038e5f752851` restores a committed fork claim after cancellation before a successor appears. Previously, restoration rejected the aborted signal, lost the fork marker, and let the next command resume the source directly. Cleanup now uses the existing current-owner settlement assertion. Stale session, lifecycle, writer, placement, and source-binding checks remain enforced. The regression fails on `e2ca5b29bfa09810aaa20eca8a1d0e85ced913c8`: the marker is absent and the next command receives `forkCliSessionOnResume=false`. After correction, both the recovery-error control and actual-signal cancellation pass; stored/cache markers and the source checkpoint remain, and the next command receives `forkCliSessionOnResume=true`. ```sh env -u NO_COLOR -u FORCE_COLOR node scripts/run-vitest.mjs run \ --config test/vitest/vitest.agents.config.ts \ src/agents/command/attempt-execution.cli.test.ts --maxWorkers=1 \ -t 'preserves a restored fork marker before a successor' ``` Fresh merge `54a5c90a8b4585f72842e380365b95263b05983d` has first parent candidate `2c163fd9eb57100ae3a2eec38cb6038e5f752851` and second parent main `adb6e518a44218650883f3daec4bd319165e0017`. All **436 tests in seven complete focused files passed**, including command successor/flag cleanup, aborted pre-successor restoration, stale-store guards, returned interruption, thrown cancellation, auto-reply, and fork-runner siblings. This bounded rerun supplements the earlier complete suites. Both real Gateway cancellation shapes also passed on that merge: before output (zero assistant events) and after first output. Both next turns resumed the same native binding, logged `historyPrompt=none`, and recalled `PEBBLE-7429`. Both drivers exited 0. The new catalog regression uses the real command/store entry point with a mocked native runner; it proves next-turn fork routing, not a new live source-transcript isolation capture. Targeted lint passed, including max-lines: ```sh pnpm exec oxlint --config .oxlintrc.json \ src/agents/command/attempt-execution.ts \ src/agents/command/attempt-execution.cli.test.ts ``` Original red evidence remains intact. Exact commands, merge identities, numeric exits, and complete captures are retained. The complete affected-suite rerun and final-head CI classification are recorded above. ## Earlier evidence Validated corrected candidate `4fd555e5957f86289cf981ce4cf4b0bb1122c679` on temporary merge `d5f41d1cd6c9b603db32deec1d60c1ba93e7e04d`. Its parents are that candidate and main `a0cce74d389d737d6dcf21de7344af10cf862f72`. All 28 complete canonical CI groups for the affected agent, reply, scheduled-run, and fast test suites exited 0 on that merge. Reporters label **46,859 tests passed and 88 skipped**. The full command persistence matrix passed, including unfinished-successor and temporary-flag cleanup for abort and timeout, plus established-binding resume. Each complete group ran through the CI command, with its canonical configuration, include list and environment preserved: ```sh node --import tsx scripts/ci-run-node-test-shard.mts ``` These are the complete affected test suites on the recorded merge. Final-head CI and its reproduced base-red exception are recorded above. Initial host setup failures were retained, then resolved by removing conflicting color settings and making GNU timeout available without replacing existing command resolution. No source assertions or timeouts were relaxed. One native summary leaves three cases unlabeled; the raw count line is retained without assigning them a status. The real Gateway was also rerun from the merge with isolated state, workspace and port: ```sh OPENCLAW_CONFIG_PATH="$PROOF/openclaw.json" OPENCLAW_STATE_DIR="$PROOF/state" \ pnpm openclaw gateway --port 21978 --bind loopback ``` `chat.send` remembered a synthetic code, a second request started a long reply, `chat.abort` canceled it, and the next `chat.send` requested the code without repeating it. | Cancellation | Recorded main | Corrected merge | | --- | --- | --- | | Before output | Fresh native session; `UNKNOWN` | Same native binding; `PEBBLE-7429` | | After first output | Fresh native session; `UNKNOWN` | Same native binding; `PEBBLE-7429` | Both drivers exited 0. Both continuations logged `useResume=true` with the same native fingerprint and `historyPrompt=none`. The pre-output run had zero assistant events before cancellation. Original red captures, merge parents, selection, exact commands, numeric exits and complete logs are preserved. Final-head CI and its reproduced base-red exception are recorded above. ## Compatibility and prior behavior This deliberately changes the cancellation-only binding invalidation retained by #126883 and #128131. Partial output remains visible, interrupted turns remain unsuccessful, and successful authentication settlement remains suppressed. Expired-session recovery from #115513 and the retired-field migration from #143347 remain unchanged. There is no schema, migration, configuration, protocol, dependency, or permission change. ## Consumers Command attempts, auto-reply turns, and scheduled turns consume the binding result. History import, session freshness, catalog continuation, export, runtime selection, and detached-media continuation read the retained binding or its explicit absence. Catalog adoption seeds a binding with `forceReuse` and a one-shot fork marker. The command path claims that marker before execution and can persist a successor before final settlement. These writes require the current session, lifecycle, writer, and expected source binding. Successful settlement removes the temporary reuse flag; interrupted replacement cleanup removes the successor and flag together. An established binding remains available after cancellation. Cancellation before a fork successor appears restores the one-shot marker, so the next command must still fork from the source. Cache updates occur at the successful commit, and scheduled continuation publication follows base-session persistence. ## Evidence limits The real Gateway sequences cover cancellation before output and after the first output. Both failed on main `fe3b2891fdeaa1a891d54cb2b306e975fc5408cf` and passed at `f9c5b148cf4d92de5211315a4e8c374bef279d9d`. The next turn resumed the same native binding without replaying local history and recalled the seeded code. The initial 272 focused tests include command persistence and next-turn routing, auto-reply retention, failed-flush cleanup, and scheduled-run settlement. They ran on the branch based on `f85a9945daaebc61d041db27b4d3175d17082e37`. The later fresh merge `d5f41d1cd6c9b603db32deec1d60c1ba93e7e04d`, recorded above, passed all 28 complete affected test groups and both real Gateway cancellation shapes. No browser-click or platform-specific UI claim is made. The two test suites that failed on the contributor head pass when applied to the refreshed main base and after correction. The original hosted failures were not reproduced in their original shard order, so their cause remains unclassified. No assertion or timeout was relaxed for this repair. ## Test ledger clarification - The ordinary-abort policy and command assertions now require retention instead of unconditional deletion. Command coverage also checks the subsequent resume. - The contributor-only interrupted-flush helper matrix was removed before the final diff because command persistence coverage supersedes it. - The retained interrupted-partial-output fixture now names an established reusable session. Its unchanged clear assertion independently protects failed transcript flush; its partial-output, unsuccessful-hook, timeout, and authentication assertions remain. - The new composition cases invoke `runAgentAttempt`, claim a fork, persist its successor, abort the actual signal, consume the production settlement result, reopen stored state, and check the next attempt. The channel regression invokes `executeAgentTurn`; the failed-flush regression invokes `runPreparedCliAgent`. Direct policy-unit assertions supplement these entry-point checks. The earlier head `e2ca5b29bfa09810aaa20eca8a1d0e85ced913c8` only replaces a retained unflushed ID with the equivalent condition at its two consumers. Review accepted that behavior-preserving delta. CI run [34769866871](https://github.com/openclaw/openclaw/actions/runs/34769866871) passed at attempt 2 on this exact head. Attempt 1 had one test failure in an unrelated QA binary-admission case; it passed on the retry without a code or timeout change and is recorded as a flake. Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Related: openclaw#144392 Supersedes openclaw#145788 by @Marvinthebored. Thanks to @EnotionZ for the issue report. The original commit and authorship are preserved. ## What Problem This Solves Canceling a reply makes the next turn forget the conversation, even though earlier messages still appear in history. ## User Impact Stopping a reply keeps the established conversation available for the next turn. Invalid sessions and account boundaries still receive their existing checks. ## Why This Change Was Made Retain established native bindings on cancellation. Clear unfinished replacements on both thrown errors and returned partial-output interruptions. An incomplete fork claim is restored by current-owner cleanup even when the signal is aborted. New claims, successor publication, and recovery arming retain their abort guards; all writes retain session, lifecycle, writer, and source-binding checks. This preserves partial-output reporting from openclaw#126883 while removing cancellation-only binding invalidation. No schema, migration, configuration, protocol, or dependency change. ## Final-head evidence Head `b068bf05618ddcd3e1b28894c68ad734e0eac997` includes a one-line test-type correction that passes the existing defined session entry; the command still reloads persisted state before choosing the next native binding. All 157 tests in that file, targeted lint, and formatting pass. Production source is unchanged from `2c163fd9eb57100ae3a2eec38cb6038e5f752851`. The complete affected owner suites passed on fresh merge `4b66a1a18209c21b5e92986452b2b98b95ae6fa1`, with parents `2c163fd9eb57100ae3a2eec38cb6038e5f752851` and main `a9a9a16114bea90d6eac90486356697df2462cb9`. All **28 complete canonical groups exited 0**: 46,971 labeled passes and 88 skips. Three cases are unlabelled in the native support summary; no status is inferred. This includes both fork-restoration cases and all four abort/timeout × established/replacement command cases. Complete current group membership, exact commands, numeric exits, and raw logs are retained. ```sh env -u NO_COLOR -u FORCE_COLOR node --import tsx scripts/ci-run-node-test-shard.mts ``` Hosted [CI run 34774482283, attempt 1](https://github.com/openclaw/openclaw/actions/runs/34774482283) passed except `checks-node-compact-small-32` and its aggregate gate. Its QA-profile routing assertion is **base-red**: the same test fails on plain main `a1105f105a093f768914a29c24b70d6ba406cad8` and fresh candidate/main merge `7ea7374fcf62570c9b3fa631cf17072ef5eda2d6`, both exit 1. openclaw#143968 (`41aebf15de48524e80c95f05e0c1212f2dfd29c6`) added `qa-profile-run-status.test.ts` as a sixth workflow reader without updating the five-target expectation. This PR changes none of those routing inputs. ```sh OPENCLAW_E2E_USE_PREBUILT_DIST=1 node scripts/run-vitest.mjs run \ test/scripts/test-projects.test.ts -t 'routes QA Profile Evidence' ``` ## Fork-claim correction Candidate `2c163fd9eb57100ae3a2eec38cb6038e5f752851` restores a committed fork claim after cancellation before a successor appears. Previously, restoration rejected the aborted signal, lost the fork marker, and let the next command resume the source directly. Cleanup now uses the existing current-owner settlement assertion. Stale session, lifecycle, writer, placement, and source-binding checks remain enforced. The regression fails on `e2ca5b29bfa09810aaa20eca8a1d0e85ced913c8`: the marker is absent and the next command receives `forkCliSessionOnResume=false`. After correction, both the recovery-error control and actual-signal cancellation pass; stored/cache markers and the source checkpoint remain, and the next command receives `forkCliSessionOnResume=true`. ```sh env -u NO_COLOR -u FORCE_COLOR node scripts/run-vitest.mjs run \ --config test/vitest/vitest.agents.config.ts \ src/agents/command/attempt-execution.cli.test.ts --maxWorkers=1 \ -t 'preserves a restored fork marker before a successor' ``` Fresh merge `54a5c90a8b4585f72842e380365b95263b05983d` has first parent candidate `2c163fd9eb57100ae3a2eec38cb6038e5f752851` and second parent main `e08263bdd3341031c219bb147638f23a1f4c3c03`. All **436 tests in seven complete focused files passed**, including command successor/flag cleanup, aborted pre-successor restoration, stale-store guards, returned interruption, thrown cancellation, auto-reply, and fork-runner siblings. This bounded rerun supplements the earlier complete suites. Both real Gateway cancellation shapes also passed on that merge: before output (zero assistant events) and after first output. Both next turns resumed the same native binding, logged `historyPrompt=none`, and recalled `PEBBLE-7429`. Both drivers exited 0. The new catalog regression uses the real command/store entry point with a mocked native runner; it proves next-turn fork routing, not a new live source-transcript isolation capture. Targeted lint passed, including max-lines: ```sh pnpm exec oxlint --config .oxlintrc.json \ src/agents/command/attempt-execution.ts \ src/agents/command/attempt-execution.cli.test.ts ``` Original red evidence remains intact. Exact commands, merge identities, numeric exits, and complete captures are retained. The complete affected-suite rerun and final-head CI classification are recorded above. ## Earlier evidence Validated corrected candidate `4fd555e5957f86289cf981ce4cf4b0bb1122c679` on temporary merge `d5f41d1cd6c9b603db32deec1d60c1ba93e7e04d`. Its parents are that candidate and main `e0ad90d2bc2effce521cbde79cec2be56cece725`. All 28 complete canonical CI groups for the affected agent, reply, scheduled-run, and fast test suites exited 0 on that merge. Reporters label **46,859 tests passed and 88 skipped**. The full command persistence matrix passed, including unfinished-successor and temporary-flag cleanup for abort and timeout, plus established-binding resume. Each complete group ran through the CI command, with its canonical configuration, include list and environment preserved: ```sh node --import tsx scripts/ci-run-node-test-shard.mts ``` These are the complete affected test suites on the recorded merge. Final-head CI and its reproduced base-red exception are recorded above. Initial host setup failures were retained, then resolved by removing conflicting color settings and making GNU timeout available without replacing existing command resolution. No source assertions or timeouts were relaxed. One native summary leaves three cases unlabeled; the raw count line is retained without assigning them a status. The real Gateway was also rerun from the merge with isolated state, workspace and port: ```sh OPENCLAW_CONFIG_PATH="$PROOF/openclaw.json" OPENCLAW_STATE_DIR="$PROOF/state" \ pnpm openclaw gateway --port 21978 --bind loopback ``` `chat.send` remembered a synthetic code, a second request started a long reply, `chat.abort` canceled it, and the next `chat.send` requested the code without repeating it. | Cancellation | Recorded main | Corrected merge | | --- | --- | --- | | Before output | Fresh native session; `UNKNOWN` | Same native binding; `PEBBLE-7429` | | After first output | Fresh native session; `UNKNOWN` | Same native binding; `PEBBLE-7429` | Both drivers exited 0. Both continuations logged `useResume=true` with the same native fingerprint and `historyPrompt=none`. The pre-output run had zero assistant events before cancellation. Original red captures, merge parents, selection, exact commands, numeric exits and complete logs are preserved. Final-head CI and its reproduced base-red exception are recorded above. ## Compatibility and prior behavior This deliberately changes the cancellation-only binding invalidation retained by openclaw#126883 and openclaw#128131. Partial output remains visible, interrupted turns remain unsuccessful, and successful authentication settlement remains suppressed. Expired-session recovery from openclaw#115513 and the retired-field migration from openclaw#143347 remain unchanged. There is no schema, migration, configuration, protocol, dependency, or permission change. ## Consumers Command attempts, auto-reply turns, and scheduled turns consume the binding result. History import, session freshness, catalog continuation, export, runtime selection, and detached-media continuation read the retained binding or its explicit absence. Catalog adoption seeds a binding with `forceReuse` and a one-shot fork marker. The command path claims that marker before execution and can persist a successor before final settlement. These writes require the current session, lifecycle, writer, and expected source binding. Successful settlement removes the temporary reuse flag; interrupted replacement cleanup removes the successor and flag together. An established binding remains available after cancellation. Cancellation before a fork successor appears restores the one-shot marker, so the next command must still fork from the source. Cache updates occur at the successful commit, and scheduled continuation publication follows base-session persistence. ## Evidence limits The real Gateway sequences cover cancellation before output and after the first output. Both failed on main `0c664785f82d3af6c2101efb53d7269d30261f4c` and passed at `f9c5b148cf4d92de5211315a4e8c374bef279d9d`. The next turn resumed the same native binding without replaying local history and recalled the seeded code. The initial 272 focused tests include command persistence and next-turn routing, auto-reply retention, failed-flush cleanup, and scheduled-run settlement. They ran on the branch based on `329bc5bf9694af38477f9fd45ebe47ad86b538a9`. The later fresh merge `d5f41d1cd6c9b603db32deec1d60c1ba93e7e04d`, recorded above, passed all 28 complete affected test groups and both real Gateway cancellation shapes. No browser-click or platform-specific UI claim is made. The two test suites that failed on the contributor head pass when applied to the refreshed main base and after correction. The original hosted failures were not reproduced in their original shard order, so their cause remains unclassified. No assertion or timeout was relaxed for this repair. ## Test ledger clarification - The ordinary-abort policy and command assertions now require retention instead of unconditional deletion. Command coverage also checks the subsequent resume. - The contributor-only interrupted-flush helper matrix was removed before the final diff because command persistence coverage supersedes it. - The retained interrupted-partial-output fixture now names an established reusable session. Its unchanged clear assertion independently protects failed transcript flush; its partial-output, unsuccessful-hook, timeout, and authentication assertions remain. - The new composition cases invoke `runAgentAttempt`, claim a fork, persist its successor, abort the actual signal, consume the production settlement result, reopen stored state, and check the next attempt. The channel regression invokes `executeAgentTurn`; the failed-flush regression invokes `runPreparedCliAgent`. Direct policy-unit assertions supplement these entry-point checks. The earlier head `e2ca5b29bfa09810aaa20eca8a1d0e85ced913c8` only replaces a retained unflushed ID with the equivalent condition at its two consumers. Review accepted that behavior-preserving delta. CI run [34769866871](https://github.com/openclaw/openclaw/actions/runs/34769866871) passed at attempt 2 on this exact head. Attempt 1 had one test failure in an unrelated QA binary-admission case; it passed on the retry without a code or timeout change and is recorded as a flake. Co-authored-by: Marvinthebored <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Summary
Replace OpenClaw's handwritten Claude Code process, stream-protocol, turn, timeout, and session machinery with Anthropic's official
@anthropic-ai/claude-agent-sdk, following the same supported Claude Code execution boundary used by T3 Code. The SDK runs the user's installed, unmodified Claude executable and leaves subscription authentication inside Claude Code; a Claude subscription is not treated as direct Messages API access.4,701additions,10,069deletions); test/support code still shrinks by 4,245 lines despite the substantially stronger regression coverage.maininterrupted-response contract: streamed assistant text survives caller cancellation and deadlines, while the transcript, session binding, execution trace, completion reason, and agent-end hook consistently record an unsuccessful aborted/timeout turn.OPENCLAW_EXTENSIONSand optional-plugin runtime selection remain unchanged.Live evidence
The actual built production Anthropic adapter was executed against the real installed Claude Code executable, with all Anthropic credential environment variables removed and native tools denied. The genuine SDK/CLI process produced the following redacted structured events:
{"ok":false,"name":"Error","message":"Claude Code returned an error result: Failed to authenticate: OAuth session expired and could not be refreshed","events":[{"type":"system","subtype":"init"},{"type":"system","subtype":"status"},{"type":"assistant","error":"authentication_failed"},{"type":"result","subtype":"success","isError":true}]}This proves the bundled SDK chunk resolves, the real installed Claude subprocess starts, genuine initialization/status/assistant/result records stream through the simpler SDK-native string prompt, and the existing owner correctly handles Anthropic's error result despite its misleading success subtype.
Extended live testing then ran the actual built OpenClaw adapter, actual official Anthropic Agent SDK, and actual installed Claude Code executable against a loopback-only synthetic Anthropic SSE server with a throwaway fake API key. This produced genuine successful subprocess conversations without accessing any account or provider: streamed plain replies, exact zero-tool requests, a host-denied Bash tool attempt, an actually executed host-approved
printf SDK_TOOL_OKcommand whose output returned in the next real model request, and two successful turns retaining the same observed Claude PID and session UUID (one registration, two activations). It also proved successful persisted-session resume across distinct Claude PIDs, real process replacement with changed model/system prompt and owner generation, three isolated concurrent session owners, and correct 429/529 terminal error classification. In-flight cancellation terminated and demonstrably reaped the actual Claude PID; malformed settings/effort/turn-limit arguments and already-aborted admission failed before making HTTP requests. This proves the actual SDK/Claude process, native tool execution, and HTTP-stream integration, but the synthetic server is deliberately not subscription-authentication proof.The final rebuilt-artifact stress pass issued 61 synthetic provider requests through 28 actual Claude subprocesses, with zero surviving processes and zero retained owner handles. It proved ten consecutive turns on one Claude PID/session/generation, three genuinely parallel owners, same-owner overlap rejection, six alternating allowed/denied native Bash turns, persisted-session resume, model/system-prompt restart, HTTP 400/401/403/429/500/529 classification, malformed/truncated SSE, and partial streamed output before both abort and timeout.
The selected-credential path was live-tested separately through the actual built backend, installed Claude binary, and SDK custom spawner. A throwaway fake API key appeared only on descriptor 3, never in the subprocess environment or argv; all four copied credential buffers were zeroized. The real Claude process completed a plain response, denied a real Bash command before side effects, executed an explicitly approved real shell command, and reaped the child on cancellation.
Finally, the rebuilt production adapter and installed Claude Code executable were tested against Anthropic's actual hosted API using the existing approved live-test API key, retrieved without prompting or logging secrets and delivered exclusively through private descriptor 3. Five genuinely authenticated turns returned
LIVE_AUTH_OK, retainedBLUE-731across two turns on the same Claude process/session, denied a real Bash action, executed an approved real shell command returningLIVE_TOOL_OK, and canceled after visible streamed output. All five copied credential buffers were zeroized, the child environment contained no API key, and all five real Claude subprocesses were reaped. Total metered provider cost: $0.0313352. This proves real API-key authentication and the exact SDK/provider/tool path; it is not a claim of successful Claude subscription authentication.Additional actual-subprocess SDK control-protocol scenarios verified exact per-turn allow/deny callbacks, malformed tool-input rejection, gateway-MCP bypass only for host-owned tools, background-agent provisional-result holding, fingerprint-change restart, stale-owner rejection, pending-approval cancellation fencing, native session resume flags, and cleanup/reaping. An already-aborted one-shot initially launched a real Claude process; a failing regression captured that defect, and the fixed source plus rebuilt artifact now reject both default and custom abort reasons before any subprocess starts.
Both built operator entry points (
agent --localand isolatedagent exec) were also run with separate temporary state/config, no provider credentials, and the real installed Claude executable. Both reached the official SDK/warm-session owner and returned the same structured, actionable expired-OAuth failure; plugin discovery, Claude model catalog, MCP startup, and provider error classification were exercised end to end.A separate real SDK-to-Claude native Bash probe verified the OpenClaw approval callback remains authoritative across all four combinations of ordinary
disableAllHooksand enterprise-managedallowManagedHooksOnly/disableAllHooks. Even with settings that otherwise auto-allow Bash, the host callback denied the actual shell action, the model received the denial, and the command never executed.All three local Claude installations report
loggedIn: false, all six local Claude account slots reportno_credentials, and OpenClaw has no configured Anthropic OAuth profile. Consequently the real authenticated proof uses Anthropic's approved live-test API key, not a Claude subscription. Anthropic's current first-party documentation explicitly supports subscription-backed Agent SDK and third-party app usage through the user's own already-authenticated, unmodified Claude executable; the newly documentedclaude auth loginrecovery is the required operator setup for that credential variant.Verification
main's explicit-current-source delivery regression, across the SDK provider, lifecycle/approval/cleanup owners, Docker/build ownership, CLI help, interrupted-response integration, and provider/CLI contract suites. Newly added cases cover real process-grandchild termination, private descriptor delivery/zeroization, 1 MiB child-stderr drainage, ambient and selected-credential native approval, variadic directory/tool arguments, prompt-file and cache-marker elimination, exact MCP capture ownership, hard approval/background deadlines, two-turn cleanup, restart, cancellation races, and both abort/deadline settlement.npm pack --dry-run --json --ignore-scriptsinspection proves zeronode_modulesentries and zero SDK native binaries in the published artifact; the SDK JavaScript contributes an approximately 1.2 MiB production chunk. Source/Docker installs select at most the matching host binary; the dependency already exists in the full workspace through ACPX.Credential and dependency boundaries
THIRD_PARTY_NOTICES.mdentry is added for a dependency.Related context