Skip to content

refactor(anthropic): replace Agent SDK with direct CLI transport - #138707

Merged
steipete merged 6 commits into
mainfrom
codex/anthropic-direct-cli
Sep 5, 2026
Merged

steipete merged 6 commits into
mainfrom
codex/anthropic-direct-cli

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

OpenClaw distributes the Claude Agent SDK for an integration that runs the user's installed Claude Code executable. This removes that dependency and its copied package assets while retaining Claude CLI support.

Related: anthropics/claude-agent-sdk-typescript#224

Why This Change Was Made

The Anthropic plugin now owns the CLI's bidirectional stream-json transport. The shared runner retains admission, approvals, questions, credential handling, timeouts, warm-session registration, and MCP lifetime. Private prompt context, native tool policy, session resume/fork, and process-tree cleanup remain supported. Permission callbacks revalidate the admitted turn immediately before their response is written, and failed turns cannot leave background work attached to a later admission.

The audit traced 112 relevant commits after SDK adoption in 12d0fd2 (#128131), retaining the later question, permission, environment, credential, session, MCP, diagnostics, and compaction fixes. Direct inspection of Agent SDK 0.3.243 and native Claude's protocol found two contracts to preserve: unhandled MCP elicitation returns decline, and the plugin runner forwards the verified executable's script prefix and argv0. Before-fix subprocess and protocol tests reproduced both gaps. Detailed audit and proof.

The SDK asset copier, build exceptions, dependency entries, and SDK-option mocks are removed. Provider tests exercise real subprocesses and protocol messages.

User Impact

Existing Claude CLI configuration and native login continue to work with the separately installed Claude Code executable. Normal Anthropic API-key support retains its separate API client. No additional plugin installation, configuration change, or database migration is needed.

The Plugin SDK gains optional CliBackendExecuteContext.argv0 to preserve verified invocation through PATH shims. Prepared arguments retain the executable's script prefix; executors spawning the prepared command should forward both.

The separately installed ACPX adapter retains its own upstream Agent SDK dependency. ACPX is excluded from core distribution; this PR removes the bundled Anthropic provider's SDK dependency.

Evidence

Final CI passed on 0672fed74110f67f5fba354aaef2e49444438ed3, including both Windows jobs and real-Gateway E2E.

974 tests across 37 files passed on the initial implementation. After the audit fixes, 112 focused tests across eight files passed, covering the provider and shared runner. Fresh Codex reviews found no actionable P0–P2 findings. Formatting, lint, production/test types, dead-export scans, repository guards, and the full build passed.

Authenticated Gateway suites passed with both an API key and native subscription authentication: real parent/child execution, ordered completion announcement, resumed recall, image understanding, MCP discovery, and automation creation. Initial authenticated proof. A supplementary native subscription run on the refreshed runtime also passed, 1/1 test in 101.119 seconds, following a fresh frozen install and build. Refreshed runtime proof. Its source tree matches merge commit 11d251c; central transport and runner files remain unchanged through the final refresh. Stored reports recovered the result after the Testbox output connection was lost; the model run was not repeated.

Real Claude Code 2.1.243 and 2.1.261 against an isolated HTTP/SSE fixture additionally proved host denial overriding native allow settings, private context, warm reuse, cancellation, background final-result handling, cold resume, and checkpoint fork without altering the original history. Native Windows Claude cancellation was not live-tested; portable process tests and Windows CI cover the shared launcher.

On the live-tested refreshed runtime revision 11d251c65dc, the package passed both npm lock validators, package integrity, and the complete dist import graph. Its 10,066 entries contain zero Agent SDK asset paths or runtime JavaScript references, with no Agent SDK dependency in the root or bundled Anthropic manifest. Tarball: 58,795,536 bytes; SHA-256 ba9dbbbc3d1152afc814df74c95933e62a0b948ebf9d362a4e56a5e0b904c43d.

CI exposed an inconsistent dashboard navigation fixture, repaired upstream in #138769 and #138793. The branch preserves the current mainline fixture and all original browser assertions; the focused browser test and all 36 dashboard-owner tests passed. One supplementary local invocation case hit its one-second deadline under severe filesystem contention; its unchanged two-case rerun passed. No timeout was increased.

Production/build/manifests: +809/−845 (net −36). Tests/support: +1,057/−1,790 (net −733). Lockfile: −98. Documentation: +35/−33. Renames are discounted. The removed asset copier owned build output, and the invocation fingerprint belongs to a process-local Map; neither requires a saved-data migration.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: macos App: macos gateway Gateway runtime security Security documentation scripts Repository scripts agents Agent runtime and tooling extensions: anthropic size: XL maintainer Maintainer-authored PR labels Sep 4, 2026
@steipete
steipete marked this pull request as ready for review September 4, 2026 23:55
@steipete
steipete requested a review from a team as a code owner September 4, 2026 23:55
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/anthropic/package.json
  • package.json
  • pnpm-lock.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfiles or workspace dependency policy changes are present.
  • Treat pnpm-lock.yaml and package-lock.json diffs as dependency security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph changes noted

This PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin, a member of @openclaw/openclaw-secops, or an OpenClaw organization member with Maintain or Admin repository access.

  • Current SHA: 0672fed74110f67f5fba354aaef2e49444438ed3
  • Trusted actor: @steipete
  • Trusted role: pull request author; openclaw-secops

Security review is still recommended before merge when the dependency graph change is intentional.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 11:48 PM ET / September 5, 2026, 03:48 UTC.

ClawSweeper review

What this changes

The Anthropic plugin replaces the Agent SDK with direct communication to installed Claude Code, removes SDK packaging, and preserves executable invocation details through the shared runner.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: current main has not absorbed this maintainer-sponsored work, and no actionable introduced defect was found. The previously raised protocol-ownership decision is resolved in the discussion.

Priority: P2
Reviewed head: 0672fed74110f67f5fba354aaef2e49444438ed3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent, net-negative refactor with substantial recorded real-runtime proof and no actionable findings, bounded by the accepted native-protocol compatibility scope.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The captured evidence reports real authenticated Gateway turns and native Claude fixtures exercising the changed transport, including host denial, cancellation, reuse, resume, and fork; central production files match the refreshed proof revision. Artifact reopening was unavailable, and native Windows cancellation remains outside the recorded live coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured evidence reports real authenticated Gateway turns and native Claude fixtures exercising the changed transport, including host denial, cancellation, reuse, resume, and fork; central production files match the refreshed proof revision. Artifact reopening was unavailable, and native Windows cancellation remains outside the recorded live coverage.
Evidence reviewed 12 items Pinned introduction and checkout identity: The local checkout matches the supplied PR head. Its raw parents match the host record, and the pinned base-to-head diff contains the Anthropic transport work without dashboard changes. The supplied test merge is stale and was not used to infer removal of current-main behavior.
Current main still uses the SDK: The fetched main implementation imports Agent SDK types and calls its query transport. The supplied related merged PRs cover earlier SDK adoption and separate dashboard work; none implements this replacement. The latest-release tree also contains the SDK runtime path, although its historical blob was unavailable for full inspection.
Production entrypoint and dependency boundary: The Anthropic backend selects executeClaudeCli for local agent turns and identifies the installed Claude Code package as its runtime artifact. This establishes an affirmative Claude protocol dependency; it does not establish a Codex runtime dependency. Isolated completions, node placement, and manual compaction retain their existing execution routes.
Findings None None.
Security None None.

How this fits together

OpenClaw’s CLI runner prepares agent prompts, credentials, tool policy, and session ownership for the Anthropic plugin. The plugin exchanges structured messages with Claude Code and returns results while OpenClaw retains approval and lifecycle control.

flowchart TD
  A[Agent turn] --> B[Shared CLI runner]
  B --> C[Anthropic transport]
  C --> D[Installed Claude Code]
  D --> E[Native tool request]
  E --> F[Current turn and host policy]
  F --> C
  D --> G[Streamed results and session continuity]
Loading

Before merge

  • Resolve merge risk (P1) - Direct stdio makes the Anthropic plugin responsible for native protocol compatibility; Claude versions outside the exercised 2.1.243/2.1.261 boundary could fail initialization or permission handling. The maintainer explicitly accepted this scope.
  • Resolve merge risk (P1) - Native Windows Claude cancellation remains unexercised; the recorded coverage consists of portable subprocess tests and Windows CI.
  • Resolve merge risk (P1) - This worker could not independently reopen the linked live artifacts or inspect upstream SDK/native source because network access failed; the supplied proof remains valid evidence, with that verification limit disclosed.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +68, Tests -733, Docs +2, Config -4, Other -198. Total -865 across 45 files.

View PR surface stats
Area Files Added Removed Net
Source 14 806 738 +68
Tests 18 1057 1790 -733
Docs 7 35 33 +2
Config 2 0 4 -4
Generated 0 0 0 0
Other 4 3 201 -198
Total 45 1901 2766 -865

Review metrics

Metric Value Why it matters
Production versus test footprint Production/build/manifests net −36; tests/support net −733 With renames discounted, the replacement removes more owned code than it adds and replaces SDK-option mocks with subprocess coverage.
Public contract change 1 optional Plugin SDK field added; 0 config options or storage migrations argv0 preserves verified executable identity through the existing execution context without introducing another backend API.

Stored data model

Persistent data-model change detected: serialized state: scripts/lib/claude-agent-sdk-assets.mts, serialized state: src/agents/cli-runner/live-session-fingerprint.ts, unknown-data-model-change: scripts/lib/claude-agent-sdk-assets.mts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Retain the recorded compatibility decision (recommended)
    Proceed within the already accepted Claude-version boundary, retaining the documented Windows proof limit and plugin ownership of future protocol maintenance.

Technical review

Best possible solution:

Maintain one Anthropic-owned transport while preserving shared admission, approvals, credential isolation, and native session continuity within the accepted CLI compatibility boundary.

Do we have a high-confidence way to reproduce the issue?

Not applicable to the central refactor; subprocess regression scenarios and reported live runs cover the preserved behavior, but were not rerun during this read-only review.

Is this the best way to solve the issue?

Yes, within the accepted CLI boundary: the patch replaces the transport at its plugin owner and retains the shared lifecycle and policy machinery. Independent upstream-contract reinspection was unavailable here.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 185ca0df6328.

Labels

Label justifications:

  • P2: This is a substantive provider-transport simplification with no demonstrated urgent user-facing regression.
  • merge-risk: 🚨 compatibility: Replacing SDK protocol handling and extending the execution context makes native CLI compatibility an explicit plugin responsibility despite successful reported proof.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The captured evidence reports real authenticated Gateway turns and native Claude fixtures exercising the changed transport, including host denial, cancellation, reuse, resume, and fork; central production files match the refreshed proof revision. Artifact reopening was unavailable, and native Windows cancellation remains outside the recorded live coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured evidence reports real authenticated Gateway turns and native Claude fixtures exercising the changed transport, including host denial, cancellation, reuse, resume, and fork; central production files match the refreshed proof revision. Artifact reopening was unavailable, and native Windows cancellation remains outside the recorded live coverage.

Evidence

What I checked:

  • Pinned introduction and checkout identity: The local checkout matches the supplied PR head. Its raw parents match the host record, and the pinned base-to-head diff contains the Anthropic transport work without dashboard changes. The supplied test merge is stale and was not used to infer removal of current-main behavior. (0672fed74110)
  • Current main still uses the SDK: The fetched main implementation imports Agent SDK types and calls its query transport. The supplied related merged PRs cover earlier SDK adoption and separate dashboard work; none implements this replacement. The latest-release tree also contains the SDK runtime path, although its historical blob was unavailable for full inspection. (extensions/anthropic/agent-sdk.runtime.ts:3, 185ca0df6328)
  • Production entrypoint and dependency boundary: The Anthropic backend selects executeClaudeCli for local agent turns and identifies the installed Claude Code package as its runtime artifact. This establishes an affirmative Claude protocol dependency; it does not establish a Codex runtime dependency. Isolated completions, node placement, and manual compaction retain their existing execution routes. (extensions/anthropic/cli-backend.ts:261, 0672fed74110)
  • Permission authority reaches the final write: The runtime captures the admitted turn before awaiting permission handling, then returns a closure that rechecks that exact turn and cancellation. The transport invokes that closure synchronously immediately before writing the control response. Completed or revoked turns receive denial instead of a retained allow response. (extensions/anthropic/cli.runtime.ts:317, 0672fed74110)
  • Shared ownership and invocation contract: The shared runner forwards the verified script prefix and optional argv0. The live-session fingerprint includes argv0, while the registry remains a process-local Map with exact owner, handle, generation, and MCP-adoption checks. These changes do not alter a persisted data model. (src/agents/cli-runner/execute-process.ts:211, 0672fed74110)
  • Regression coverage inspected: Subprocess tests cover revoked approvals, late responses after a subsequent turn starts, stale input lifecycle events, cancellation, credential descriptor isolation, background results, and warm reuse. Shared-runner tests exercise real interpreter and symlink invocation. These tests were read, not executed during this read-only review. (extensions/anthropic/cli-runtime.test.ts:262, 0672fed74110)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Dallin Romney: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-05T00:12:02.728Z sha 72aae4e :: blocked before merge. :: none
  • reviewed 2026-09-05T01:53:24.541Z sha 92315c7 :: blocked before merge. :: none
  • reviewed 2026-09-05T02:47:40.201Z sha 11d251c :: blocked before merge. :: none
  • reviewed 2026-09-05T03:01:19.346Z sha ab2bd95 :: blocked before merge. :: none

@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

The post-adoption audit and requested live verification are complete on 92315c776065ba5b739ced71c089763f59229d34. Addressing the outstanding review notes:

  • Independent Claude contract inspection: Read the official Agent SDK 0.3.243 implementation and declarations plus native Claude Code 2.1.243's embedded protocol, independently of the OpenClaw wrapper. Verified initialize fields/acknowledgment ordering, hook callback and permission response shapes, input UUID lifecycle events, cancellation, resume/fork, and process exit behavior. SDK source SHA-256: d45b7f7db00d7ed670d2930bef1435603948ad20ed8434063b3601f76751510c; declarations: d25b9ae5937d97463d5077e7bcc9e64f6cecf7a508e59a5570e6dd062852c42a. No upstream implementation was copied. The audit found and repaired the noninteractive elicitation default (decline) and the shared plugin runner's dropped executable prefix/argv0. Before-fix subprocess and protocol tests failed for those exact reasons; all 112 focused tests now pass.
  • SDK-era fixes: Traced 112 relevant commits from SDK adoption in 12d0fd2 through removal, including questions, permissions, private context, environment/credential ownership, warm sessions, diagnostics, MCP, compaction, and recovery. The updated body records representative fixes and their retained owners. A plain historical revert would have lost these repairs; this replaces only the SDK-owned transport/build path and preserves the current shared owners.
  • Authenticated behavior: The full real Gateway CLI suite passed both API-key and native subscription authentication in Testbox workflow 33933664206: actual parent/child runs, child announcement after parent completion, resumed recall, image understanding, MCP discovery, and automation creation. API-key run: 102.8 seconds; final native subscription run: 96.7 seconds. The subscription run excluded API keys and its attested tree 89a808c75b3edce5eb011b4c9f89eb23edcfbcba exactly equals this PR head's Git tree. Native fixture proof additionally covers host denial, private context, cancellation, warm reuse, cold resume, and checkpoint fork.
  • Live-test correction: One subscription attempt failed an over-specific marker assertion despite a visible completion after the parent. Retained native transcripts proved the model truthfully summarized the child result without repeating the synthetic marker. The live prompt now explicitly requests that marker; both original transcript-order assertions remain, with diagnostics emitted before assertions. The full rerun passed. No production delivery workaround or timeout increase was introduced.
  • Data-model flag: scripts/lib/claude-agent-sdk-assets.mts copied SDK artifacts into build output. It owned no persistent user state, SQLite schema, or saved configuration. There is no data migration to implement. Native cold resume/fork proof covers the unchanged external CLI history format.
  • Maintainer decision and quality: Proceed with the single Anthropic-owned direct transport. Fresh independent Codex reviews found no actionable P0–P2 findings after the audit fixes and final test repair. Full build, changed-file checks, and package integrity/import-graph checks pass. The 10,040-entry tarball has zero Agent SDK paths/references and no root/bundled-Anthropic Agent SDK dependency. Production/build/manifests net −36 lines; test/support net −733. The optional Plugin SDK argv0 field preserves resolved executable identity; no config or database changes.

Windows native Claude cancellation has not been exercised on a Windows installation; portable subprocess coverage and current Windows CI cover the shared process boundary. This limitation is separate from the authenticated Linux and native macOS proof above. The separately installed ACPX adapter's upstream SDK dependency remains outside core distribution.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Sep 5, 2026
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Read the refreshed exact-head review. Proceeding with its recommended exercised CLI boundary: the Anthropic plugin owns future native-protocol maintenance, with direct SDK/native source inspection plus Claude 2.1.243/2.1.261 and authenticated Gateway proof supporting this replacement. This is not a claim of compatibility with arbitrary future CLI versions. Native Windows Claude cancellation remains an explicitly recorded coverage limit; both required Windows CI jobs passed and the existing custom process/credential owner is retained.

The added fingerprint flag is also not a persisted-data migration. live-session-fingerprint.ts:71–102 computes a hash for the process-local liveSessions Map in cli-live-session-registry.ts:36; adding argv0 prevents reusing the wrong live executable invocation. Undefined argv0 leaves the serialized hash input unchanged. Native session IDs/history and saved configuration are untouched, and cold resume/checkpoint fork were exercised. The deleted SDK asset copier only produced build output. No database/store migration is applicable to either flagged file.

Apply the upstream fixture correction from #138769 so chat startup and dashboard navigation resolve the same session.
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Sep 5, 2026
zijunl pushed a commit to zijunl/openclaw that referenced this pull request Sep 18, 2026
…mment

Upstream replaced the Agent SDK with a direct CLI transport (openclaw#138707), so
the comment's reference to how "the Agent SDK types this field" no longer
names anything in the tree. The dual-spelling read is still required --
the streamed record and the on-disk transcript disagree -- so only the
attribution changes, not the behavior.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BjsHL4YEa67pAiPpSY3svm
obviyus added a commit that referenced this pull request Sep 19, 2026
…8504)

Closes #138424

## What Problem This Solves

Fixes ordinary `claude-cli` agent turns failing to launch on Windows when an npm installation exposes an extensionless shell shim or a `.cmd` launcher.

## User Impact

Windows users can complete Claude CLI turns through their npm-installed command without replacing launcher files. Native executables and non-Windows command handling are preserved. No configuration, authentication, or identity-verification policy changes are required.

## Why This Change Was Made

The earlier implementation targeted the Agent SDK adapter removed by #138707. This revision preserves the contributor's commits while applying the repair to the current direct CLI transport. Its launch boundary now uses the existing shared Windows resolver and carries the resolved program together with its leading arguments. Relative commands and PATH entries are resolved against the child working directory; existing identity callers retain their previous behavior.

## Evidence

The supported `agent --local --session-id <fresh> --message "Reply with exactly PONG" --json --timeout 60` path was exercised on real GitHub-hosted Windows 2025 with Node 24.20.0, isolated OpenClaw state, an npm-style prefix, and a controlled external CLI speaking the Anthropic transport protocol. No auth-binding callback or exact-version policy normalized the command first; no platform mock or live provider credential was used.

| Actual Windows launch | Unchanged main production | Candidate production |
| --- | --- | --- |
| Extensionless shim plus npm `.cmd` | `write EPIPE`, no run child or reply | Run child launched; final reply `PONG` |
| npm `.cmd` resolving to Node plus script | `spawn EINVAL`, no run child or reply | Node and script argument preserved; final reply `PONG` |
| Native `.exe` control | Final reply `PONG` | Final reply `PONG` |

- [Baseline run](https://github.com/openclaw/openclaw/actions/runs/35431111855): production from `7a932d979442`, proof ref `381771f2ca50`.
- [Candidate run](https://github.com/openclaw/openclaw/actions/runs/35433705895): `e9f91d13d7e3`, with the same three fixtures and order. All three product cases passed. Publication head `7f7212ac7e6b` changes only the fixture's filesystem-error typing, not production or executable fixture bytes.
- A macOS npm-shim control also completed with `PONG`. Focused local checks passed 75 tests, with the native-only case skipped; scoped lint passed.
- The candidate Windows workflow is **not wholly green**: three later executable-identity tests failed with `expected undefined to be package-tree`. The baseline stopped before those cases, so this is not claimed as reproduced base-red. Their two-argument resolver calls retain exactly the previous behavior, run outside the changed execution owner, and execute in separate test processes. The identity guards and assertions remain intact.

This proves the real OpenClaw command, Windows process launch, direct transport, and final reply boundary with a controlled CLI peer. It does not claim live Anthropic authentication/model traffic, pnpm launcher coverage, or Windows resume-session coverage. Ordinary exact-head PR CI remains the wider validation gate.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
…nclaw#138504)

Closes openclaw#138424

## What Problem This Solves

Fixes ordinary `claude-cli` agent turns failing to launch on Windows when an npm installation exposes an extensionless shell shim or a `.cmd` launcher.

## User Impact

Windows users can complete Claude CLI turns through their npm-installed command without replacing launcher files. Native executables and non-Windows command handling are preserved. No configuration, authentication, or identity-verification policy changes are required.

## Why This Change Was Made

The earlier implementation targeted the Agent SDK adapter removed by openclaw#138707. This revision preserves the contributor's commits while applying the repair to the current direct CLI transport. Its launch boundary now uses the existing shared Windows resolver and carries the resolved program together with its leading arguments. Relative commands and PATH entries are resolved against the child working directory; existing identity callers retain their previous behavior.

## Evidence

The supported `agent --local --session-id <fresh> --message "Reply with exactly PONG" --json --timeout 60` path was exercised on real GitHub-hosted Windows 2025 with Node 24.20.0, isolated OpenClaw state, an npm-style prefix, and a controlled external CLI speaking the Anthropic transport protocol. No auth-binding callback or exact-version policy normalized the command first; no platform mock or live provider credential was used.

| Actual Windows launch | Unchanged main production | Candidate production |
| --- | --- | --- |
| Extensionless shim plus npm `.cmd` | `write EPIPE`, no run child or reply | Run child launched; final reply `PONG` |
| npm `.cmd` resolving to Node plus script | `spawn EINVAL`, no run child or reply | Node and script argument preserved; final reply `PONG` |
| Native `.exe` control | Final reply `PONG` | Final reply `PONG` |

- [Baseline run](https://github.com/openclaw/openclaw/actions/runs/35431111855): production from `cc262448fa0c`, proof ref `381771f2ca50`.
- [Candidate run](https://github.com/openclaw/openclaw/actions/runs/35433705895): `e9f91d13d7e3`, with the same three fixtures and order. All three product cases passed. Publication head `7f7212ac7e6b` changes only the fixture's filesystem-error typing, not production or executable fixture bytes.
- A macOS npm-shim control also completed with `PONG`. Focused local checks passed 75 tests, with the native-only case skipped; scoped lint passed.
- The candidate Windows workflow is **not wholly green**: three later executable-identity tests failed with `expected undefined to be package-tree`. The baseline stopped before those cases, so this is not claimed as reproduced base-red. Their two-argument resolver calls retain exactly the previous behavior, run outside the changed execution owner, and execute in separate test processes. The identity guards and assertions remain intact.

This proves the real OpenClaw command, Windows process launch, direct transport, and final reply boundary with a controlled CLI peer. It does not claim live Anthropic authentication/model traffic, pnpm launcher coverage, or Windows resume-session coverage. Ordinary exact-head PR CI remains the wider validation gate.

Co-authored-by: Ayaan Zaidi <[email protected]>
zijunl pushed a commit to zijunl/openclaw that referenced this pull request Oct 6, 2026
…ompt

Narrow openclaw#137134 onto the current direct transport per the ClawSweeper review
recommendation (preserve existing defaults; consolidate explicit isolation
support on the current Anthropic transport).

- Drops the retired Agent SDK implementation: the SDK adapter this branch
  patched was removed by openclaw#138707, so no SDK code is touched anymore.
- The memory-isolation half is covered by openclaw#166073
  (claudeCli.excludeNativeMemory, opt-in, default off); this branch no longer
  implements it.
- Reimplements the prompt-ownership half as an opt-in on the direct
  transport: plugins.entries.anthropic.config.claudeCli.replaceNativePrompt
  (default false). When enabled, normalizeClaudeBackendConfig swaps the
  backend's system-prompt file arg from --append-system-prompt-file to
  --system-prompt-file, so OpenClaw's prompt replaces Claude Code's native
  prompt instead of appending to it. The --exclude-dynamic-system-prompt-
  sections trim flag is skipped when replacing, since there are no native
  sections left to trim.
- Defaults are unchanged: without the setting, runs keep the native prompt
  with OpenClaw's instructions appended.

Docs: setting documented in docs/gateway/cli-backends.md; schema and UI
hints added to the Anthropic plugin manifest; generated config baseline
regenerated.

Tests: three new cases in extensions/anthropic/cli-shared.test.ts covering
the default append behavior, the opt-in swap, and the trim-flag skip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: macos App: macos dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation extensions: anthropic gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security Security documentation size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant