Skip to content

fix(tools): normalize truly empty MCP tool schemas for OpenAI#60176

Merged
steipete merged 2 commits into
openclaw:mainfrom
Bartok9:fix/60158-empty-mcp-tool-schema
Apr 3, 2026
Merged

fix(tools): normalize truly empty MCP tool schemas for OpenAI#60176
steipete merged 2 commits into
openclaw:mainfrom
Bartok9:fix/60158-empty-mcp-tool-schema

Conversation

@Bartok9

@Bartok9 Bartok9 commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #60158

MCP tools with parameter-free schemas may return truly empty objects {} without a type field. The existing normalization handled { type: "object" }{ type: "object", properties: {} } but missed the truly empty case.

Problem

OpenAI gpt-5.4 rejects tool schemas without type: "object" and properties, causing HTTP 400 errors:

Invalid schema for function 'flux-mcp__get_flux_instance':
In context=(), object schema missing properties.

This was happening for MCP tools like flux-operator-mcp that expose parameter-free tool schemas.

Root Cause

The normalizeToolParameterSchema function in pi-tools.schema.ts handled three cases:

  1. Schemas with both type and properties → pass through
  2. Schemas with no type but with properties or required → add type: "object"
  3. Schemas with type but no properties → add properties: {}

But it did not handle truly empty schemas {} that have neither type nor properties. These fell through to the final return schema without normalization.

Fix

Added a condition before the final pass-through to catch empty schemas (no type, no properties, no unions) and normalize them to { type: "object", properties: {} }.

Testing

  • Added test case: "normalizes truly empty schemas to type:object with properties:{} (MCP parameter-free tools)"
  • All existing tests pass

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Apr 3, 2026
@greptile-apps

greptile-apps Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a missing normalization branch in normalizeToolParameterSchema for MCP tool schemas that are truly empty {} — having neither a type field nor properties. These schemas now get normalized to { type: "object", properties: {} } before being sent to OpenAI, matching the existing treatment of { type: "object" } schemas and resolving the HTTP 400 errors. A focused test case is added alongside the existing ones.

Confidence Score: 5/5

Safe to merge — the fix is minimal, correctly guarded, and covered by a new test.

The new condition fires only after confirming neither type nor properties is present (and after all existing early-return branches have already been checked), so it cannot interfere with schemas already handled. The spread order { type: "object", properties: {}, ...schemaRecord } is safe because the guard ensures those keys are absent in schemaRecord. No P0/P1 findings.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(tools): normalize truly empty MCP to..." | Re-trigger Greptile

Bartok Moltbot and others added 2 commits April 3, 2026 20:17
Fixes openclaw#60158

MCP tools with parameter-free schemas may return truly empty objects
`{}` without a `type` field. The existing normalization handled
`{ type: "object" }` → `{ type: "object", properties: {} }` but
missed the truly empty case.

OpenAI gpt-5.4 rejects tool schemas without `type: "object"` and
`properties`, causing HTTP 400 errors:

```
Invalid schema for function 'flux-mcp__get_flux_instance':
In context=(), object schema missing properties.
```

This change catches empty schemas (no type, no properties, no unions)
before the final pass-through and converts them to the required format.

Added test case for parameter-free MCP tool schemas.
@steipete
steipete force-pushed the fix/60158-empty-mcp-tool-schema branch from 751773a to 90633d8 Compare April 3, 2026 11:45
@steipete
steipete merged commit 57999f9 into openclaw:main Apr 3, 2026
9 checks passed
@steipete

steipete commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm check && pnpm test && pnpm build
  • Land commit: 90633d8
  • Merge commit: 57999f9

Thanks @Bartok9!

@prtags

prtags Bot commented Apr 23, 2026

Copy link
Copy Markdown

Related work from PRtags group unique-heron-2zsc

Title: Open PR duplicate: MCP schema properties + auto-reset override self-heal composite

Number Title
#58299 fix: normalize MCP tool schemas missing properties field for OpenAI Responses API
#60176* fix(tools): normalize truly empty MCP tool schemas for OpenAI
#69419 session: clear auto-sourced model/auth overrides on /new and /reset
#69956 fix(mcp-http): ensure MCP tool schemas always include properties field

* This PR

@Bartok9

Bartok9 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @steipete for landing it! Glad the fix was clean — the truly-empty {} case is one of those easy-to-miss edge cases that only shows up with certain MCP tool definitions. 🎻

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
obviyus pushed a commit to SymbolStar/openclaw that referenced this pull request May 2, 2026
…o OpenAI (openclaw#75362)

MCP servers may return inputSchema as { type: "object" } without a
properties field, or with properties set to undefined/null. The
hasTopLevelObjectSchema guard only checked 'properties' in schemaRecord
(key existence) without verifying the value is a real object. This caused
such schemas to pass through unnormalized, resulting in OpenAI rejecting
them with 'object schema missing properties'.

Fix: tighten hasTopLevelObjectSchema to require properties to be a
non-null object, and broaden isTypedSchemaMissingProperties to catch
properties keys with undefined/null values.

Regression of openclaw#60158 (originally fixed by openclaw#60176).
obviyus pushed a commit that referenced this pull request May 2, 2026
…o OpenAI (#75362)

MCP servers may return inputSchema as { type: "object" } without a
properties field, or with properties set to undefined/null. The
hasTopLevelObjectSchema guard only checked 'properties' in schemaRecord
(key existence) without verifying the value is a real object. This caused
such schemas to pass through unnormalized, resulting in OpenAI rejecting
them with 'object schema missing properties'.

Fix: tighten hasTopLevelObjectSchema to require properties to be a
non-null object, and broaden isTypedSchemaMissingProperties to catch
properties keys with undefined/null values.

Regression of #60158 (originally fixed by #60176).
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
…o OpenAI (openclaw#75362)

MCP servers may return inputSchema as { type: "object" } without a
properties field, or with properties set to undefined/null. The
hasTopLevelObjectSchema guard only checked 'properties' in schemaRecord
(key existence) without verifying the value is a real object. This caused
such schemas to pass through unnormalized, resulting in OpenAI rejecting
them with 'object schema missing properties'.

Fix: tighten hasTopLevelObjectSchema to require properties to be a
non-null object, and broaden isTypedSchemaMissingProperties to catch
properties keys with undefined/null values.

Regression of openclaw#60158 (originally fixed by openclaw#60176).
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…o OpenAI (openclaw#75362)

MCP servers may return inputSchema as { type: "object" } without a
properties field, or with properties set to undefined/null. The
hasTopLevelObjectSchema guard only checked 'properties' in schemaRecord
(key existence) without verifying the value is a real object. This caused
such schemas to pass through unnormalized, resulting in OpenAI rejecting
them with 'object schema missing properties'.

Fix: tighten hasTopLevelObjectSchema to require properties to be a
non-null object, and broaden isTypedSchemaMissingProperties to catch
properties keys with undefined/null values.

Regression of openclaw#60158 (originally fixed by openclaw#60176).
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…o OpenAI (openclaw#75362)

MCP servers may return inputSchema as { type: "object" } without a
properties field, or with properties set to undefined/null. The
hasTopLevelObjectSchema guard only checked 'properties' in schemaRecord
(key existence) without verifying the value is a real object. This caused
such schemas to pass through unnormalized, resulting in OpenAI rejecting
them with 'object schema missing properties'.

Fix: tighten hasTopLevelObjectSchema to require properties to be a
non-null object, and broaden isTypedSchemaMissingProperties to catch
properties keys with undefined/null values.

Regression of openclaw#60158 (originally fixed by openclaw#60176).
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…o OpenAI (openclaw#75362)

MCP servers may return inputSchema as { type: "object" } without a
properties field, or with properties set to undefined/null. The
hasTopLevelObjectSchema guard only checked 'properties' in schemaRecord
(key existence) without verifying the value is a real object. This caused
such schemas to pass through unnormalized, resulting in OpenAI rejecting
them with 'object schema missing properties'.

Fix: tighten hasTopLevelObjectSchema to require properties to be a
non-null object, and broaden isTypedSchemaMissingProperties to catch
properties keys with undefined/null values.

Regression of openclaw#60158 (originally fixed by openclaw#60176).
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
…o OpenAI (openclaw#75362)

MCP servers may return inputSchema as { type: "object" } without a
properties field, or with properties set to undefined/null. The
hasTopLevelObjectSchema guard only checked 'properties' in schemaRecord
(key existence) without verifying the value is a real object. This caused
such schemas to pass through unnormalized, resulting in OpenAI rejecting
them with 'object schema missing properties'.

Fix: tighten hasTopLevelObjectSchema to require properties to be a
non-null object, and broaden isTypedSchemaMissingProperties to catch
properties keys with undefined/null values.

Regression of openclaw#60158 (originally fixed by openclaw#60176).
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: openai/gpt-5.4 rejects parameter-free MCP tool schemas in 2026.4.2

2 participants