Skip to content

Commit ad4a138

Browse files
maweibinclaude
andcommitted
fix(agents): normalize MCP schema before null-stripping (P2)
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent 56bb624 commit ad4a138

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/agents/agent-bundle-mcp-materialize.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,11 @@ export async function materializeBundleMcpToolsForRun(params: {
476476
// Strip null-valued optional arguments: some MCP servers treat JSON null differently
477477
// from an absent key (e.g., coercing null to ""), while the LLM often sends null for
478478
// unset optional params. Only strip nulls for fields NOT declared as nullable in the
479-
// tool's input schema, preserving schema-meaningful nulls for required nullable fields.
480-
const schema = tool.inputSchema as Record<string, unknown> | undefined;
481-
const cleaned = stripNullOptionalArgs(input, schema);
479+
// tool's normalized input schema, preserving schema-meaningful nulls for required nullable
480+
// fields. Normalize first so $ref, nullable: true, and other OpenClaw schema conventions
481+
// are resolved before nullability classification.
482+
const normalizedSchema = normalizeToolParameterSchema(tool.inputSchema as never);
483+
const cleaned = stripNullOptionalArgs(input, normalizedSchema as Record<string, unknown>);
482484
const result = await params.runtime.callTool(tool.serverName, tool.toolName, cleaned);
483485
return toAgentToolResult({
484486
serverName: tool.serverName,

0 commit comments

Comments
 (0)