tests passing

This commit is contained in:
dal 2025-08-21 08:58:43 -06:00
parent 5838285c81
commit 84445efa60
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
3 changed files with 12 additions and 16 deletions

View File

@ -307,19 +307,14 @@ export const analystAgentTask: ReturnType<
const braintrustMetadataPromise = getBraintrustMetadata({ messageId: payload.message_id }); const braintrustMetadataPromise = getBraintrustMetadata({ messageId: payload.message_id });
// Wait for all operations to complete // Wait for all operations to complete
const [ const [messageContext, conversationHistory, dataSource, datasets, braintrustMetadata] =
messageContext, await Promise.all([
conversationHistory, messageContextPromise,
dataSource, conversationHistoryPromise,
datasets, dataSourcePromise,
braintrustMetadata, datasetsPromise,
] = await Promise.all([ braintrustMetadataPromise,
messageContextPromise, ]);
conversationHistoryPromise,
dataSourcePromise,
datasetsPromise,
braintrustMetadataPromise,
]);
const dataLoadEnd = Date.now(); const dataLoadEnd = Date.now();
const dataLoadTime = dataLoadEnd - dataLoadStart; const dataLoadTime = dataLoadEnd - dataLoadStart;

View File

@ -89,13 +89,13 @@ describe('re-ask-strategy', () => {
input: JSON.stringify(correctedToolCall.input), // FIXED: Now returns stringified input 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 calls = mockGenerateText.mock.calls[0];
const messages = calls?.[0]?.messages; const messages = calls?.[0]?.messages;
const assistantMessage = messages?.find((m: any) => m.role === 'assistant'); const assistantMessage = messages?.find((m: any) => m.role === 'assistant');
const content = assistantMessage?.content?.[0]; const content = assistantMessage?.content?.[0];
if (content && typeof content === 'object' && 'input' in content) { 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( expect(mockGenerateText).toHaveBeenCalledWith(
@ -338,7 +338,7 @@ describe('re-ask-strategy', () => {
const assistantMessage = messages?.find((m: any) => m.role === 'assistant'); const assistantMessage = messages?.find((m: any) => m.role === 'assistant');
const content = assistantMessage?.content?.[0]; const content = assistantMessage?.content?.[0];
if (content && typeof content === 'object' && 'input' in content) { 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
} }
}); });
}); });

View File

@ -90,6 +90,7 @@ describe('structured-output-strategy', () => {
model: 'mock-model', model: 'mock-model',
schema: tool?.inputSchema, schema: tool?.inputSchema,
prompt: expect.stringContaining('Fix these tool arguments'), prompt: expect.stringContaining('Fix these tool arguments'),
mode: 'json',
}); });
}); });