From 3e8d2d73d514ebad064d28ba5b0ed2da62c9ba12 Mon Sep 17 00:00:00 2001 From: Shirone Date: Sun, 28 Dec 2025 11:26:34 +0100 Subject: [PATCH] feat: Enhance tool event handling in CursorProvider - Added checks to skip processing for partial streaming events when tool call arguments are not yet populated. - Updated the event emission logic to include both tool_use and tool_result for completed events, ensuring the UI reflects all tool calls accurately even if the 'started' event is skipped. --- apps/server/src/providers/cursor-provider.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/server/src/providers/cursor-provider.ts b/apps/server/src/providers/cursor-provider.ts index fd3e5408..af50af7c 100644 --- a/apps/server/src/providers/cursor-provider.ts +++ b/apps/server/src/providers/cursor-provider.ts @@ -393,9 +393,13 @@ export class CursorProvider extends BaseProvider { let toolInput: unknown; if (toolCall.readToolCall) { + // Skip if args not yet populated (partial streaming event) + if (!toolCall.readToolCall.args) return null; toolName = 'Read'; toolInput = { file_path: toolCall.readToolCall.args.path }; } else if (toolCall.writeToolCall) { + // Skip if args not yet populated (partial streaming event) + if (!toolCall.writeToolCall.args) return null; toolName = 'Write'; toolInput = { file_path: toolCall.writeToolCall.args.path, @@ -431,7 +435,8 @@ export class CursorProvider extends BaseProvider { }; } - // For completed events, emit tool_result + // For completed events, emit both tool_use and tool_result + // This ensures the UI shows the tool call even if 'started' was skipped if (toolEvent.subtype === 'completed') { let resultContent = ''; @@ -447,6 +452,12 @@ export class CursorProvider extends BaseProvider { message: { role: 'assistant', content: [ + { + type: 'tool_use', + name: toolName, + tool_use_id: toolEvent.call_id, + input: toolInput, + }, { type: 'tool_result', tool_use_id: toolEvent.call_id,