mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
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.
This commit is contained in:
@@ -393,9 +393,13 @@ export class CursorProvider extends BaseProvider {
|
|||||||
let toolInput: unknown;
|
let toolInput: unknown;
|
||||||
|
|
||||||
if (toolCall.readToolCall) {
|
if (toolCall.readToolCall) {
|
||||||
|
// Skip if args not yet populated (partial streaming event)
|
||||||
|
if (!toolCall.readToolCall.args) return null;
|
||||||
toolName = 'Read';
|
toolName = 'Read';
|
||||||
toolInput = { file_path: toolCall.readToolCall.args.path };
|
toolInput = { file_path: toolCall.readToolCall.args.path };
|
||||||
} else if (toolCall.writeToolCall) {
|
} else if (toolCall.writeToolCall) {
|
||||||
|
// Skip if args not yet populated (partial streaming event)
|
||||||
|
if (!toolCall.writeToolCall.args) return null;
|
||||||
toolName = 'Write';
|
toolName = 'Write';
|
||||||
toolInput = {
|
toolInput = {
|
||||||
file_path: toolCall.writeToolCall.args.path,
|
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') {
|
if (toolEvent.subtype === 'completed') {
|
||||||
let resultContent = '';
|
let resultContent = '';
|
||||||
|
|
||||||
@@ -447,6 +452,12 @@ export class CursorProvider extends BaseProvider {
|
|||||||
message: {
|
message: {
|
||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: [
|
content: [
|
||||||
|
{
|
||||||
|
type: 'tool_use',
|
||||||
|
name: toolName,
|
||||||
|
tool_use_id: toolEvent.call_id,
|
||||||
|
input: toolInput,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'tool_result',
|
type: 'tool_result',
|
||||||
tool_use_id: toolEvent.call_id,
|
tool_use_id: toolEvent.call_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user