From f34a7780690a941936b31899e2d096b8a07f4afc Mon Sep 17 00:00:00 2001 From: User Date: Tue, 3 Feb 2026 04:08:01 +0900 Subject: [PATCH] fix: remove config.schema from agent gateway tool The config.schema endpoint returns a 373KB JSON schema designed for Control UI form rendering, not for agent consumption. When agents called this action, it caused context explosion issues. Changes: - Remove config.schema from GATEWAY_ACTIONS in gateway-tool.ts - Update system prompt to remove config.schema reference - Add config.patch to system prompt documentation The underlying config.schema endpoint remains available for Control UI via the internal callGatewayTool function. Fixes #7347 --- CHANGELOG.md | 1 + docs/tools/index.md | 3 ++- src/agents/system-prompt.test.ts | 2 ++ src/agents/system-prompt.ts | 3 +-- src/agents/tools/gateway-tool.ts | 7 +------ 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d66c0223f52..dafcf5c8a67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -180,6 +180,7 @@ Docs: https://docs.openclaw.ai - Memory/doctor SecretRef handling: treat SecretRef-backed memory-search API keys as configured, and fail embedding setup with explicit unresolved-secret errors instead of crashing. (#36835) Thanks @joshavant. - Memory/flush default prompt: ban timestamped variant filenames during default memory flush runs so durable notes stay in the canonical daily `memory/YYYY-MM-DD.md` file. (#34951) thanks @zerone0x. - Agents/reply delivery timing: flush embedded Pi block replies before waiting on compaction retries so already-generated assistant replies reach channels before compaction wait completes. (#35489) thanks @Sid-Qin. +- Agents/gateway config guidance: stop exposing `config.schema` through the agent `gateway` tool, remove prompt/docs guidance that told agents to call it, and keep agents on `config.get` plus `config.patch`/`config.apply` for config changes. (#7382) thanks @kakuteki. ## 2026.3.2 diff --git a/docs/tools/index.md b/docs/tools/index.md index 47366f25e3a..2f9417d75d9 100644 --- a/docs/tools/index.md +++ b/docs/tools/index.md @@ -453,7 +453,7 @@ Restart or apply updates to the running Gateway process (in-place). Core actions: - `restart` (authorizes + sends `SIGUSR1` for in-process restart; `openclaw gateway` restart in-place) -- `config.get` / `config.schema` +- `config.get` - `config.apply` (validate + write config + restart + wake) - `config.patch` (merge partial update + restart + wake) - `update.run` (run update + restart + wake) @@ -461,6 +461,7 @@ Core actions: Notes: - Use `delayMs` (defaults to 2000) to avoid interrupting an in-flight reply. +- `config.schema` remains available to internal Control UI flows and is not exposed through the agent `gateway` tool. - `restart` is enabled by default; set `commands.restart: false` to disable it. ### `sessions_list` / `sessions_history` / `sessions_send` / `sessions_spawn` / `session_status` diff --git a/src/agents/system-prompt.test.ts b/src/agents/system-prompt.test.ts index 13273354bf4..0d67634a0bf 100644 --- a/src/agents/system-prompt.test.ts +++ b/src/agents/system-prompt.test.ts @@ -444,7 +444,9 @@ describe("buildAgentSystemPrompt", () => { expect(prompt).toContain("## OpenClaw Self-Update"); expect(prompt).toContain("config.apply"); + expect(prompt).toContain("config.patch"); expect(prompt).toContain("update.run"); + expect(prompt).not.toContain("config.schema"); }); it("includes skills guidance when skills prompt is present", () => { diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index 440fde78708..991f2918f17 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -482,8 +482,7 @@ export function buildAgentSystemPrompt(params: { ? [ "Get Updates (self-update) is ONLY allowed when the user explicitly asks for it.", "Do not run config.apply or update.run unless the user explicitly requests an update or config change; if it's not explicit, ask first.", - "Use config.schema to fetch the current JSON Schema (includes plugins/channels) before making config changes or answering config-field questions; avoid guessing field names/types.", - "Actions: config.get, config.schema, config.apply (validate + write full config, then restart), update.run (update deps or git, then restart).", + "Actions: config.get, config.apply (validate + write full config, then restart), config.patch (partial update, merges with existing), update.run (update deps or git, then restart).", "After restart, OpenClaw pings the last active session automatically.", ].join("\n") : "", diff --git a/src/agents/tools/gateway-tool.ts b/src/agents/tools/gateway-tool.ts index d4cb47e0f9e..03419b17cf8 100644 --- a/src/agents/tools/gateway-tool.ts +++ b/src/agents/tools/gateway-tool.ts @@ -34,7 +34,6 @@ function resolveBaseHashFromSnapshot(snapshot: unknown): string | undefined { const GATEWAY_ACTIONS = [ "restart", "config.get", - "config.schema", "config.apply", "config.patch", "update.run", @@ -48,7 +47,7 @@ const GatewayToolSchema = Type.Object({ // restart delayMs: Type.Optional(Type.Number()), reason: Type.Optional(Type.String()), - // config.get, config.schema, config.apply, update.run + // config.get, config.apply, update.run gatewayUrl: Type.Optional(Type.String()), gatewayToken: Type.Optional(Type.String()), timeoutMs: Type.Optional(Type.Number()), @@ -172,10 +171,6 @@ export function createGatewayTool(opts?: { const result = await callGatewayTool("config.get", gatewayOpts, {}); return jsonResult({ ok: true, result }); } - if (action === "config.schema") { - const result = await callGatewayTool("config.schema", gatewayOpts, {}); - return jsonResult({ ok: true, result }); - } if (action === "config.apply") { const { raw, baseHash, sessionKey, note, restartDelayMs } = await resolveConfigWriteParams();