From 84445efa60a98671cd25b061997c038d3715ef33 Mon Sep 17 00:00:00 2001 From: dal Date: Thu, 21 Aug 2025 08:58:43 -0600 Subject: [PATCH] tests passing --- .../analyst-agent-task/analyst-agent-task.ts | 21 +++++++------------ .../strategies/re-ask-strategy.test.ts | 6 +++--- .../structured-output-strategy.test.ts | 1 + 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/apps/trigger/src/tasks/analyst-agent-task/analyst-agent-task.ts b/apps/trigger/src/tasks/analyst-agent-task/analyst-agent-task.ts index ac738bfa8..ce1d8fd2c 100644 --- a/apps/trigger/src/tasks/analyst-agent-task/analyst-agent-task.ts +++ b/apps/trigger/src/tasks/analyst-agent-task/analyst-agent-task.ts @@ -307,19 +307,14 @@ export const analystAgentTask: ReturnType< const braintrustMetadataPromise = getBraintrustMetadata({ messageId: payload.message_id }); // Wait for all operations to complete - const [ - messageContext, - conversationHistory, - dataSource, - datasets, - braintrustMetadata, - ] = await Promise.all([ - messageContextPromise, - conversationHistoryPromise, - dataSourcePromise, - datasetsPromise, - braintrustMetadataPromise, - ]); + const [messageContext, conversationHistory, dataSource, datasets, braintrustMetadata] = + await Promise.all([ + messageContextPromise, + conversationHistoryPromise, + dataSourcePromise, + datasetsPromise, + braintrustMetadataPromise, + ]); const dataLoadEnd = Date.now(); const dataLoadTime = dataLoadEnd - dataLoadStart; diff --git a/packages/ai/src/utils/tool-call-repair/strategies/re-ask-strategy.test.ts b/packages/ai/src/utils/tool-call-repair/strategies/re-ask-strategy.test.ts index 045e0b6de..ad24b9037 100644 --- a/packages/ai/src/utils/tool-call-repair/strategies/re-ask-strategy.test.ts +++ b/packages/ai/src/utils/tool-call-repair/strategies/re-ask-strategy.test.ts @@ -89,13 +89,13 @@ describe('re-ask-strategy', () => { input: JSON.stringify(correctedToolCall.input), // FIXED: Now returns stringified input }); - // Verify the tool input is properly formatted as a string in the messages + // Verify the tool input is properly formatted as an object in the messages const calls = mockGenerateText.mock.calls[0]; const messages = calls?.[0]?.messages; const assistantMessage = messages?.find((m: any) => m.role === 'assistant'); const content = assistantMessage?.content?.[0]; if (content && typeof content === 'object' && 'input' in content) { - expect(content.input).toEqual(JSON.stringify({ param: 'value' })); + expect(content.input).toEqual({ param: 'value' }); } expect(mockGenerateText).toHaveBeenCalledWith( @@ -338,7 +338,7 @@ describe('re-ask-strategy', () => { const assistantMessage = messages?.find((m: any) => m.role === 'assistant'); const content = assistantMessage?.content?.[0]; if (content && typeof content === 'object' && 'input' in content) { - expect(content.input).toEqual('{"already":"valid"}'); // Now expects stringified JSON + expect(content.input).toEqual({ already: 'valid' }); // Expects parsed object } }); }); diff --git a/packages/ai/src/utils/tool-call-repair/strategies/structured-output-strategy.test.ts b/packages/ai/src/utils/tool-call-repair/strategies/structured-output-strategy.test.ts index 106e4af8c..d77a1e37d 100644 --- a/packages/ai/src/utils/tool-call-repair/strategies/structured-output-strategy.test.ts +++ b/packages/ai/src/utils/tool-call-repair/strategies/structured-output-strategy.test.ts @@ -90,6 +90,7 @@ describe('structured-output-strategy', () => { model: 'mock-model', schema: tool?.inputSchema, prompt: expect.stringContaining('Fix these tool arguments'), + mode: 'json', }); });