@@ -23,7 +23,6 @@ import {
2323import { createBridgeCloseController } from "./bridge-close-controller" ;
2424
2525const MCP_TOOL_BATCH_WINDOW_MS = 150 ;
26- const MCP_TOOL_METADATA_GRACE_MS = 1_500 ;
2726
2827interface CollectedResponse {
2928 text : string ;
@@ -90,8 +89,6 @@ async function collectFullResponse(
9089 let endStreamError : Error | null = null ;
9190 const pendingToolCalls : OpenAIToolCall [ ] = [ ] ;
9291 let toolCallEndTimer : NodeJS . Timeout | undefined ;
93- const announcedToolCallIds = new Set < string > ( ) ;
94- let toolCallMetadataDeadlineMs = 0 ;
9592
9693 const { bridge, heartbeatTimer } = await startBridge (
9794 accessToken ,
@@ -103,44 +100,10 @@ async function collectFullResponse(
103100 clearTimeout ( toolCallEndTimer ) ;
104101 toolCallEndTimer = undefined ;
105102 } ;
106- const getMissingAnnouncedToolCallIds = ( ) => {
107- const pendingExecIds = new Set ( pendingToolCalls . map ( ( call ) => call . id ) ) ;
108- return [ ...announcedToolCallIds ] . filter (
109- ( toolCallId ) => ! pendingExecIds . has ( toolCallId ) ,
110- ) ;
111- } ;
112103 const scheduleToolCallBridgeEnd = ( ) => {
113104 stopToolCallEndTimer ( ) ;
114105 toolCallEndTimer = setTimeout (
115- ( ) => {
116- const missingAnnouncedToolCallIds = getMissingAnnouncedToolCallIds ( ) ;
117- if (
118- missingAnnouncedToolCallIds . length > 0 &&
119- Date . now ( ) < toolCallMetadataDeadlineMs
120- ) {
121- scheduleToolCallBridgeEnd ( ) ;
122- return ;
123- }
124-
125- if ( missingAnnouncedToolCallIds . length > 0 ) {
126- endStreamError = new Error (
127- `Cursor announced MCP tool calls without matching exec metadata: ${ missingAnnouncedToolCallIds . join ( ", " ) } ` ,
128- ) ;
129- logPluginError (
130- "Aborting non-streaming Cursor response because announced MCP tool calls never received exec metadata" ,
131- {
132- modelId,
133- convKey,
134- pendingExecToolCallIds : pendingToolCalls . map ( ( call ) => call . id ) ,
135- missingAnnouncedToolCallIds,
136- } ,
137- ) ;
138- scheduleBridgeEnd ( bridge ) ;
139- return ;
140- }
141-
142- scheduleBridgeEnd ( bridge ) ;
143- } ,
106+ ( ) => scheduleBridgeEnd ( bridge ) ,
144107 MCP_TOOL_BATCH_WINDOW_MS ,
145108 ) ;
146109 } ;
@@ -173,7 +136,6 @@ async function collectFullResponse(
173136 fullText += content ;
174137 } ,
175138 ( exec ) => {
176- announcedToolCallIds . add ( exec . toolCallId ) ;
177139 const toolCall = {
178140 id : exec . toolCallId ,
179141 type : "function" as const ,
@@ -190,21 +152,9 @@ async function collectFullResponse(
190152 } else {
191153 pendingToolCalls . push ( toolCall ) ;
192154 }
193- toolCallMetadataDeadlineMs =
194- Date . now ( ) + MCP_TOOL_METADATA_GRACE_MS ;
195155 scheduleToolCallBridgeEnd ( ) ;
196156 } ,
197- ( info : McpToolCallUpdateInfo ) => {
198- if ( info . updateCase === "toolCallCompleted" ) {
199- announcedToolCallIds . delete ( info . toolCallId ) ;
200- } else {
201- announcedToolCallIds . add ( info . toolCallId ) ;
202- }
203-
204- if ( pendingToolCalls . length > 0 ) {
205- scheduleToolCallBridgeEnd ( ) ;
206- }
207- } ,
157+ ( _info : McpToolCallUpdateInfo ) => { } ,
208158 ( checkpointBytes ) => {
209159 updateConversationCheckpoint ( convKey , checkpointBytes ) ;
210160 bridgeCloseController . noteCheckpoint ( ) ;
0 commit comments