Fix Codex tool schema compatibility#12
Conversation
📝 WalkthroughWalkthroughIntroduced passthrough normalization utilities for OpenAI Codex compatibility. Added PassthroughToolSchemaKey type and four functions: normalizeCodexToolChoice, normalizeCodexTools, normalizePassthroughForCodex, and applyPassthroughToCodexRequest. These flatten tool-related structures by propagating nested function names and metadata to parent tool objects and removing nested 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/openai-compat.test.ts (1)
222-274: Good coverage of the core flattening path.Consider also asserting that
descriptionandparametersfrom the nestedfunctionobject were promoted to the top-level tool entry (e.g.recordedTools[0]?.description === "Fetch weather for a city."). Without this, a regression that drops those fields wouldn't be caught.
There was a problem hiding this comment.
Pull request overview
This PR adds normalization logic to ensure OpenAI function-style tool schemas are compatible with Codex's expected format. The changes flatten nested {type: "function", function: {...}} structures into top-level tool objects with name, description, and parameters fields that Codex requires.
Changes:
- Added helper functions to normalize tools and tool_choice before forwarding to Codex
- Refactored both
/v1/chat/completionsand/v1/responsesendpoints to apply normalization - Added comprehensive test coverage for the normalization logic
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/openai.ts | Implements normalization functions and refactors passthrough logic to apply transformations |
| tests/openai-compat.test.ts | Adds test cases validating tool schema normalization for both chat completions and responses endpoints |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a296ce0cad
ℹ️ 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".
|
@copilot review |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/openai-compat.test.ts (1)
289-330: Consider adding atool_choiceassertion for the responses endpoint too.The chat completions step validates
tool_choiceflattening, but this step doesn't. SincehandleResponsesalso passes throughtool_choiceviaapplyPassthroughToCodexRequest, a parallel assertion would close the gap.
|
This is to get openclaw to work. |
|
Caution Error: Invalid environment provided. |
Summary
tests/openai-compat.test.ts.Validation