This commit is contained in:
dal 2025-10-01 20:45:03 -06:00
parent 5000e8aca3
commit fe7af072cf
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
3 changed files with 33 additions and 33 deletions

View File

@ -127,10 +127,10 @@ export function createAnalystAgent(analystAgentOptions: AnalystAgentOptions) {
const docsSystemMessage = docsContent const docsSystemMessage = docsContent
? ({ ? ({
role: 'system', role: 'system',
content: `<data_catalog_docs>\n${docsContent}\n</data_catalog_docs>`, content: `<data_catalog_docs>\n${docsContent}\n</data_catalog_docs>`,
providerOptions: DEFAULT_ANTHROPIC_OPTIONS, providerOptions: DEFAULT_ANTHROPIC_OPTIONS,
} as ModelMessage) } as ModelMessage)
: null; : null;
async function stream({ messages }: AnalystStreamOptions) { async function stream({ messages }: AnalystStreamOptions) {
@ -187,19 +187,19 @@ export function createAnalystAgent(analystAgentOptions: AnalystAgentOptions) {
// Create analyst instructions system message with proper escaping // Create analyst instructions system message with proper escaping
const analystInstructionsMessage = analystInstructions const analystInstructionsMessage = analystInstructions
? ({ ? ({
role: 'system', role: 'system',
content: `<organization_instructions>\n${analystInstructions}\n</organization_instructions>`, content: `<organization_instructions>\n${analystInstructions}\n</organization_instructions>`,
providerOptions: DEFAULT_ANTHROPIC_OPTIONS, providerOptions: DEFAULT_ANTHROPIC_OPTIONS,
} as ModelMessage) } as ModelMessage)
: null; : null;
// Create user personalization system message // Create user personalization system message
const userPersonalizationSystemMessage = userPersonalizationMessageContent const userPersonalizationSystemMessage = userPersonalizationMessageContent
? ({ ? ({
role: 'system', role: 'system',
content: userPersonalizationMessageContent, content: userPersonalizationMessageContent,
providerOptions: DEFAULT_ANTHROPIC_OPTIONS, providerOptions: DEFAULT_ANTHROPIC_OPTIONS,
} as ModelMessage) } as ModelMessage)
: null; : null;
return wrapTraced( return wrapTraced(

View File

@ -63,7 +63,7 @@ describe('Analyst Agent Instructions', () => {
expect(result).toContain('<intro>'); expect(result).toContain('<intro>');
expect(result).toContain('<sql_best_practices>'); expect(result).toContain('<sql_best_practices>');
expect(result).toContain('<visualization_and_charting_guidelines>'); expect(result).toContain('<visualization_and_charting_guidelines>');
expect(result).toContain('You are a Buster'); expect(result).toContain('You are an agent');
}); });
it('should throw an error for empty SQL dialect guidance', () => { it('should throw an error for empty SQL dialect guidance', () => {

View File

@ -123,27 +123,27 @@ export async function runAnalystWorkflow(
// earlyTermination: thinkAndPrepAgentStepResults.earlyTermination, // earlyTermination: thinkAndPrepAgentStepResults.earlyTermination,
// }); // });
analystAgentStepResults = await runAnalystAgentStep({ analystAgentStepResults = await runAnalystAgentStep({
options: { options: {
messageId: input.messageId, messageId: input.messageId,
chatId: input.chatId, chatId: input.chatId,
organizationId: input.organizationId, organizationId: input.organizationId,
dataSourceId: input.dataSourceId, dataSourceId: input.dataSourceId,
dataSourceSyntax: input.dataSourceSyntax, dataSourceSyntax: input.dataSourceSyntax,
userId: input.userId, userId: input.userId,
datasets: input.datasets, datasets: input.datasets,
workflowStartTime, workflowStartTime,
analysisMode, analysisMode,
analystInstructions, analystInstructions,
organizationDocs, organizationDocs,
userPersonalizationMessageContent, userPersonalizationMessageContent,
}, },
streamOptions: { streamOptions: {
messages, messages,
}, },
}); });
messages.push(...analystAgentStepResults.messages); messages.push(...analystAgentStepResults.messages);
// } else { // } else {
// console.info('[runAnalystWorkflow] DEBUG: SKIPPING analyst agent due to early termination', { // console.info('[runAnalystWorkflow] DEBUG: SKIPPING analyst agent due to early termination', {
// workflowId, // workflowId,