fix(ai): normalize Responses tool schemas - #732
Conversation
There was a problem hiding this comment.
💡 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>); |
There was a problem hiding this comment.
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>); |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
Validation
npm --prefix packages/ai run test -- xai-responses.test.tsnpm --prefix packages/ai testnpm run checkSummary by cubic
Normalize Responses function tool schemas to always send an object-root
parameters, preventing unnormalized root unions from being forwarded. Fixes the xAIgrok-4.5request path and preserves MCP schemas with a requiredtype: "object"root (follow-up to #718).normalizeToolParametersForOpenAICompatinconvertResponsesToolsso top-levelanyOfis flattened into an object-root schema.grok-4.5to verify normalized function toolparameters.packages/ai/CHANGELOG.md.Written for commit f59ded7. Summary will update on new commits.