@@ -11,6 +11,7 @@ import { OCX_REASONING_PREFIX } from "../responses/reasoning-envelope";
1111import { modelRecordValue } from "../reasoning-effort" ;
1212import type { TranslatorBudget } from "../lib/translator-budget" ;
1313import { rewriteRoutedCustomToolsForUpstream } from "../responses/custom-tool-compat" ;
14+ import { rewriteRoutedToolSearchForUpstream } from "../responses/tool-search-compat" ;
1415import { openaiResponsesUrl } from "./openai-responses-url" ;
1516import {
1617 createAdapterTierMetadata ,
@@ -1468,6 +1469,7 @@ export function createResponsesPassthroughAdapter(provider: OcxProviderConfig):
14681469
14691470 const forward = provider . authMode === "forward" ;
14701471 let convertedRoutedCustomToolNames : Set < string > | undefined ;
1472+ let convertedRoutedToolSearchNames : Set < string > | undefined ;
14711473 const unexpandedMiss = ! ! parsed . previousResponseId && parsed . _previousResponseInputExpanded !== true ;
14721474 let outBody = stripPreviousResponseId (
14731475 parsed . _rawBody ,
@@ -1522,6 +1524,13 @@ export function createResponsesPassthroughAdapter(provider: OcxProviderConfig):
15221524 outBody = rewritten . body ;
15231525 convertedRoutedCustomToolNames = rewritten . names ;
15241526 }
1527+ if ( ! isCanonicalOpenAiForwardProvider ( provider ) ) {
1528+ // Run after custom-tool lowering so the search compatibility layer can choose a
1529+ // collision-free public function name against the final routed function catalog.
1530+ const rewritten = rewriteRoutedToolSearchForUpstream ( outBody ) ;
1531+ outBody = rewritten . body ;
1532+ convertedRoutedToolSearchNames = rewritten . names ;
1533+ }
15251534 const sanitizedBody = normalizeToolSchemas ( stripSparkCompatibility ( stripUnsupportedReasoningParams ( stripItemIdsWhenUnstored ( stripInvalidItemIds ( stripUnsupportedHostedTools ( sanitizeReasoningInputContent ( scrubOcxCompactionItems ( outBody ) , { preserveRawReasoningContent : provider . preserveResponsesReasoningContent === true } ) ) ) ) ) ) ) ;
15261535 const finalBody = stripDisabledReasoningSummaries (
15271536 normalizeConfiguredReasoningSummaryDelivery ( sanitizedBody , provider , parsed . modelId ) ,
@@ -1549,6 +1558,7 @@ export function createResponsesPassthroughAdapter(provider: OcxProviderConfig):
15491558 body,
15501559 releaseBodyObservation,
15511560 ...( convertedRoutedCustomToolNames ? { convertedRoutedCustomToolNames } : { } ) ,
1561+ ...( convertedRoutedToolSearchNames ? { convertedRoutedToolSearchNames } : { } ) ,
15521562 ...( tierLog ? { tierLog } : { } ) ,
15531563 } ;
15541564 } ,
0 commit comments