feat(agent): Split agents into maintainable chunks

This commit is contained in:
Willie Zutz 2025-06-15 11:53:00 -06:00
parent 09799a880b
commit df1a8b6cd2
6 changed files with 678 additions and 586 deletions

View file

@ -0,0 +1,41 @@
import { BaseMessage } from '@langchain/core/messages';
import { Annotation, END } from '@langchain/langgraph';
import { Document } from 'langchain/document';
/**
* State interface for the agent supervisor workflow
*/
export const AgentState = Annotation.Root({
messages: Annotation<BaseMessage[]>({
reducer: (x, y) => x.concat(y),
default: () => [],
}),
query: Annotation<string>({
reducer: (x, y) => y ?? x,
default: () => '',
}),
relevantDocuments: Annotation<Document[]>({
reducer: (x, y) => x.concat(y),
default: () => [],
}),
bannedUrls: Annotation<string[]>({
reducer: (x, y) => x.concat(y),
default: () => [],
}),
searchInstructionHistory: Annotation<string[]>({
reducer: (x, y) => x.concat(y),
default: () => [],
}),
searchInstructions: Annotation<string>({
reducer: (x, y) => y ?? x,
default: () => '',
}),
next: Annotation<string>({
reducer: (x, y) => y ?? x ?? END,
default: () => END,
}),
analysis: Annotation<string>({
reducer: (x, y) => y ?? x,
default: () => '',
}),
});