Skip to content

Commit e66d7c6

Browse files
committed
fix(agents): broaden local model lean profile
1 parent 6d362db commit e66d7c6

7 files changed

Lines changed: 96 additions & 10 deletions

File tree

docs/concepts/experimental-features.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,24 @@ Treat them differently from normal config:
3030

3131
## Local model lean mode
3232

33-
`agents.defaults.experimental.localModelLean: true` is a pressure-release valve for weaker local-model setups. When it is on, OpenClaw drops three default tools — `browser`, `cron`, and `message` from the agent's tool surface for every turn. Nothing else changes. Use `agents.list[].experimental.localModelLean` to enable or disable the same behavior for one configured agent.
33+
`agents.defaults.experimental.localModelLean: true` is a pressure-release valve for weaker local-model setups. When it is on, OpenClaw keeps the core coding/status surface but drops heavyweight web, media, channel, scheduler, node, and orchestration tools from the agent's tool surface for every turn. Use `agents.list[].experimental.localModelLean` to enable or disable the same behavior for one configured agent.
3434

35-
### Why these three tools
35+
### What it trims
3636

37-
These three tools have the largest descriptions and the most parameter shapes in the default OpenClaw runtime. On a small-context or stricter OpenAI-compatible backend that is the difference between:
37+
Lean mode trims tool families that tend to be noisy for small-context or stricter OpenAI-compatible backends:
38+
39+
- Web and browser tools: `browser`, `web_fetch`, `web_search`, `x_search`.
40+
- Channel/scheduler/orchestration tools: `message`, `cron`, `gateway`, `nodes`, `agents_list`, `sessions_list`, `sessions_history`, `sessions_send`, `sessions_spawn`, `subagents`.
41+
- Media and document-generation tools: `canvas`, `image`, `image_generate`, `music_generate`, `pdf`, `tts`, `video_generate`.
42+
- Hosted code-execution style tools: `code_execution`.
43+
44+
That can be the difference between:
3845

3946
- Tool schemas fitting cleanly in the prompt vs. crowding out conversation history.
4047
- The model picking the right tool vs. emitting malformed tool calls because there are too many similar-looking schemas.
4148
- The Chat Completions adapter staying inside the server's structured-output limits vs. tripping a 400 on tool-call payload size.
4249

43-
Removing them does not silently rewire OpenClaw — it just makes the tool list shorter. The model still has `read`, `write`, `edit`, `exec`, `apply_patch`, web search/fetch (when configured), memory, and session/agent tools available.
50+
Removing them does not silently rewire OpenClaw — it just makes the tool list shorter. The model still has core coding tools such as `read`, `write`, `edit`, `exec`, `apply_patch`, and `process`, plus lightweight status/planning tools such as `session_status` and `update_plan`. Plugin-owned memory tools stay available unless you narrow them separately with `tools.profile`, `tools.allow`, or `tools.deny`.
4451

4552
### When to turn it on
4653

@@ -94,7 +101,7 @@ Restart the Gateway after changing the flag, then confirm the trimmed tool list
94101
openclaw status --deep
95102
```
96103

97-
The deep status output lists the active agent tools; `browser`, `cron`, and `message` should be absent when lean mode is on.
104+
The deep status output lists the active agent tools. Heavyweight web, media, channel, scheduler, node, and orchestration tools should be absent when lean mode is on.
98105

99106
## Experimental does not mean hidden
100107

docs/gateway/local-models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ If the model loads cleanly but full agent turns misbehave, work top-down — con
315315
openclaw infer model run --gateway --model <provider/model> --prompt "Reply with exactly: pong" --json
316316
```
317317

318-
3. **Try lean mode.** If both probes pass but real agent turns fail with malformed tool calls or oversized prompts, enable `agents.defaults.experimental.localModelLean: true`. It drops the three heaviest default tools (`browser`, `cron`, `message`) so the prompt shape is smaller and less brittle. See [Experimental Features → Local model lean mode](/concepts/experimental-features#local-model-lean-mode) for the full explanation, when to use it, and how to confirm it is on.
318+
3. **Try lean mode.** If both probes pass but real agent turns fail with malformed tool calls or oversized prompts, enable `agents.defaults.experimental.localModelLean: true`. It keeps core coding/status tools but trims heavyweight web, media, channel, scheduler, node, and orchestration tools so the prompt shape is smaller and less brittle. See [Experimental Features → Local model lean mode](/concepts/experimental-features#local-model-lean-mode) for the full explanation, when to use it, and how to confirm it is on.
319319

320320
4. **Disable tools entirely as a last resort.** If lean mode is not enough, set `models.providers.<provider>.models[].compat.supportsTools: false` for that model entry. The agent will then operate without tool calls on that model.
321321

docs/providers/ollama.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ Use these as starting points and replace model IDs with the exact names from `ol
679679
```
680680

681681
Use `compat.supportsTools: false` only when the model or server reliably fails on tool schemas. It trades agent capability for stability.
682-
`localModelLean` removes the browser, cron, and message tools from the agent surface, but it does not change Ollama's runtime context or thinking mode. Pair it with explicit `params.num_ctx` and `params.thinking: false` for small Qwen-style thinking models that loop or spend their response budget on hidden reasoning.
682+
`localModelLean` keeps core coding/status tools but removes heavyweight web, media, channel, scheduler, node, and orchestration tools from the agent surface. It does not change Ollama's runtime context or thinking mode. Pair it with explicit `params.num_ctx` and `params.thinking: false` for small Qwen-style thinking models that loop or spend their response budget on hidden reasoning.
683683

684684
</Accordion>
685685
</AccordionGroup>

src/agents/agent-tools.model-provider-collision.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ describe("applyModelProviderToolPolicy", () => {
141141
[
142142
{ name: "read" },
143143
{ name: "browser" },
144+
{ name: "web_search" },
145+
{ name: "web_fetch" },
146+
{ name: "x_search" },
147+
{ name: "sessions_spawn" },
148+
{ name: "image_generate" },
144149
{ name: "cron" },
145150
{ name: "message" },
146151
{ name: "exec" },

src/agents/local-model-lean.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,56 @@ function tools(names: string[]): AnyAgentTool[] {
88
}
99

1010
describe("local model lean tool filtering", () => {
11+
it("keeps core coding tools while trimming heavyweight surfaces", () => {
12+
expect(
13+
filterLocalModelLeanTools({
14+
tools: tools([
15+
"read",
16+
"write",
17+
"edit",
18+
"exec",
19+
"apply_patch",
20+
"process",
21+
"session_status",
22+
"update_plan",
23+
"browser",
24+
"web_search",
25+
"web_fetch",
26+
"x_search",
27+
"code_execution",
28+
"gateway",
29+
"nodes",
30+
"sessions_spawn",
31+
"sessions_yield",
32+
"subagents",
33+
"image_generate",
34+
"video_generate",
35+
"tts",
36+
"cron",
37+
"message",
38+
]),
39+
config: {
40+
agents: {
41+
defaults: {
42+
experimental: {
43+
localModelLean: true,
44+
},
45+
},
46+
},
47+
},
48+
}).map((tool) => tool.name),
49+
).toEqual([
50+
"read",
51+
"write",
52+
"edit",
53+
"exec",
54+
"apply_patch",
55+
"process",
56+
"session_status",
57+
"update_plan",
58+
]);
59+
});
60+
1161
it("filters heavyweight tools for one configured agent", () => {
1262
const cfg: OpenClawConfig = {
1363
agents: {

src/agents/local-model-lean.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,31 @@ import { normalizeAgentId, parseAgentSessionKey } from "../routing/session-key.j
33
import { resolveAgentConfig, resolveDefaultAgentId } from "./agent-scope-config.js";
44
import type { AnyAgentTool } from "./agent-tools.types.js";
55

6-
const LOCAL_MODEL_LEAN_DENY_TOOL_NAMES = new Set(["browser", "cron", "message"]);
6+
const LOCAL_MODEL_LEAN_DENY_TOOL_NAMES = new Set([
7+
"agents_list",
8+
"browser",
9+
"canvas",
10+
"code_execution",
11+
"cron",
12+
"gateway",
13+
"image",
14+
"image_generate",
15+
"message",
16+
"music_generate",
17+
"nodes",
18+
"pdf",
19+
"sessions_history",
20+
"sessions_list",
21+
"sessions_send",
22+
"sessions_spawn",
23+
"sessions_yield",
24+
"subagents",
25+
"tts",
26+
"video_generate",
27+
"web_fetch",
28+
"web_search",
29+
"x_search",
30+
]);
731

832
function resolveLocalModelLeanAgentId(params: {
933
config?: OpenClawConfig;

src/config/schema.help.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export const FIELD_HELP: Record<string, string> = {
252252
"agents.list[].experimental":
253253
"Per-agent experimental flags. Omitted fields inherit agents.defaults.experimental.",
254254
"agents.list[].experimental.localModelLean":
255-
"Per-agent override for lean local-model mode. Enable it for one smaller local-model agent without trimming tools from every agent.",
255+
"Per-agent override for lean local-model mode. Enable it for one smaller local-model agent without trimming heavyweight web, media, channel, and orchestration tools from every agent.",
256256
"agents.defaults.contextLimits":
257257
"Focused per-agent-context budget defaults for selected high-volume excerpts and injected prompt blocks. Use this to tune bounded read/injection sizes without reopening any unbounded call paths.",
258258
"agents.defaults.contextLimits.memoryGetMaxChars":
@@ -1127,7 +1127,7 @@ export const FIELD_HELP: Record<string, string> = {
11271127
"agents.defaults.experimental":
11281128
"Experimental agent-default flags. Keep these off unless you are intentionally testing a preview surface.",
11291129
"agents.defaults.experimental.localModelLean":
1130-
"Experimental local-model prompt trim. When enabled, OpenClaw drops heavyweight default tools like browser, cron, and message for weaker or smaller local-model backends.",
1130+
"Experimental local-model prompt trim. When enabled, OpenClaw keeps core coding/status tools but drops heavyweight web, media, channel, scheduler, and orchestration tools for weaker or smaller local-model backends.",
11311131
"agents.defaults.bootstrapPromptTruncationWarning":
11321132
'Inject agent-visible warning text when bootstrap files are truncated: "off", "once", or "always" (default).',
11331133
"agents.defaults.startupContext":

0 commit comments

Comments
 (0)