type GPT-5.4 hosted tools and enforce model gates#314
type GPT-5.4 hosted tools and enforce model gates#314ndycode wants to merge 4 commits intofeat/openai-parity-pr5from
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
📝 WalkthroughWalkthroughcentralized tool type definitions to lib/types.ts, refactored tool cleanup logic with helper functions, added model-aware tool filtering to remove incompatible tools based on selected model capabilities, and extended test coverage accordingly. Changes
Sequence DiagramsequenceDiagram
participant Client
participant RequestTransformer
participant ModelCapabilities
participant ToolUtils
Client->>RequestTransformer: transformRequestBody(body, model)
RequestTransformer->>ToolUtils: cleanupToolDefinitions(body.tools)
ToolUtils-->>RequestTransformer: cleaned tools
RequestTransformer->>ModelCapabilities: getModelCapabilities(model)
ModelCapabilities-->>RequestTransformer: {supportsToolSearch, supportsComputerUse}
RequestTransformer->>RequestTransformer: sanitizeModelIncompatibleTools(tools, capabilities)
Note over RequestTransformer: Filter tool_search if unsupported<br/>Filter computer tools if unsupported<br/>Remove/update namespaces
RequestTransformer->>Client: sanitized request body
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes specific concerns for reviewregression test coverage gaps: lib/request/helpers/tool-utils.ts:line namespace filtering logic risk: lib/request/request-transformer.ts:line the sanitization recursively updates namespace.tools, but confirm that removing all nested tools correctly removes the entire namespace entry (the summary says "drops the namespace") rather than leaving an empty namespace object. model capability lookups: lib/request/request-transformer.ts:line ensure getModelCapabilities handles unknown or future model strings gracefully—does it return safe defaults (conservative: assume unsupported) or could it throw? confirm no concurrency issues if model list changes mid-flight. no windows-specific paths: tool definitions use standardized server_url and server_label fields, so no platform-specific path separators or escaping issues expected. public api contract stability: lib/types.ts exports now include tool types that were previously only in tool-utils.ts—verify no circular dependency risk or breaking changes for downstream consumers importing from either location. 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
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.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/request/request-transformer.ts`:
- Around line 903-904: sanitizePlanOnlyTools currently only inspects top-level
tools so nested tool entries inside bundle/namespace objects (e.g.,
{type:"function", function:{name:"request_user_input"}}) bypass the
collaboration guard; update sanitizePlanOnlyTools in request-transformer.ts to
recursively walk into namespace/bundle entries (same traversal pattern used by
sanitizeModelIncompatibleTools or the existing recursive helper) and filter out
plan-only tools at any depth, ensure body.tools assignment still calls
sanitizePlanOnlyTools before sanitizeModelIncompatibleTools, and add a vitest
regression next to the existing tests in test/request-transformer.test.ts
(around 1943-1964) that covers a namespace/bundle containing a plan-only tool to
assert it is removed in non-collaboration mode.
- Around line 901-905: After sanitizing tools in the block that calls
cleanupToolDefinitions, sanitizePlanOnlyTools, and
sanitizeModelIncompatibleTools, collapse an empty tools array to undefined so
downstream checks that use !!body.tools don't treat [] as truthy; specifically,
after body.tools = sanitizeModelIncompatibleTools(body.tools, body.model) set
body.tools = undefined if Array.isArray(body.tools) && body.tools.length === 0.
Update the affected tests in test/request-transformer.test.ts (the cases around
the previous assertions for result.tools) to assert the normalized behavior
(tools becomes undefined when all tools are stripped) and add/adjust vitest
cases to cover the empty-array-to-undefined normalization.
- Around line 352-365: The namespace-handling branch in request-transformer.ts
(the block around the type === "namespace" case using
sanitizeModelIncompatibleToolEntry) assumes "no change" if nestedTools.length
=== record.tools.length, which lets rewritten nested namespaces be discarded;
change the logic to detect structural changes (not just removals) by performing
a deep comparison between nestedTools and record.tools (e.g., element-wise/deep
equality) and only return the original tool when they are deeply equal,
otherwise return the updated record with tools: nestedTools; update the code
path that returns tool and the surrounding logic in
sanitizeModelIncompatibleToolEntry/namespace handling accordingly, and add a
vitest regression in test/request-transformer.test.ts (extend the existing test
around lines 2011-2047) that covers multi-level nested namespaces (e.g.,
namespace -> namespace -> tool_search on a model without search) to assert that
rewritten inner namespaces are preserved and unsupported tools are filtered out.
In `@lib/types.ts`:
- Line 196: The tools property is effectively typed as unknown because
RequestToolDefinition[] | unknown collapses to unknown; change the request
boundary type so tools is a concrete type (e.g., RequestToolDefinition[] or
RequestToolDefinition[] | undefined) instead of unioning with unknown, update
the cleanupToolDefinitions function signature (cleanupToolDefinitions) to accept
and return that concrete type rather than unknown so type information flows
through the pipeline, and add an expectTypeOf public API test to validate the
exported type shape for tools to prevent regressions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: c84f23a9-299d-49c1-950a-345d7a274175
📒 Files selected for processing (6)
lib/request/helpers/tool-utils.tslib/request/request-transformer.tslib/types.tstest/public-api-contract.test.tstest/request-transformer.test.tstest/tool-utils.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Greptile Review
🧰 Additional context used
📓 Path-based instructions (2)
test/**
⚙️ CodeRabbit configuration file
tests must stay deterministic and use vitest. demand regression cases that reproduce concurrency bugs, token refresh races, and windows filesystem behavior. reject changes that mock real secrets or skip assertions.
Files:
test/public-api-contract.test.tstest/request-transformer.test.tstest/tool-utils.test.ts
lib/**
⚙️ CodeRabbit configuration file
focus on auth rotation, windows filesystem IO, and concurrency. verify every change cites affected tests (vitest) and that new queues handle EBUSY/429 scenarios. check for logging that leaks tokens or emails.
Files:
lib/request/request-transformer.tslib/types.tslib/request/helpers/tool-utils.ts
|
@coderabbitai review |
|
✅ Actions performedReview triggered.
|
3c4429f to
5f16828
Compare
All review threads are resolved and later commits addressed this stale automated change request.
Summary
tool_search,mcp,computer, andnamespacebundlesStack
#313