You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 12d0fd2
Browse filesBrowse the repository at this point in the historyBrowse files
refactor(anthropic): replace handwritten Claude sessions with Agent SDK (#128131)
* refactor(anthropic): explore official Claude Agent SDK runtime
* refactor(anthropic): replace handwritten Claude sessions with SDK
* refactor(anthropic): collapse SDK live-session ownership
* refactor(anthropic): simplify SDK ownership and preserve live skills
* fix(anthropic): fence cancelled SDK runs before process startup
* fix(anthropic): harden SDK approvals, lifecycle, and packaging
* refactor(anthropic): own SDK process trees and streamline runtime
* fix(anthropic): repair rebased packaging and legacy test fixtures
Copy file name to clipboardExpand all lines: docs/providers/anthropic.md
+37-33Lines changed: 37 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ title: "Anthropic"
9
9
Anthropic builds the **Claude** model family. OpenClaw supports two auth routes:
10
10
11
11
-**API key** - direct Anthropic API access with usage-based billing (`anthropic/*` models)
12
-
-**Claude CLI** - reuse an existing Claude Code login on the same host
12
+
-**Claude CLI** - reuse an existing Claude Code login on the same host through Anthropic's official Agent SDK
13
13
14
14
## Usage and cost tracking
15
15
@@ -22,18 +22,11 @@ OpenClaw detects the available Anthropic credential and selects the matching usa
22
22
Admin API cost history comes from Anthropic's [Usage and Cost API](https://platform.claude.com/docs/en/manage-claude/usage-cost-api). It is actual provider billing, separate from OpenClaw's session-derived estimated cost.
23
23
24
24
<Warning>
25
-
OpenClaw's Claude CLI backend runs the installed Claude Code CLI in
26
-
non-interactive print mode (`claude -p`). Anthropic's current Claude Code docs
27
-
describe that mode as Agent SDK/programmatic usage. Anthropic's June 15, 2026
28
-
support update paused the announced separate Agent SDK billing change: Claude
29
-
Agent SDK, `claude -p`, and third-party app usage still draw from a signed-in
30
-
subscription's usage limits, and the previously announced monthly Agent SDK
31
-
credit is not available while Anthropic revises that plan.
32
-
33
-
Interactive Claude Code still draws from the signed-in Claude plan's limits.
34
-
API key auth is direct pay-as-you-go billing and does not depend on that plan.
35
-
For long-lived gateway hosts, shared automation, and predictable production
36
-
spend, use an Anthropic API key.
25
+
Claude Code owns its existing login and subscription; OpenClaw does not extract
26
+
that login or synthesize Anthropic API requests. Agent SDK and `claude -p`
27
+
usage currently draw from the signed-in subscription's limits. API-key auth
28
+
uses separate pay-as-you-go billing and is preferable for shared automation or
29
+
predictable production spend.
37
30
38
31
Anthropic's current support articles can change this behavior without an
39
32
OpenClaw release:
@@ -91,18 +84,15 @@ OpenClaw release:
91
84
92
85
<Steps>
93
86
<Step title="Ensure Claude CLI is installed and logged in">
94
-
OpenClaw's streamed session correlation requires the
95
-
`msg_lifecycle_v1` capability. Claude Code 2.1.206 is the first
96
-
published build known to advertise it. Verify the installed version:
87
+
OpenClaw runs the installed Claude Code executable through Anthropic's
88
+
official Agent SDK. Verify that Claude Code is installed and up to date:
97
89
98
90
```bash
99
91
claude --version
100
92
```
101
93
102
-
A lower-version compatible backport or wrapper remains selectable;
103
-
OpenClaw verifies the capability at runtime. If the runtime rejects the
104
-
installed build, update Claude Code and restart OpenClaw so the gateway
105
-
launches the new binary:
94
+
If the installed build is incompatible, update Claude Code and restart
95
+
OpenClaw so the gateway launches the new binary:
106
96
107
97
```bash
108
98
claude update
@@ -114,7 +104,18 @@ OpenClaw release:
114
104
# choose: Claude CLI
115
105
```
116
106
117
-
OpenClaw detects and reuses the existing Claude CLI credentials.
107
+
OpenClaw detects the existing Claude CLI login. Normal agent turns use
108
+
the official Agent SDK with the installed, authenticated Claude Code
109
+
executable, including native-tool turns whose approvals remain under
110
+
OpenClaw control. Imported native OAuth profiles reuse the verified
111
+
Claude Code login; explicitly selected API-key or token credentials
112
+
still use protected file-descriptor forwarding. Isolated side-question
113
+
completions and paired-node execution retain the supervised CLI path.
114
+
115
+
Consecutive agent turns reuse the same warm Agent SDK query and Claude
116
+
Code subprocess when their authenticated session and execution policy
117
+
match. If that process ends or the gateway restarts, the next turn
118
+
resumes the persisted Claude Code session.
118
119
</Step>
119
120
<Step title="Verify the model is available">
120
121
```bash
@@ -125,8 +126,6 @@ OpenClaw release:
125
126
126
127
<Note>
127
128
Setup and runtime details for the Claude CLI backend are in [CLI Backends](/gateway/cli-backends).
128
-
`openclaw doctor` also reports advisory guidance for an installed Claude
129
-
Code version below the first-known compatible release.
130
129
</Note>
131
130
132
131
<Warning>
@@ -177,8 +176,8 @@ OpenClaw release:
177
176
178
177
### Billing and `claude -p`
179
178
180
-
OpenClaw uses Claude Code's non-interactive `claude -p` path for Claude CLI
181
-
runs. Anthropic currently treats that path as Agent SDK/programmatic usage:
179
+
Anthropic currently treats Agent SDK and non-interactive CLI invocations as
180
+
programmatic usage:
182
181
183
182
- Anthropic's June 15, 2026 support update paused the previously announced
184
183
separate Agent SDK credit plan.
@@ -189,14 +188,6 @@ OpenClaw release:
189
188
- Console/API-key logins use pay-as-you-go API billing and do not receive
0 commit comments