Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions task-runner/src/orchestratorExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,21 @@ export async function processOrchestratorRun(run: TeamRun): Promise<void> {

let totalTokens = 0;
let totalCost = 0;
let teamData: { name: string; config: OrchestratorConfig; mode: string; output_route_ids: string[] | null } | null = null;

try {
// 1. Fetch team to get config
const teamResponse = await supabase
.from('teams')
.select('config, mode')
.select('name, config, mode, output_route_ids')
.eq('id', run.team_id)
.single();

if (teamResponse.error || !teamResponse.data) {
throw new Error(`Failed to load team: ${teamResponse.error?.message ?? 'not found'}`);
}

const teamData = teamResponse.data as { config: OrchestratorConfig; mode: string };
teamData = teamResponse.data as { name: string; config: OrchestratorConfig; mode: string; output_route_ids: string[] | null };
const config = teamData.config;

if (!config.brain_agent_id || !config.worker_agent_ids?.length) {
Expand Down Expand Up @@ -313,9 +314,10 @@ export async function processOrchestratorRun(run: TeamRun): Promise<void> {

// Fire team_run.completed webhook (fire-and-forget)
void dispatchTeamRunWebhooks(
{ id: run.id, team_id: run.team_id, workspace_id: run.workspace_id, status: 'completed', input_task: run.input_task },
`Orchestrator Team ${run.team_id}`,
{ id: run.id, team_id: run.team_id, workspace_id: run.workspace_id, status: 'completed', input_task: run.input_task, output: runOutput ?? undefined },
teamData.name,
'team_run.completed',
teamData.output_route_ids,
);

} catch (error: unknown) {
Expand All @@ -336,8 +338,9 @@ export async function processOrchestratorRun(run: TeamRun): Promise<void> {
// Fire team_run.failed webhook (fire-and-forget)
void dispatchTeamRunWebhooks(
{ id: run.id, team_id: run.team_id, workspace_id: run.workspace_id, status: 'failed', input_task: run.input_task, error_message: errMsg },
`Orchestrator Team ${run.team_id}`,
teamData?.name ?? `Orchestrator Team ${run.team_id}`,
'team_run.failed',
teamData?.output_route_ids ?? null,
);
}
}
Expand Down
Loading