Skip to content

fix(ai): normalize Responses tool schemas - #732

Open
Tinycute00 wants to merge 1 commit into
code-yeongyu:mainfrom
Tinycute00:fix/openai-responses-root-schema
Open

fix(ai): normalize Responses tool schemas#732
Tinycute00 wants to merge 1 commit into
code-yeongyu:mainfrom
Tinycute00:fix/openai-responses-root-schema

Conversation

@Tinycute00

@Tinycute00 Tinycute00 commented Aug 5, 2026

Copy link
Copy Markdown

Summary

Validation

  • npm --prefix packages/ai run test -- xai-responses.test.ts
  • npm --prefix packages/ai test
  • repository TypeScript validation
  • pre-commit npm run check

Summary by cubic

Normalize Responses function tool schemas to always send an object-root parameters, preventing unnormalized root unions from being forwarded. Fixes the xAI grok-4.5 request path and preserves MCP schemas with a required type: "object" root (follow-up to #718).

  • Bug Fixes
    • Applied normalizeToolParametersForOpenAICompat in convertResponsesTools so top-level anyOf is flattened into an object-root schema.
    • Added a test for grok-4.5 to verify normalized function tool parameters.
    • Updated packages/ai/CHANGELOG.md.

Written for commit f59ded7. Summary will update on new commits.

Review in cubic

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f59ded74c8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

} as OpenAITool;
}

const parameters = normalizeToolParametersForOpenAICompat(tool.parameters as Record<string, unknown>);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Record the Responses source change in changes.md

This changes the Responses provider wire payload by normalizing function-tool schemas, but the commit only adds a release changelog note and leaves packages/ai/src/changes.md without a source-change entry. When upstream syncs hit this adapter area, that file is the durable record of what changed, why, extension limits, and conflict zones, so this follow-up can be missed or mis-resolved unless it is documented there in the same increment.

AGENTS.md reference: AGENTS.md:L97-L98

Useful? React with 👍 / 👎.

} as OpenAITool;
}

const parameters = normalizeToolParametersForOpenAICompat(tool.parameters as Record<string, unknown>);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize hook-injected Responses tools after payload hooks

When onPayload adds or replaces tools, those function schemas bypass this new normalization because it only runs while converting context.tools, before the Responses adapters invoke the payload hook. The same root-union schema injected by an extension/hook is still sent unmerged to xAI/OpenAI/Azure/Codex Responses, unlike the Completions path which has a post-hook normalizeRequestToolSchemas pass for this exact case, so hook-injected MCP/tool schemas can still hit the provider rejection this change is meant to prevent.

AGENTS.md reference: packages/ai/AGENTS.md:L51-L52

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants