Skip to content

fix(mcp): normalize empty parameter-free tool schema before sending to OpenAI (#75362)#75401

Merged
obviyus merged 2 commits into
openclaw:mainfrom
SymbolStar:fix/mcp-empty-schema-75362
May 2, 2026
Merged

fix(mcp): normalize empty parameter-free tool schema before sending to OpenAI (#75362)#75401
obviyus merged 2 commits into
openclaw:mainfrom
SymbolStar:fix/mcp-empty-schema-75362

Conversation

@SymbolStar

Copy link
Copy Markdown
Contributor

Fixes #75362

Summary

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 400 Invalid schema for function: object schema missing properties.

Root Cause

In pi-tools-parameter-schema.ts:

  • hasTopLevelObjectSchema checked "properties" in schemaRecord — which is true even when the value is undefined
  • isTypedSchemaMissingProperties checked !("properties" in schemaRecord) — which is false when the key exists with value undefined

Result: schemas like { type: "object", properties: undefined } passed through without normalization.

Fix

  • Tighten hasTopLevelObjectSchema to require properties to be a non-null object
  • Broaden isTypedSchemaMissingProperties to catch properties keys with undefined/null/non-object values

Regression History

Tests

Added unit tests in:

  • openai-tool-schema.test.ts: strict mode normalization for empty/undefined properties
  • pi-tools.schema.test.ts: normalizeToolParameters with properties: undefined and properties: null

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels May 1, 2026
@clawsweeper

clawsweeper Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
Review failed before ClawSweeper could summarize the requested change.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Next step before merge
Review did not complete, so no work-lane recommendation was made.

Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

Do we have a high-confidence way to reproduce the issue?

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

What I checked:

  • failure reason: codex execution failed.
  • codex failure detail: Command failed: /usr/bin/git status --porcelain=v1 --untracked-files=all.
  • codex stdout: Per-item Codex failure; continuing with the rest of the shard.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)

Remaining risk / open question:

  • No close action taken because the review did not complete.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 1a796b9700ae.

@obviyus

obviyus commented May 2, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper automerge

@clawsweeper clawsweeper Bot added the clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge label May 2, 2026
@clawsweeper

clawsweeper Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper 🐠 automerge status

No new branch changes from this pass. ClawSweeper left the branch untouched instead of making a noisy edit.

Executor outcome: no planned fix actions.
Worker summary: No repair PR is needed. The hydrated preflight shows this PR already landed on main as merge commit 3f766c8, #75362 is already closed, and the current checkout matches the preflight main SHA c76ee64. Local inspection confirms the landed code handles null/undefined/non-object properties and includes regression tests plus changelog credit. No GitHub mutations are planned; closed refs are retained as historical evidence.

Worker actions:

  • keep_closed on this PR: skipped - The canonical PR is already merged and closed; job frontmatter blocks merge and close actions, and no repair artifact is needed.
  • keep_closed on #75362: skipped - Already closed and covered by the landed canonical this PR; no post-merge close action is allowed or needed.
  • keep_closed on #60176: skipped - Already-merged historical related fix; keep as evidence and preserve contributor credit.
  • keep_closed on #60158: skipped - Already closed by the historical merged fix fix(tools): normalize truly empty MCP tool schemas for OpenAI #60176; no mutation planned.

No branch push, rebase, replacement PR, merge, or ClawSweeper re-review was started on this pass.

fish notes: model gpt-5.5, reasoning high.

Automerge progress:

  • 2026-05-02 03:13:34 UTC review queued [`abd04a07578c`](https://github.com/openclaw/openclaw/commit/abd04a07578cac6bcb86ce80597c407721c19b71) (queued)
  • 2026-05-02 03:14:29 UTC repair queued [`abd04a07578c`](https://github.com/openclaw/openclaw/commit/abd04a07578cac6bcb86ce80597c407721c19b71) (autonomous) Run: https://github.com/openclaw/clawsweeper/actions/runs/25242426838
  • 2026-05-02 03:38:02 UTC review passed [`a917c7139eac`](https://github.com/openclaw/openclaw/commit/a917c7139eac7f5e12f505594ce20f06bae2bf63) (structured ClawSweeper verdict: pass (sha=a917c7139eac7f5e12f505594ce20f06bae2b...)
  • 2026-05-02 03:38:08 UTC repair queued [`a917c7139eac`](https://github.com/openclaw/openclaw/commit/a917c7139eac7f5e12f505594ce20f06bae2bf63) (autonomous) Run: https://github.com/openclaw/clawsweeper/actions/runs/25242886396
  • 2026-05-02 03:41:17 UTC review queued [`1b8b3a33fce0`](https://github.com/openclaw/openclaw/commit/1b8b3a33fce0d567b7294e37af9687ca28aa484b) (queued)
  • 2026-05-02 03:41:18 UTC repair completed (no branch change) in 24m 10s Run: https://github.com/openclaw/clawsweeper/actions/runs/25242426838 Codex /review timed out after 30000ms
  • 2026-05-02 04:11:40 UTC repair completed (no branch change) in 1s Run: https://github.com/openclaw/clawsweeper/actions/runs/25243424836 no planned fix actions

@obviyus
obviyus force-pushed the fix/mcp-empty-schema-75362 branch from a917c71 to 1b8b3a3 Compare May 2, 2026 03:39
…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).
@clawsweeper clawsweeper Bot added the clawsweeper:human-review Needs maintainer review before ClawSweeper can continue label May 2, 2026
@clawsweeper

clawsweeper Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

🦞🦞
ClawSweeper is pausing this repair loop for human review.

Source: clawsweeper[bot]
Reason: structured ClawSweeper verdict: needs-human (sha=1b8b3a33fce0d567b7294e37af9687ca28aa484b)

I added clawsweeper:human-review and left the final call with a maintainer.

@obviyus
obviyus force-pushed the fix/mcp-empty-schema-75362 branch from 1b8b3a3 to 764d262 Compare May 2, 2026 03:43

@obviyus obviyus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the MCP no-parameter schema regression: typed object schemas with properties: undefined or null now normalize through the shared tool-parameter path before OpenAI strict schema handling.

Maintainer follow-up restored the dropped regression-test wrapper, trimmed the redundant explanatory comment, rebased onto current main, and moved the changelog entry to the active Fixes block with PR attribution.

Local gate: pnpm test src/agents/pi-tools.schema.test.ts src/agents/openai-tool-schema.test.ts and pnpm check:changed.

@obviyus
obviyus merged commit 3f766c8 into openclaw:main May 2, 2026
81 checks passed
@obviyus

obviyus commented May 2, 2026

Copy link
Copy Markdown
Contributor

Landed on main.

Thanks @SymbolStar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge clawsweeper:human-review Needs maintainer review before ClawSweeper can continue size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Regression: openai/gpt-5.4 rejects parameter-free MCP tool schemas again in v2026.4.27

2 participants