Skip to content

Commit 4dcfe2c

Browse files
fix(acp): honor agent thinkingDefault for ACP bindings instead of forcing adaptive
ACP bindings resolved the owner agent's model but not its thinking policy, so runtimeOptions.thinking was never set and the agent fell back to the runtime's adaptive level. That broke ACP runs on models without adaptive support (e.g. ollama-cloud). Resolve the owner agent's thinking policy at bind time and thread it through the binding spec/record into runtimeOptions.thinking, mirroring the gateway's resolution (explicit thinkingDefault wins, else the model-family default, which still yields adaptive for models that support it). Thinking flows via the existing config-option channel; no acpx adapter change and no new setting.
1 parent 2e04f76 commit 4dcfe2c

4 files changed

Lines changed: 65 additions & 1 deletion

File tree

‎src/acp/persistent-bindings.lifecycle.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ export async function ensureConfiguredAcpBindingSession(params: {
106106
sessionKey,
107107
agent: params.spec.acpAgentId ?? params.spec.agentId,
108108
mode: params.spec.mode,
109-
runtimeOptions: params.spec.model ? { model: params.spec.model } : undefined,
109+
runtimeOptions:
110+
params.spec.model || params.spec.thinking
111+
? {
112+
...(params.spec.model ? { model: params.spec.model } : {}),
113+
...(params.spec.thinking ? { thinking: params.spec.thinking } : {}),
114+
}
115+
: undefined,
110116
cwd: params.spec.cwd,
111117
backendId: params.spec.backend,
112118
});

‎src/acp/persistent-bindings.types.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export type ConfiguredAcpBindingSpec = {
2929
acpAgentId?: string;
3030
mode: AcpRuntimeSessionMode;
3131
model?: string;
32+
/** Owner agent thinking policy, carried so ACP sessions honor thinkingDefault. */
33+
thinking?: string;
3234
cwd?: string;
3335
backend?: string;
3436
label?: string;
@@ -106,6 +108,7 @@ export function toConfiguredAcpBindingRecord(spec: ConfiguredAcpBindingSpec): Se
106108
...(spec.acpAgentId ? { acpAgentId: spec.acpAgentId } : {}),
107109
label: spec.label,
108110
...(spec.model ? { model: spec.model } : {}),
111+
...(spec.thinking ? { thinking: spec.thinking } : {}),
109112
...(spec.backend ? { backend: spec.backend } : {}),
110113
...(spec.cwd ? { cwd: spec.cwd } : {}),
111114
},
@@ -164,6 +167,7 @@ export function resolveConfiguredAcpBindingSpecFromRecord(
164167
acpAgentId: normalizeText(record.metadata?.acpAgentId),
165168
mode: normalizeMode(record.metadata?.mode),
166169
model: normalizeText(record.metadata?.model),
170+
thinking: normalizeText(record.metadata?.thinking),
167171
cwd: normalizeText(record.metadata?.cwd),
168172
backend: normalizeText(record.metadata?.backend),
169173
label: normalizeText(record.metadata?.label),

‎src/channels/plugins/acp-bindings.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,39 @@ describe("configured binding registry", () => {
226226
expect(getLoadedChannelPluginMock).not.toHaveBeenCalled();
227227
});
228228

229+
it("carries the owner agent thinkingDefault into the ACP binding record", () => {
230+
// Regression for #128145: an owner agent's thinkingDefault must reach the ACP session so
231+
// models that do not support `adaptive` (e.g. ollama-cloud) are not forced into it.
232+
resolveAgentConfigMock.mockReturnValue({ thinkingDefault: "off" });
233+
const plugin = createDiscordAcpPlugin();
234+
getLoadedChannelPluginMock.mockReturnValue(plugin);
235+
236+
const resolved = bindingRegistry.resolveConfiguredBindingRecord({
237+
cfg: createConfig() as never,
238+
channel: "discord",
239+
accountId: "default",
240+
conversationId: "1479098716916023408",
241+
});
242+
243+
expect(resolved?.record.metadata?.thinking).toBe("off");
244+
});
245+
246+
it("omits thinking from the ACP binding record when no thinking policy applies", () => {
247+
// Owner has no thinkingDefault and no explicit model, so the record preserves prior behavior
248+
// (no forced thinking level) instead of injecting a default.
249+
const plugin = createDiscordAcpPlugin();
250+
getLoadedChannelPluginMock.mockReturnValue(plugin);
251+
252+
const resolved = bindingRegistry.resolveConfiguredBindingRecord({
253+
cfg: createConfig() as never,
254+
channel: "discord",
255+
accountId: "default",
256+
conversationId: "1479098716916023408",
257+
});
258+
259+
expect(resolved?.record.metadata?.thinking).toBeUndefined();
260+
});
261+
229262
it("uses the current loaded channel plugin on each resolve", () => {
230263
const firstPlugin = createDiscordAcpPlugin();
231264
const secondPlugin = createDiscordAcpPlugin();

‎src/channels/plugins/acp-configured-binding-consumer.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
resolveAgentExplicitModelPrimary,
1919
resolveAgentWorkspaceDir,
2020
} from "../../agents/agent-scope.js";
21+
import { parseModelRef } from "../../agents/model-selection-normalize.js";
22+
import { resolveThinkingDefault } from "../../agents/model-thinking-default.js";
2123
import type { OpenClawConfig } from "../../config/types.openclaw.js";
2224
import type {
2325
ConfiguredBindingRuleConfig,
@@ -72,6 +74,7 @@ function buildConfiguredAcpSpec(params: {
7274
acpAgentId?: string;
7375
mode: "persistent" | "oneshot";
7476
model?: string;
77+
thinking?: string;
7578
cwd?: string;
7679
backend?: string;
7780
label?: string;
@@ -85,6 +88,7 @@ function buildConfiguredAcpSpec(params: {
8588
acpAgentId: params.acpAgentId,
8689
mode: params.mode,
8790
model: params.model,
91+
thinking: params.thinking,
8892
cwd: params.cwd,
8993
backend: params.backend,
9094
label: params.label,
@@ -110,6 +114,22 @@ function buildAcpTargetFactory(params: {
110114
const mode = normalizeMode(bindingOverrides.mode ?? runtimeDefaults.mode);
111115
// Every ACP binding uses its owner's explicit model, regardless of the owner's runtime type.
112116
const model = resolveAgentExplicitModelPrimary(params.cfg, params.agentId);
117+
// Resolve the owner agent's thinking policy alongside its model so ACP sessions honor the
118+
// agent's thinkingDefault instead of falling back to the runtime's `adaptive` default, which
119+
// breaks models that do not support adaptive thinking. Mirrors gateway session resolution:
120+
// an explicit per-agent thinkingDefault wins, otherwise the model-family default applies
121+
// (which still yields `adaptive` for models that support it).
122+
const agentThinkingDefault = resolveAgentConfig(params.cfg, params.agentId)?.thinkingDefault;
123+
const modelRef = model ? parseModelRef(model, "") : null;
124+
const thinking =
125+
agentThinkingDefault ??
126+
(modelRef
127+
? resolveThinkingDefault({
128+
cfg: params.cfg,
129+
provider: modelRef.provider,
130+
model: modelRef.model,
131+
})
132+
: undefined);
113133
const cwd =
114134
bindingOverrides.cwd ??
115135
runtimeDefaults.cwd ??
@@ -134,6 +154,7 @@ function buildAcpTargetFactory(params: {
134154
acpAgentId,
135155
mode,
136156
model,
157+
thinking,
137158
cwd,
138159
backend,
139160
label,

0 commit comments

Comments
 (0)