hotfix - streaming rd 2

This commit is contained in:
dal 2025-09-26 13:35:35 -06:00
parent 355149358f
commit d6cc1f38d1
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
1 changed files with 11 additions and 4 deletions

View File

@ -20,14 +20,21 @@ async function processDone(
state: DoneToolState,
toolCallId: string,
messageId: string,
_context: DoneToolContext
_context: DoneToolContext,
input: DoneToolInput
): Promise<DoneToolOutput> {
const output: DoneToolOutput = {
success: true,
};
// Update state with the full finalResponse from input to ensure completeness
const updatedState: DoneToolState = {
...state,
finalResponse: input.finalResponse,
};
// Create both the tool call and result messages to maintain proper ordering
const rawLlmMessage = createDoneToolRawLlmMessageEntry(state, toolCallId);
const rawLlmMessage = createDoneToolRawLlmMessageEntry(updatedState, toolCallId);
const rawToolResultEntry = createRawToolResultEntry(toolCallId, DONE_TOOL_NAME, output);
try {
@ -55,12 +62,12 @@ async function processDone(
// Factory function that creates the execute function with proper context typing
export function createDoneToolExecute(context: DoneToolContext, state: DoneToolState) {
return wrapTraced(
async (_input: DoneToolInput): Promise<DoneToolOutput> => {
async (input: DoneToolInput): Promise<DoneToolOutput> => {
if (!state.toolCallId) {
throw new Error('Tool call ID is required');
}
const result = await processDone(state, state.toolCallId, context.messageId, context);
const result = await processDone(state, state.toolCallId, context.messageId, context, input);
// Wait for all pending updates from delta/finish to complete before returning
await waitForPendingUpdates(context.messageId);