feat(agent): Add signal support for cancellation in agent workflows

This commit is contained in:
Willie Zutz 2025-06-17 00:14:22 -06:00
parent 765d084b44
commit 74c3934aa5
2 changed files with 4 additions and 1 deletions

View file

@ -99,6 +99,7 @@ export class AgentSearch {
const result = await workflow.invoke(initialState, {
configurable: { thread_id: `agent_search_${Date.now()}` },
recursionLimit: 20,
signal: this.signal,
});
return result;

View file

@ -101,6 +101,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
llm: BaseChatModel,
systemInstructions: string,
emitter: eventEmitter,
signal: AbortSignal,
) {
(llm as unknown as ChatOpenAI).temperature = 0;
@ -238,7 +239,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
</text>
Make sure to answer the query in the summary.
`); //TODO: Pass signal for cancellation
`, { signal });
const document = new Document({
pageContent: res.content as string,
@ -340,6 +341,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
llm,
systemInstructions,
emitter,
signal,
);
var date = formatDateForLLM();