Merge pull request #1202 from buster-so/dallin-bus-1984-final-response-still-being-cut-off

Fix: wait for deltas to finish then write
This commit is contained in:
dal 2025-09-29 11:19:37 -06:00 committed by GitHub
commit 2e8ed0ecd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 3 deletions

View File

@ -75,11 +75,13 @@ export function createDoneToolExecute(context: DoneToolContext, state: DoneToolS
throw new Error('Tool call ID is required'); throw new Error('Tool call ID is required');
} }
const result = await processDone(state, state.toolCallId, context.messageId, context, input); // CRITICAL: Wait for ALL pending updates from delta/finish to complete FIRST
// This ensures execute's update is always the last one in the queue
// Wait for all pending updates from delta/finish to complete before returning
await waitForPendingUpdates(context.messageId); await waitForPendingUpdates(context.messageId);
// Now do the final authoritative update with the complete input
const result = await processDone(state, state.toolCallId, context.messageId, context, input);
cleanupState(state); cleanupState(state);
return result; return result;
}, },