Skip to content

Commit 1c40abd

Browse files
authored
fix: preserve ACP model switches and reply completion (#132040)
* fix: keep ACP thinking aligned after model switches Carry published ACPX accepted control snapshots through the plugin boundary and reconcile selected thinking in the session owner. Preserve selectable pending thinking on automatic replay, persist accepted changes before later failures, and show effective thinking in command replies. Keep shipped optional-control replay and third-party void backends unchanged. * fix: give ACP replies one completion owner * fix: tighten ACP completion type boundaries * fix(ui): defer native chrome and recover rendered lazy surfaces * refactor(ui): separate native startup recovery tests * fix: preserve explicit reply completion ownership * test: consolidate ACP completion regression fixtures * chore(ui): refresh boot manifest after main integration * test: distinguish inbound ACP reply options * test(ui): target retargeted queue clicks deterministically * fix(ci): split UI test type graphs within the root budget
1 parent cc27ac4 commit 1c40abd

63 files changed

Lines changed: 1737 additions & 414 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/ci.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ Hybrid is the normal degraded-capacity mode. If Blacksmith is down: rerun the fa
354354
gh variable set OPENCLAW_CI_RUNNER_BACKEND --repo openclaw/openclaw --body github
355355
```
356356

357-
Hosted paths use the same setup exercised by manual dispatches and fork pull requests. Fork PRs are forced into the logical `github` planner profile even when repository variables are unavailable, so core lint and test types retain their hosted stripes instead of falling back to the oversized all-in-one jobs. Frozen targets opt into this event-aware profile through `hosted-runner-profile-contract-v1`; targets without the marker retain their historical workload shape. Blacksmith-only Docker and sticky-disk steps are skipped, dependency setup uses the ordinary Actions pnpm-store cache, and low-memory Android builds use separate Gradle processes. Hybrid attempt-1 Node and plateau lanes deliberately keep this backend-neutral Actions-cache profile when they run on Blacksmith because preflight remains hosted. The exact workspace dependency cache intentionally stays off when preflight is hosted: GitHub can roll the runner image and Node patch between preflight and fanout in one workflow, while the safe exact key then misses; the ordinary store archive is only slightly smaller and pnpm's measured relink is already single-digit seconds. The Node toolchain itself is also cached through that API: Blacksmith's image tracks an older runner-images snapshot whose toolcache Node patches (measured 2026-08-16: 20.20.0, 22.22.0, 24.13.0) sit just under this repo's `engines` floor, so every job otherwise re-downloads Node from nodejs.org. Restores are prefix-keyed and saves carry the resolved patch, because an exact-key hit suppresses the post-job save and would pin the first payload forever once the floor advanced past it. A restored payload below the floor is rejected, pruned, and replaced. Vitest transform and Node compile caches still use the upstream Actions cache API, which Blacksmith proxies; their Linux-only `runner.os != 'Windows'` conditions do not exclude Blacksmith labels, and the planner still elects one semantic transform-cache writer. Core oxlint splits into five deterministic hosted stripes, with extension/scripts lint and optional UI and format checks in the existing `check-lint` row. The 14 serial core test-type graphs likewise split into five `check-test-types-core-*` stripes (two overlapped graphs per stripe), leaving the extensions/root/scripts type tail in the `check-test-types` row; targets without stripe support keep the whole lane in that row.
357+
Hosted paths use the same setup exercised by manual dispatches and fork pull requests. Fork PRs are forced into the logical `github` planner profile even when repository variables are unavailable, so core lint and test types retain their hosted stripes instead of falling back to the oversized all-in-one jobs. Frozen targets opt into this event-aware profile through `hosted-runner-profile-contract-v1`; targets without the marker retain their historical workload shape. Blacksmith-only Docker and sticky-disk steps are skipped, dependency setup uses the ordinary Actions pnpm-store cache, and low-memory Android builds use separate Gradle processes. Hybrid attempt-1 Node and plateau lanes deliberately keep this backend-neutral Actions-cache profile when they run on Blacksmith because preflight remains hosted. The exact workspace dependency cache intentionally stays off when preflight is hosted: GitHub can roll the runner image and Node patch between preflight and fanout in one workflow, while the safe exact key then misses; the ordinary store archive is only slightly smaller and pnpm's measured relink is already single-digit seconds. The Node toolchain itself is also cached through that API: Blacksmith's image tracks an older runner-images snapshot whose toolcache Node patches (measured 2026-08-16: 20.20.0, 22.22.0, 24.13.0) sit just under this repo's `engines` floor, so every job otherwise re-downloads Node from nodejs.org. Restores are prefix-keyed and saves carry the resolved patch, because an exact-key hit suppresses the post-job save and would pin the first payload forever once the floor advanced past it. A restored payload below the floor is rejected, pruned, and replaced. Vitest transform and Node compile caches still use the upstream Actions cache API, which Blacksmith proxies; their Linux-only `runner.os != 'Windows'` conditions do not exclude Blacksmith labels, and the planner still elects one semantic transform-cache writer. Core oxlint splits into five deterministic hosted stripes, with extension/scripts lint and optional UI and format checks in the existing `check-lint` row. The 15 serial core test-type graphs, with UI pages and E2E tests in separate graphs to preserve the 720-root cap, likewise split into five `check-test-types-core-*` stripes (two overlapped graphs per stripe), leaving the extensions/root/scripts type tail in the `check-test-types` row; targets without stripe support keep the whole lane in that row.
358358

359359
The compact Node planner keeps separate Blacksmith and standard 4-core hosted timing ownership. The `github` profile targets 90/95 seconds of serial group work for the hosted large/small source runner classes and applies a 1.6x median scaling fallback only to unmeasured groups. Hybrid keeps the expanded topology and hosted-derived splitting for groups above the unchanged 150-second ceiling, so hosted retries do not inherit an indivisible hosted wall pole. Its attempt-1 packing applies the existing 0.87 scale to Blacksmith estimates, using committed measurements before the cold-start hints. Refits can change the number and composition of compact jobs without changing runner policy. Direct sampled hints cover the doctor and cron-service outliers, while a 140-second floor and singleton bin protect the observed `agentic-gateway-core-3` tail. During rebalance, native hybrid groups use scaled Blacksmith stripe hints; only synthesized hosted stripes retain their divided parent weight. Failed and timeout-and-retry samples are excluded from refreshes. Whole-config groups with registered file listers (agent support, gateway methods, runtime config, isolated unit fast) split into file-weighted hosted stripes. The hosted agent-chat split also carries direct successful-run hints for its two longest files so they cannot land in the same stripe. The subprocess-heavy tooling family uses seven balanced stripes projecting to roughly 115 hosted seconds per stripe.
360360

‎docs/plugins/hooks.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,25 @@ message context and a host dispatcher, and a handled result reports
10201020
`queuedFinal` and delivery `counts`. Use `before_agent_reply` for a simple
10211021
synthetic reply, and the sending hooks below to transform outgoing payloads.
10221022

1023+
Runtime takeovers should forward `ctx.onAgentRunStart` and
1024+
`ctx.userTurnTranscriptRecorder` to their runtime helper. The ACP dispatch
1025+
helper forwards both automatically. Share the recorder so the runtime and
1026+
Gateway do not append the same user turn independently; mark runtime
1027+
persistence only after a successful transcript write.
1028+
1029+
The optional third `onAgentRunStart` argument can offer
1030+
`completionSource: "reply-dispatch"` with a `getResult()` callback. The host must
1031+
return `"reply-dispatch"` synchronously to accept completion ownership; observers
1032+
and other callback results leave lifecycle completion unchanged. Wrappers must
1033+
forward every callback argument and its return value. After dispatch settles,
1034+
`getResult()` supplies the canonical `terminalOutcome` and, when an
1035+
assistant write succeeded, its `assistantTranscript` receipt (target, message
1036+
ID, idempotency key, and optional projection anchor). The host then emits one
1037+
chat completion from the delivered, post-hook payloads while retaining runtime
1038+
lifecycle events. A receipt prevents a duplicate append; it does not authorize
1039+
writes to a replaced session. Omit this declaration for runtimes whose event
1040+
stream already owns chat completion.
1041+
10231042
Use `eligibleDispatchKinds: ["acp"]` for an ACP-only dispatcher. The host
10241043
classifies the resolved target, including conversation bindings, and passes
10251044
`ctx.dispatchKind` as `acp` or `agent`. Stored ACP metadata and ACP session keys

‎docs/plugins/sdk-runtime.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ snapshots; OpenClaw owns all persistence and lifecycle coordination.
263263

264264
Before advertising an ACP-backed action, use `resolveAcpSessionAvailability(...)` from `openclaw/plugin-sdk/acp-runtime`. It applies the canonical enablement, dispatch, allowed-agent, registered-backend, and backend-health checks; recheck it immediately before creating the session.
265265

266+
ACP backends can return `AcpRuntimeConfigOptionResult` from `setConfigOption(...)`: a complete `configOptions` array of `{ id, category?, currentValue, options? }`, where `currentValue` is a string or boolean. Select `options` contain `{ value }` entries or groups of `{ options: [{ value }] }`. OpenClaw reconciles an already-selected thinking override from the accepted `thought_level` category or a recognized thinking key. Automatic model replay preserves a pending thinking value only when it is still current or selectable; explicit controls always use the accepted value. An empty array removes that override; omitted or null `category` is allowed, and backend defaults are not pinned. Existing third-party backends returning `void` retain requested-value persistence. Return the snapshot after backend persistence succeeds; reject failed writes.
267+
266268
Creation holds the session lifecycle mutation fence through `afterCreate`, so new work waits for plugin-owned initialization to finish and pre-existing admitted work makes creation fail. The callback receives a clone of the created state. If it returns a patch, that patch may contain only `pluginExtensions`, and its value is the complete final `pluginExtensions` field. A callback or final-persistence failure rolls back the unchanged new row and transcript; guarded rollback preserves a row changed or claimed concurrently. `recoverMatchingInitialEntry: true` is only for retrying interrupted initialization when the persisted trusted fields match exactly, and recovery requires `afterCreate` to return a final patch.
267269

268270
Use `runWithWorkAdmission(...)` when a plugin starts work on a persisted session. The callback rejects archived or concurrently replaced sessions, keeps archive/reset/delete mutations coordinated through completion, and receives an `AbortSignal` that must be forwarded to the agent run. A harness may explicitly name trusted execution delegates through its experimental `delegatedExecutionPluginIds` registration field. Delegates can admit and run only an exact existing model-locked session; all session mutations remain restricted to the harness owner. See [Agent harness plugins](/plugins/sdk-agent-harness#delegated-execution).

‎docs/tools/acp-agents.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,12 @@ does not accept a target token.
839839
| `/acp set <key> <value>` | generic | `key=cwd` uses the cwd override path. |
840840
| `/acp reset-options` | clears all runtime overrides | - |
841841

842+
When a backend returns its accepted controls, OpenClaw keeps an already-selected
843+
thinking level in sync with that response. A model switch may lower the level or
844+
remove thinking support; subsequent turns and reconnects use the accepted
845+
selection instead of replaying the old level. Backend defaults do not become new
846+
session overrides, and the model reference keeps its OpenClaw provider prefix.
847+
842848
## acpx harness, plugin setup, and permissions
843849

844850
For acpx harness configuration (Claude Code / Codex / Gemini CLI aliases),

‎extensions/acpx/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": {
1111
"@agentclientprotocol/claude-agent-acp": "0.70.0",
1212
"@agentclientprotocol/codex-acp": "1.6.0",
13-
"acpx": "0.13.1",
13+
"acpx": "0.13.2",
1414
"smol-toml": "1.8.0",
1515
"zod": "4.4.3"
1616
},

‎extensions/acpx/runtime-api.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export {
1313
export type {
1414
AcpRuntime,
1515
AcpRuntimeCapabilities,
16+
AcpRuntimeConfigOptionResult,
1617
AcpRuntimeDoctorReport,
1718
AcpRuntimeEnsureInput,
1819
AcpRuntimeEvent,

‎extensions/acpx/src/runtime-proxy.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ describe("createLazyAcpRuntimeProxy", () => {
4545
promptStarted.promise,
4646
);
4747
const proxy = createLazyAcpRuntimeProxy(async () => runtime);
48+
const accepted = { configOptions: [{ id: "effort", currentValue: "medium" }] };
49+
runtime.setConfigOption = vi.fn(async () => accepted);
50+
await expect(proxy.setConfigOption({ handle, key: "effort", value: "high" })).resolves.toBe(
51+
accepted,
52+
);
4853

4954
await expect(proxy.doctor()).resolves.toEqual({
5055
ok: false,

‎extensions/acpx/src/runtime-proxy.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export function createLazyAcpRuntimeProxy(
7979
await (await resolveRuntime()).setMode(input);
8080
},
8181
async setConfigOption(input) {
82-
await (await resolveRuntime()).setConfigOption(input);
82+
return await (await resolveRuntime()).setConfigOption(input);
8383
},
8484
async doctor() {
8585
return await (await resolveRuntime()).doctor();

‎extensions/acpx/src/runtime.test.ts‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,19 +1634,21 @@ describe("AcpxRuntime fresh reset wrapper", () => {
16341634
save: vi.fn(async () => {}),
16351635
};
16361636
const { runtime, delegate } = makeRuntime(baseStore);
1637-
const setConfigOption = vi.spyOn(delegate, "setConfigOption").mockResolvedValue(undefined);
1637+
const accepted = { configOptions: [{ id: "reasoning_effort", currentValue: "medium" }] };
1638+
const setConfigOption = vi.spyOn(delegate, "setConfigOption").mockResolvedValue(accepted);
16381639
const handle: Parameters<NonNullable<AcpRuntime["setConfigOption"]>>[0]["handle"] = {
16391640
sessionKey: "agent:codex:acp:test",
16401641
backend: "acpx",
16411642
runtimeSessionName: "agent:codex:acp:test",
16421643
acpxRecordId: "agent:codex:acp:test",
16431644
};
16441645

1645-
await runtime.setConfigOption({
1646+
const result = await runtime.setConfigOption({
16461647
handle,
16471648
key: "model",
16481649
value,
16491650
});
1651+
expect(result).toBe(accepted);
16501652

16511653
expect(setConfigOption).toHaveBeenCalledOnce();
16521654
expect(setConfigOption).toHaveBeenCalledWith({
@@ -1694,19 +1696,26 @@ describe("AcpxRuntime fresh reset wrapper", () => {
16941696
save: vi.fn(async () => {}),
16951697
};
16961698
const { runtime, delegate } = makeRuntime(baseStore);
1697-
const setConfigOption = vi.spyOn(delegate, "setConfigOption").mockResolvedValue(undefined);
1699+
const accepted = { configOptions: [{ id: "reasoning_effort", currentValue: "high" }] };
1700+
const setConfigOption = vi
1701+
.spyOn(delegate, "setConfigOption")
1702+
.mockResolvedValueOnce({
1703+
configOptions: [{ id: "reasoning_effort", currentValue: "medium" }],
1704+
})
1705+
.mockResolvedValueOnce(accepted);
16981706
const handle: Parameters<NonNullable<AcpRuntime["setConfigOption"]>>[0]["handle"] = {
16991707
sessionKey: "agent:codex:acp:test",
17001708
backend: "acpx",
17011709
runtimeSessionName: "agent:codex:acp:test",
17021710
acpxRecordId: "agent:codex:acp:test",
17031711
};
17041712

1705-
await runtime.setConfigOption({
1713+
const result = await runtime.setConfigOption({
17061714
handle,
17071715
key: "model",
17081716
value: "openai/gpt-5.4/high",
17091717
});
1718+
expect(result).toBe(accepted);
17101719

17111720
expect(setConfigOption).toHaveBeenNthCalledWith(1, {
17121721
handle,
@@ -1786,7 +1795,10 @@ describe("AcpxRuntime fresh reset wrapper", () => {
17861795
save: vi.fn(async () => {}),
17871796
};
17881797
const { runtime, delegate } = makeRuntime(baseStore);
1789-
const setConfigOption = vi.spyOn(delegate, "setConfigOption").mockResolvedValue(undefined);
1798+
const accepted = {
1799+
configOptions: [{ id: "reasoning_effort", currentValue: expected ?? "medium" }],
1800+
};
1801+
const setConfigOption = vi.spyOn(delegate, "setConfigOption").mockResolvedValue(accepted);
17901802
const handle: Parameters<NonNullable<AcpRuntime["setConfigOption"]>>[0]["handle"] = {
17911803
sessionKey: "agent:codex:acp:test",
17921804
backend: "acpx",
@@ -1807,7 +1819,7 @@ describe("AcpxRuntime fresh reset wrapper", () => {
18071819
return;
18081820
}
18091821

1810-
await update;
1822+
await expect(update).resolves.toBe(accepted);
18111823
expect(setConfigOption).toHaveBeenCalledWith({
18121824
handle,
18131825
key: "reasoning_effort",
@@ -1924,19 +1936,21 @@ describe("AcpxRuntime fresh reset wrapper", () => {
19241936
save: vi.fn(async () => {}),
19251937
};
19261938
const { runtime, delegate } = makeRuntime(baseStore);
1927-
const setConfigOption = vi.spyOn(delegate, "setConfigOption").mockResolvedValue(undefined);
1939+
const accepted = { configOptions: [{ id: "effort", currentValue: "low" }] };
1940+
const setConfigOption = vi.spyOn(delegate, "setConfigOption").mockResolvedValue(accepted);
19281941
const handle: Parameters<NonNullable<AcpRuntime["setConfigOption"]>>[0]["handle"] = {
19291942
sessionKey: "agent:claude:acp:test",
19301943
backend: "acpx",
19311944
runtimeSessionName: "agent:claude:acp:test",
19321945
acpxRecordId: "agent:claude:acp:test",
19331946
};
19341947

1935-
await runtime.setConfigOption({
1948+
const result = await runtime.setConfigOption({
19361949
handle,
19371950
key: "model",
19381951
value: "anthropic/claude-sonnet-4-6",
19391952
});
1953+
expect(result).toBe(accepted);
19401954
await runtime.setConfigOption({
19411955
handle,
19421956
key: "model",

‎extensions/acpx/src/runtime.ts‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,17 +1771,17 @@ export class AcpxRuntime implements CompleteAcpRuntime {
17711771

17721772
async setConfigOption(
17731773
input: Parameters<NonNullable<AcpRuntime["setConfigOption"]>>[0],
1774-
): Promise<void> {
1774+
): ReturnType<NonNullable<AcpRuntime["setConfigOption"]>> {
17751775
const snapshot = await this.loadOperationSnapshotForHandle(input.handle);
1776-
await this.runWithProcessLeaseForHandle(input.handle, snapshot.record, () =>
1776+
return await this.runWithProcessLeaseForHandle(input.handle, snapshot.record, () =>
17771777
this.setConfigOptionUnlocked(input, snapshot),
17781778
);
17791779
}
17801780

17811781
private async setConfigOptionUnlocked(
17821782
input: Parameters<NonNullable<AcpRuntime["setConfigOption"]>>[0],
17831783
snapshot: AcpxHandleOperationSnapshot,
1784-
): Promise<void> {
1784+
): ReturnType<NonNullable<AcpRuntime["setConfigOption"]>> {
17851785
const { command } = snapshot;
17861786
const delegate = this.resolveDelegateForOperationSnapshot(input.handle, snapshot);
17871787
const key = input.key.trim().toLowerCase();
@@ -1796,17 +1796,17 @@ export class AcpxRuntime implements CompleteAcpRuntime {
17961796
failUnsupportedCodexAcpModel(input.value);
17971797
}
17981798
const { override } = classification;
1799-
if (override.model) {
1800-
await delegate.setConfigOption({ ...input, key: "model", value: override.model });
1801-
}
1799+
const modelResult = override.model
1800+
? await delegate.setConfigOption({ ...input, key: "model", value: override.model })
1801+
: undefined;
18021802
if (override.reasoningEffort) {
1803-
await delegate.setConfigOption({
1803+
return await delegate.setConfigOption({
18041804
...input,
18051805
key: "reasoning_effort",
18061806
value: override.reasoningEffort,
18071807
});
18081808
}
1809-
return;
1809+
return modelResult;
18101810
}
18111811
if (key === "thinking" || key === "thought_level" || key === "reasoning_effort") {
18121812
const classification = classifyCodexAcpModelRequest(undefined, input.value);
@@ -1819,22 +1819,20 @@ export class AcpxRuntime implements CompleteAcpRuntime {
18191819
"Clearing Codex reasoning effort on an existing session is unsupported. Choose a supported explicit effort; the current effort is unchanged.",
18201820
);
18211821
}
1822-
await delegate.setConfigOption({
1822+
return await delegate.setConfigOption({
18231823
...input,
18241824
key: "reasoning_effort",
18251825
value: reasoningEffort,
18261826
});
1827-
return;
18281827
}
18291828
}
18301829
if (isClaudeAcpCommand(command) && key === "model") {
1831-
await delegate.setConfigOption({
1830+
return await delegate.setConfigOption({
18321831
...input,
18331832
value: normalizeClaudeAcpModelOverride(input.value) ?? input.value,
18341833
});
1835-
return;
18361834
}
1837-
await delegate.setConfigOption(input);
1835+
return await delegate.setConfigOption(input);
18381836
}
18391837

18401838
async cancel(input: Parameters<AcpRuntime["cancel"]>[0]): Promise<void> {

0 commit comments

Comments
 (0)