mirror of https://github.com/buster-so/buster.git
Enhance analyst agent task by integrating message post-processing functionality. Updated logging configuration in integration tests to use environment variable for project name.
This commit is contained in:
parent
51c85c4384
commit
2e4791158b
|
@ -1,4 +1,4 @@
|
|||
import { logger, schemaTask } from '@trigger.dev/sdk';
|
||||
import { logger, schemaTask, tasks } from '@trigger.dev/sdk/v3';
|
||||
import { initLogger, wrapTraced } from 'braintrust';
|
||||
import { AnalystAgentTaskInputSchema, type AnalystAgentTaskOutput } from './types';
|
||||
|
||||
|
@ -19,6 +19,8 @@ import { RuntimeContext } from '@mastra/core/runtime-context';
|
|||
// Database helper output types
|
||||
import type { MessageContextOutput, OrganizationDataSourceOutput } from '@buster/database';
|
||||
|
||||
import type { messagePostProcessingTask } from '../message-post-processing/message-post-processing';
|
||||
|
||||
/**
|
||||
* Task 3: Setup runtime context from Task 2 database helper outputs
|
||||
* Uses individual helper results to populate Mastra RuntimeContext
|
||||
|
@ -351,7 +353,7 @@ export const analystAgentTask: ReturnType<
|
|||
dataSourceId: dataSource.dataSourceId,
|
||||
dataSourceSyntax: dataSource.dataSourceSyntax,
|
||||
dashboardFilesCount: dashboardFiles.length,
|
||||
dashboardFiles: dashboardFiles.map(d => ({
|
||||
dashboardFiles: dashboardFiles.map((d) => ({
|
||||
id: d.id,
|
||||
name: d.name,
|
||||
versionNumber: d.versionNumber,
|
||||
|
@ -476,6 +478,19 @@ export const analystAgentTask: ReturnType<
|
|||
},
|
||||
});
|
||||
|
||||
// Fire off message post-processing task (fire-and-forget)
|
||||
tasks
|
||||
.trigger<typeof messagePostProcessingTask>('message-post-processing', {
|
||||
messageId: payload.message_id,
|
||||
})
|
||||
.catch((error) => {
|
||||
// Log error but don't fail the current task
|
||||
logger.error('Failed to trigger message post-processing task', {
|
||||
messageId: payload.message_id,
|
||||
error: error instanceof Error ? error.message : 'Unknown error',
|
||||
});
|
||||
});
|
||||
|
||||
// Allow Braintrust a brief moment to clean up its trace, but don't block unnecessarily
|
||||
// Use a much shorter timeout with a race condition to avoid excessive delays
|
||||
await Promise.race([
|
||||
|
|
|
@ -41,7 +41,7 @@ describe('Analyst Agent Task Integration Tests', () => {
|
|||
// Initialize Braintrust logging for observability
|
||||
initLogger({
|
||||
apiKey: process.env.BRAINTRUST_KEY,
|
||||
projectName: 'ANALYST-AGENT-TASK-INTEGRATION',
|
||||
projectName: process.env.ENVIRONMENT || 'development',
|
||||
});
|
||||
|
||||
// Verify required environment variables
|
||||
|
|
Loading…
Reference in New Issue