feat(agent): Refactor agent architecture to enhance content routing and file search capabilities

- Introduced ContentRouterAgent to determine the next step in information gathering (file search, web search, or analysis) based on task relevance and focus mode.
- Added FileSearchAgent to handle searching through attached files, processing file content into searchable documents.
- Updated SynthesizerAgent to utilize a prompt template for generating comprehensive responses based on context and user queries.
- Enhanced TaskManagerAgent to consider file context when creating tasks.
- Improved AnalyzerAgent to assess the sufficiency of context, including file and web documents.
- Implemented utility functions for processing files and ranking documents based on similarity to queries.
- Updated prompts to include new instructions for handling file context and routing decisions.
- Adjusted agent search workflow to integrate new agents and support file handling.
This commit is contained in:
Willie Zutz 2025-06-28 14:48:08 -06:00
parent 7b47d3dacb
commit de3d26fb15
20 changed files with 1044 additions and 96 deletions

View file

@ -74,7 +74,7 @@ export class TaskManagerAgent {
});
return new Command({
goto: 'web_search',
goto: 'content_router',
update: {
messages: [
new AIMessage(
@ -127,8 +127,15 @@ export class TaskManagerAgent {
});
const template = PromptTemplate.fromTemplate(taskBreakdownPrompt);
// Create file context information
const fileContext = state.fileIds && state.fileIds.length > 0
? `Files attached: ${state.fileIds.length} file(s) are available for analysis. Consider creating tasks that can leverage these attached files when appropriate.`
: 'No files attached: Focus on tasks that can be answered through web research or general knowledge.';
const prompt = await template.format({
systemInstructions: this.systemInstructions,
fileContext: fileContext,
query: state.query,
});
@ -182,7 +189,7 @@ export class TaskManagerAgent {
: `Question broken down into ${taskLines.length} focused tasks for parallel processing`;
return new Command({
goto: 'web_search', // Next step would typically be web search for each task
goto: 'content_router', // Route to content router to decide between file search, web search, or analysis
update: {
messages: [new AIMessage(responseMessage)],
tasks: taskLines,
@ -197,7 +204,7 @@ export class TaskManagerAgent {
);
return new Command({
goto: 'web_search', // Fallback to web search with original query
goto: 'content_router', // Fallback to content router with original query
update: {
messages: [errorMessage],
tasks: [state.query], // Use original query as single task