From 3f766c8c62089429cf8d2616bb2534ad485d6246 Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Sat, 2 May 2026 09:04:08 +0530 Subject: [PATCH] fix: normalize MCP empty tool schemas (#75401) (thanks @SymbolStar) --- CHANGELOG.md | 1 + src/agents/pi-tools-parameter-schema.ts | 4 ---- src/agents/pi-tools.schema.test.ts | 2 ++ 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdccc367355..21c132b7539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,7 @@ Docs: https://docs.openclaw.ai - Plugins/hooks: derive hook `ctx.channelId` from the conversation target instead of the provider name, so Discord and other channel plugins can keep per-channel state isolated. Fixes #59881. Thanks @bradfreels. - Gateway/config: log config health-state write failures instead of silently hiding config observe-recovery write errors. Thanks @sallyom. - Diagnostics: reset stuck-session timers on reply, tool, status, block, and ACP progress events, and back off repeated `session.stuck` diagnostics while a session remains unchanged. Supersedes #72010. Thanks @rubencu. +- Agents/OpenAI: normalize parameter-free MCP tool schemas whose `properties` value is null or undefined, so OpenAI no longer rejects MCP tools without parameters. Fixes #75362. (#75401) Thanks @SymbolStar. ## 2026.4.30 diff --git a/src/agents/pi-tools-parameter-schema.ts b/src/agents/pi-tools-parameter-schema.ts index 94eb9b783f0..ffb3c6b6c07 100644 --- a/src/agents/pi-tools-parameter-schema.ts +++ b/src/agents/pi-tools-parameter-schema.ts @@ -134,10 +134,6 @@ function isTypedSchemaMissingProperties( if (!("type" in schemaRecord) || conditionalKey !== null) { return false; } - // Treat both missing `properties` and `properties` set to a non-object value - // (e.g. undefined/null) as "missing properties" — MCP servers sometimes return - // `{ type: "object" }` or `{ type: "object", properties: undefined }` for - // parameter-free tools. if (!("properties" in schemaRecord)) { return true; } diff --git a/src/agents/pi-tools.schema.test.ts b/src/agents/pi-tools.schema.test.ts index c38eebb7405..e2f0c8a0d0f 100644 --- a/src/agents/pi-tools.schema.test.ts +++ b/src/agents/pi-tools.schema.test.ts @@ -207,6 +207,8 @@ describe("normalizeToolParameters", () => { expect(parameters.type).toBe("object"); expect(parameters.properties).toEqual({}); }); + + it("preserves existing properties on type:object schemas", () => { const tool: AnyAgentTool = { name: "query", label: "query",