-
Notifications
You must be signed in to change notification settings - Fork 6.6k
feat: use while loop to reconstruct the recursive agent new node #5562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use while loop to reconstruct the recursive agent new node #5562
Conversation
…lan parsing, state management and tool invocation
- Simplified the `runAgentCall` function by removing unnecessary complexity and restructuring the flow for better readability and maintainability. - Introduced helper functions to create tools from tool nodes and to prepare agent messages, enhancing modularity. - Removed the `utils.ts` file as its functions were integrated into the main logic, streamlining the codebase. - Updated the dispatch logic in `index.ts` to utilize the new helper functions and improve clarity. - Adjusted the handling of interactive modes and tool calls to ensure proper response formatting and error handling.
…emove the unused tool creation functions
Preview mcp_server Image:
|
Preview sandbox Image:
|
Preview fastgpt Image:
|
const currToolsRunResponse: ToolRunResponseType = []; | ||
|
||
// Interactive mode handling | ||
if (currentInteractiveParams) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interactive 不应该在循环内。应该在循环外,处理了交互,才会进入循环
toolMsgParams: ChatCompletionToolMessageParam; | ||
}[]; | ||
|
||
export const runAgentCall = async (props: DispatchAgentModuleProps): Promise<RunAgentResponse> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最好这个方法不要复制入口的参数,和工作流的耦合起来显得很复杂。需要哪些传入哪些即可。目的在于,下一个人来开发时候,不懂工作流代码也没事,知道 agent 这块就好了。
结构优化:
入口层:进行首轮 messages 的处理。传递必须参数到循环层。处理计费,和组合返回结果。
循环层:将交互结果写入 messages(如有)。根据传入的 messages 和参数 进行循环调用,反复拼接/压缩 messages,返回结果给入口层。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对于处理交互节点问题:agent 里处理交互节点,不涉及工作流运行,所以不需要什么 runtimeNodes 的。他只需要吧响应结果,拼接到 messages 里就好了。
…requestProps and workflowProps
…all and dispatchRunAgent
…questParams for clarity
… for improved response management
…gent to use direct properties
TestGru AssignmentSummary
Tip You can |
}); | ||
} catch (error) { | ||
stringToolResponse = getErrText(error); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Async Function Not Awaited Causes Promise Leakage
The handleToolResponse
function returns a Promise<string>
but isn't awaited. This assigns a Promise object to stringToolResponse
, causing downstream string operations like sliceStrStartEnd
and the tool response content to receive a Promise instead of the resolved string.
@@ -44,6 +44,7 @@ const nodeTypes: Record<FlowNodeTypeEnum, any> = { | |||
[FlowNodeTypeEnum.pluginOutput]: dynamic(() => import('./nodes/NodePluginIO/PluginOutput')), | |||
[FlowNodeTypeEnum.pluginModule]: NodeSimple, | |||
[FlowNodeTypeEnum.queryExtension]: NodeSimple, | |||
[FlowNodeTypeEnum.toolCall]: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dispatchRunTools
node, I created a newdispatchRunAgents
node using a while loop approach, which will be used to replace thetools
node with theagents
node later.plan agent / sub agent / context agent
and other logic will be connected based on this branch/agent
folder needs to be migrated later