fix(mcp) : file search transform and include filter#1449
fix(mcp) : file search transform and include filter#1449pramod-rudrawadi wants to merge 7 commits into
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR extends MCP file-search handling across the protocol, transformation, and request/response pipeline. It adds optional metadata fields to file-search result types, refactors parsing to support field aliases and multiple input shapes, enables file-search routing as a built-in tool type, implements conditional filtering of results based on request include flags, and prefers structured content in JSON conversion. ChangesFile Search with Structured Content & Conditional Filtering
Sequence DiagramsequenceDiagram
participant Client
participant Streaming as Streaming Handler
participant Router as MCP Router
participant Executor as Tool Executor
participant Transform as Transformer
participant Orch as Orchestrator
Client->>Streaming: Send file-search request<br/>(with include flags)
Streaming->>Router: Recognize FileSearch<br/>as built-in tool type
Router->>Executor: Route to MCP executor<br/>(include flags passed)
Executor->>Transform: Parse file-search results
Transform->>Transform: Extract fields with aliases<br/>(file_id, filename,<br/>vector_store_id, etc.)
Transform->>Executor: Return parsed FileSearchResult
Executor->>Executor: Conditionally filter<br/>results field based<br/>on include flags
Executor->>Orch: Convert to JSON
Orch->>Orch: Prefer structured_content<br/>else use content
Orch->>Streaming: Return filtered output
Streaming->>Client: Send response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Hi @pramod-rudrawadi, this PR has merge conflicts that must be resolved before it can be merged. Please rebase your branch: git fetch origin main
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease |
There was a problem hiding this comment.
Code Review
This pull request enhances the Model Context Protocol (MCP) implementation by improving the handling of structured tool results and file search outputs. Key updates include prioritizing structured_content in the orchestrator, expanding the FileSearchResult struct to include vector_store_id and additional_properties, and refining the response transformer to support various JSON schemas and aliases for file search results. Additionally, a filtering mechanism was implemented to honor OpenAI-style include parameters, ensuring file search results are only returned when explicitly requested. Comprehensive tests were added across the modified modules to verify these changes. I have no feedback to provide as there were no review comments.
Signed-off-by: Pramod Rudrawadi <pramod.rudrawadi@oracle.com>
Signed-off-by: Pramod Rudrawadi <pramod.rudrawadi@oracle.com>
Signed-off-by: Pramod Rudrawadi <pramod.rudrawadi@oracle.com>
Signed-off-by: Pramod Rudrawadi <pramod.rudrawadi@oracle.com>
…esult parsing Signed-off-by: Pramod Rudrawadi <pramod.rudrawadi@oracle.com>
Signed-off-by: Pramod Rudrawadi <pramod.rudrawadi@oracle.com>
…vior Signed-off-by: Pramod Rudrawadi <pramod.rudrawadi@oracle.com>
ea8a1c6 to
856afc0
Compare
|
This pull request has been automatically marked as stale because it has not had any activity within 14 days. It will be automatically closed if no further activity occurs within 16 days. Leave a comment if you feel this pull request should remain open. Thank you! |
|
Hi @pramod-rudrawadi, this PR has merge conflicts that must be resolved before it can be merged. Please rebase your branch: git fetch origin main
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease |
Description
Problem
This PR closes several gaps in MCP-hosted
file_searchbehavior across routing, output shaping, and payload handling:file_searchwas not consistently included in builtin MCP routing/type extraction.file_search_call.resultsneeded explicit include-gating to match OpenAIinclude[]semantics.Solution
file_searchdetection/mapping in MCP routing/type extraction.file_search_call.resultsbehindIncludeField::FileSearchCallResultsin streaming and non-streaming tool-loop outputs.CallToolResult.structured_contentwhen converting MCP tool outputs to JSON.Changes
file_searchto builtin MCP routing/type extraction.file_search_call.resultsbehind explicitinclude[]=file_search_call.results.include[]into streaming tool interception flow.fileId,file_name,fileName,id,name).attributesaliases →file_id) when missing.content[]formats (text,text.value, typedvalue) and ignored non-text typed nodes.attributes,additional_properties,vector_store_id) in parsed results.structured_contentover legacy text blocks.Tests
Added/updated focused coverage for:
test_should_include_file_search_results_only_when_explicitly_requestedtest_apply_file_search_include_filter_removes_results_when_not_includedtest_apply_file_search_include_filter_keeps_results_when_includedid/name,fileId/file_name/fileName)content[]text extraction and non-text filteringtest_call_result_to_json_prefers_structured_contenttest_call_result_to_json_falls_back_to_content_when_unstructuredTest Plan
Verified behavior
file_searchis now discovered as a builtin MCP-routable tool and mapped toBuiltinToolType::FileSearch.file_search_call.resultsis omitted unlessincludeexplicitly containsfile_search_call.results.file_search_call.resultsis preserved when explicitly requested.content[]text extraction.Checklist
cargo +nightly fmtpassescargo clippy --all-targets --all-features -- -D warningspassesSummary by CodeRabbit
New Features
Bug Fixes