fix: align claude-cli prompt hooks (#70625) · openclaw/openclaw@3e956a4
mbelinky
·
2026-04-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,14 @@
|
2 | 2 | |
3 | 3 | Docs: https://docs.openclaw.ai |
4 | 4 | |
| 5 | +## Unreleased |
| 6 | + |
| 7 | +### Changes |
| 8 | + |
| 9 | +### Fixes |
| 10 | + |
| 11 | +- CLI/Claude: run the same prompt-build hooks and trigger/channel context on `claude-cli` turns as on direct embedded runs, keeping Claude Code sessions aligned with OpenClaw workspace identity, routing, and hook-driven prompt mutations. (#70625) Thanks @mbelinky. |
| 12 | + |
5 | 13 | ## 2026.4.22 |
6 | 14 | |
7 | 15 | ### Changes |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -71,6 +71,24 @@ For long-lived gateway hosts, an Anthropic API key is still the most predictable
|
71 | 71 | setup. If you want to reuse an existing Claude login on the same host, use the |
72 | 72 | Anthropic Claude CLI path in onboarding/configure. |
73 | 73 | |
| 74 | +Recommended host setup for Claude CLI reuse: |
| 75 | + |
| 76 | +```bash |
| 77 | +# Run on the gateway host |
| 78 | +claude auth login |
| 79 | +claude auth status --text |
| 80 | +openclaw models auth login --provider anthropic --method cli --set-default |
| 81 | +``` |
| 82 | + |
| 83 | +This is a two-step setup: |
| 84 | + |
| 85 | +1. Log Claude Code itself into Anthropic on the gateway host. |
| 86 | +2. Tell OpenClaw to switch Anthropic model selection to the local `claude-cli` |
| 87 | + backend and store the matching OpenClaw auth profile. |
| 88 | + |
| 89 | +If `claude` is not on `PATH`, either install Claude Code first or set |
| 90 | +`agents.defaults.cliBackends.claude-cli.command` to the real binary path. |
| 91 | + |
74 | 92 | Manual token entry (any provider; writes `auth-profiles.json` + updates config): |
75 | 93 | |
76 | 94 | ```bash |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -169,6 +169,18 @@ resolver sees the same filtered set that OpenClaw would otherwise advertise in
|
169 | 169 | the prompt. Skill env/API key overrides are still applied by OpenClaw to the |
170 | 170 | child process environment for the run. |
171 | 171 | |
| 172 | +Before OpenClaw can use the bundled `claude-cli` backend, Claude Code itself |
| 173 | +must already be logged in on the same host: |
| 174 | + |
| 175 | +```bash |
| 176 | +claude auth login |
| 177 | +claude auth status --text |
| 178 | +openclaw models auth login --provider anthropic --method cli --set-default |
| 179 | +``` |
| 180 | + |
| 181 | +Use `agents.defaults.cliBackends.claude-cli.command` only when the `claude` |
| 182 | +binary is not already on `PATH`. |
| 183 | + |
172 | 184 | ## Sessions |
173 | 185 | |
174 | 186 | - If the CLI supports sessions, set `sessionArg` (e.g. `--session-id`) or |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -431,6 +431,22 @@ describe("runCliAgent spawn path", () => {
|
431 | 431 | expect(params.senderIsOwner).toBe(false); |
432 | 432 | }); |
433 | 433 | |
| 434 | + it("forwards channel context through the compat wrapper", () => { |
| 435 | + const params = buildRunClaudeCliAgentParams({ |
| 436 | + sessionId: "openclaw-session", |
| 437 | + sessionFile: "/tmp/session.jsonl", |
| 438 | + workspaceDir: "/tmp", |
| 439 | + prompt: "hi", |
| 440 | + timeoutMs: 1_000, |
| 441 | + runId: "run-claude-channel-wrapper", |
| 442 | + messageChannel: "telegram", |
| 443 | + messageProvider: "acp", |
| 444 | + }); |
| 445 | + |
| 446 | + expect(params.messageChannel).toBe("telegram"); |
| 447 | + expect(params.messageProvider).toBe("acp"); |
| 448 | + }); |
| 449 | + |
434 | 450 | it("forwards static extra system prompt through the compat wrapper", () => { |
435 | 451 | const params = buildRunClaudeCliAgentParams({ |
436 | 452 | sessionId: "openclaw-session", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -140,6 +140,7 @@ export function buildRunClaudeCliAgentParams(params: RunClaudeCliAgentParams): R
|
140 | 140 | sessionId: params.sessionId, |
141 | 141 | sessionKey: params.sessionKey, |
142 | 142 | agentId: params.agentId, |
| 143 | + trigger: params.trigger, |
143 | 144 | sessionFile: params.sessionFile, |
144 | 145 | workspaceDir: params.workspaceDir, |
145 | 146 | config: params.config, |
@@ -156,6 +157,8 @@ export function buildRunClaudeCliAgentParams(params: RunClaudeCliAgentParams): R
|
156 | 157 | // Ignore it here so the compatibility wrapper does not accidentally resume |
157 | 158 | // an incompatible Claude session on the generic runner path. |
158 | 159 | images: params.images, |
| 160 | + messageChannel: params.messageChannel, |
| 161 | + messageProvider: params.messageProvider, |
159 | 162 | senderIsOwner: params.senderIsOwner, |
160 | 163 | }; |
161 | 164 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。