Skip to content

Fix Codex tool schema compatibility#12

Merged
0x4007 merged 2 commits intodevelopmentfrom
fix/codex-tools-compat
Feb 17, 2026
Merged

Fix Codex tool schema compatibility#12
0x4007 merged 2 commits intodevelopmentfrom
fix/codex-tools-compat

Conversation

@0x4007
Copy link
Member

@0x4007 0x4007 commented Feb 17, 2026

Summary

  • Normalize OpenAI function-style tool schema before forwarding to Codex.
  • Flatten OpenAI \ into top-level names Codex requires.
  • Normalize {type:"function", name}- Apply normalization on both /v1/responses- Add compatibility coverage in tests/openai-compat.test.ts.

Validation

  • deno test tests/openai-compat.test.ts

Copilot AI review requested due to automatic review settings February 17, 2026 16:24
@github-actions
Copy link

github-actions bot commented Feb 17, 2026

Copy link
Member Author

@0x4007 0x4007 left a comment

Choose a reason for hiding this comment

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

@codex review

@coderabbitai
Copy link

coderabbitai bot commented Feb 17, 2026

📝 Walkthrough

Walkthrough

Introduced 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 function fields. Refactored handleChatCompletions and handleResponses to use centralized normalization. Added tests validating tools and tool_choice structure flattening in chat completions and responses requests.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly reflects the main change: normalizing Codex tool schema compatibility by handling function-style tools.
Description check ✅ Passed The description covers the key changes: normalizing OpenAI tool schemas, flattening nested function fields, and adding test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/codex-tools-compat

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/openai-compat.test.ts (1)

222-274: Good coverage of the core flattening path.

Consider also asserting that description and parameters from the nested function object 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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/completions and /v1/responses endpoints 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.

@0x4007
Copy link
Member Author

0x4007 commented Feb 17, 2026

@codex review

Copy link

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

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: 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".

@0x4007
Copy link
Member Author

0x4007 commented Feb 17, 2026

@copilot review

Copy link

Copilot AI commented Feb 17, 2026

@0x4007 I've opened a new pull request, #13, to work on those changes. Once the pull request is ready, I'll request review from you.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Swish!

ℹ️ 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".

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/openai-compat.test.ts (1)

289-330: Consider adding a tool_choice assertion for the responses endpoint too.

The chat completions step validates tool_choice flattening, but this step doesn't. Since handleResponses also passes through tool_choice via applyPassthroughToCodexRequest, a parallel assertion would close the gap.

@0x4007
Copy link
Member Author

0x4007 commented Feb 17, 2026

This is to get openclaw to work.

@0x4007 0x4007 merged commit a69e849 into development Feb 17, 2026
2 checks passed
@ubiquity-os
Copy link

ubiquity-os bot commented Feb 17, 2026

Caution

Error: Invalid environment provided.

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.

3 participants