feat(rah-light): remove agent delegation system

- Delete src/services/agents/delegation.ts (AgentDelegationService)
- Delete app/api/rah/delegations/ directory (all routes)
- Delete src/components/agents/DelegationIndicator.tsx
- Update workflowExecutor.ts to work without delegation streaming
- Update executeWorkflow.ts tool to execute workflows directly
- Update quickAdd.ts to execute directly without delegation tracking
- Add stub AgentDelegation types to UI components for compatibility
- Add stub voice hooks to RAHChat.tsx (will be removed in story 2)

Files deleted:
- src/services/agents/delegation.ts
- app/api/rah/delegations/route.ts
- app/api/rah/delegations/stream/route.ts
- app/api/rah/delegations/[sessionId]/route.ts
- app/api/rah/delegations/[sessionId]/summary/route.ts
- src/components/agents/DelegationIndicator.tsx

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
“BeeRad”
2026-01-29 15:11:15 +11:00
co-authored by Claude Opus 4.5
parent 08012a8e5a
commit 6b7bb5a5f9
19 changed files with 234 additions and 819 deletions
+5 -12
View File
@@ -1,11 +1,10 @@
import { tool } from 'ai';
import { z } from 'zod';
import { AgentDelegationService } from '@/services/agents/delegation';
import { WorkflowExecutor } from '@/services/agents/workflowExecutor';
import { RequestContext } from '@/services/context/requestContext';
export const delegateToWiseRAHTool = tool({
description: 'Delegate complex workflows to wise ra-h (GPT-5)',
description: 'Delegate complex workflows to workflow executor',
inputSchema: z.object({
task: z.string().describe('Complex workflow description: what needs to be planned and executed'),
context: z.array(z.string()).max(8).default([]).describe('Optional context: node IDs, URLs, or key information the planner needs'),
@@ -17,16 +16,10 @@ export const delegateToWiseRAHTool = tool({
const requestContext = RequestContext.get();
console.log('[delegateToWiseRAH] Current traceId:', requestContext.traceId);
const delegation = AgentDelegationService.createDelegation({
task,
context,
expectedOutcome,
agentType: 'wise-rah',
supabaseToken: null,
});
const sessionId = `workflow_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
const execution = await WorkflowExecutor.execute({
sessionId: delegation.sessionId,
sessionId,
task,
context,
expectedOutcome,
@@ -37,7 +30,7 @@ export const delegateToWiseRAHTool = tool({
});
// Return a simple string that Claude can directly use in conversation
const summary = execution?.summary || 'Wise ra-h delegated but no summary returned.';
return `Wise ra-h (session ${delegation.sessionId.split('_').pop()}) completed the workflow:\n\n${summary}`;
const summary = execution?.summary || 'Workflow completed but no summary returned.';
return `Workflow (session ${sessionId.split('_').pop()}) completed:\n\n${summary}`;
},
});
+26 -29
View File
@@ -2,7 +2,6 @@ import { tool } from 'ai';
import { z } from 'zod';
import { WorkflowRegistry } from '@/services/workflows/registry';
import { getSQLiteClient } from '@/services/database/sqlite-client';
import { AgentDelegationService } from '@/services/agents/delegation';
import { WorkflowExecutor } from '@/services/agents/workflowExecutor';
import { RequestContext } from '@/services/context/requestContext';
import { getAutoContextSummaries } from '@/services/context/autoContext';
@@ -92,39 +91,37 @@ ${workflow.instructions}
${nodeId ? `Target Node ID: ${nodeId}` : 'No specific node targeted (general workflow)'}`;
// 5. Delegate to wise ra-h oracle with workflow metadata
// 5. Execute workflow directly
const requestContext = RequestContext.get();
console.log('[executeWorkflowTool] Current traceId:', requestContext.traceId);
const delegation = AgentDelegationService.createDelegation({
task,
context: contextLines,
expectedOutcome: workflow.expectedOutcome,
agentType: 'wise-rah',
supabaseToken: null,
});
const sessionId = `workflow_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
// Fire-and-forget execution so main ra-h stays responsive while workflow runs
void WorkflowExecutor.execute({
sessionId: delegation.sessionId,
task,
context: contextLines,
expectedOutcome: workflow.expectedOutcome,
traceId: requestContext.traceId,
parentChatId: requestContext.parentChatId,
workflowKey,
workflowNodeId: nodeId,
}).catch((error) => {
console.error('[executeWorkflowTool] Wise ra-h delegation failed', error);
});
try {
const result = await WorkflowExecutor.execute({
sessionId,
task,
context: contextLines,
expectedOutcome: workflow.expectedOutcome,
traceId: requestContext.traceId,
parentChatId: requestContext.parentChatId,
workflowKey,
workflowNodeId: nodeId,
});
RequestContext.set({ workflowKey: undefined, workflowNodeId: undefined });
RequestContext.set({ workflowKey: undefined, workflowNodeId: undefined });
const shortSessionId = delegation.sessionId.split('_').pop();
const workflowLabel = workflow.displayName || workflowKey;
return [
`Delegated **${workflowLabel}** to wise ra-h (session ${shortSessionId}).`,
'Keep working here—wise ra-h will stream every step inside its tab and post the final summary when complete.',
].join('\n');
const workflowLabel = workflow.displayName || workflowKey;
return {
success: true,
message: `Workflow **${workflowLabel}** completed.`,
summary: result.summary,
};
} catch (error) {
console.error('[executeWorkflowTool] Workflow execution failed', error);
RequestContext.set({ workflowKey: undefined, workflowNodeId: undefined });
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
return { success: false, error: `Workflow execution failed: ${errorMessage}` };
}
},
});