Skip to content

Conversation

francismiko
Copy link
Contributor

@francismiko francismiko commented Aug 29, 2025

  • Based on the original dispatchRunTools node, I created a new dispatchRunAgents node using a while loop approach, which will be used to replace the tools node with the agents node later.
  • plan agent / sub agent / context agent and other logic will be connected based on this branch
  • The /agent folder needs to be migrated later
Untitled diagram _ Mermaid Chart-2025-08-29-091224

…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.
Copy link

github-actions bot commented Aug 29, 2025

Preview mcp_server Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_mcp_server_c18d3668787105dcb326b0c844db2153ca72a8f4

Copy link

github-actions bot commented Aug 29, 2025

Preview sandbox Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_sandbox_c18d3668787105dcb326b0c844db2153ca72a8f4

Copy link

github-actions bot commented Aug 29, 2025

Preview fastgpt Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_c18d3668787105dcb326b0c844db2153ca72a8f4

const currToolsRunResponse: ToolRunResponseType = [];

// Interactive mode handling
if (currentInteractiveParams) {
Copy link
Collaborator

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> => {
Copy link
Collaborator

@c121914yu c121914yu Aug 30, 2025

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,返回结果给入口层。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于处理交互节点问题:agent 里处理交互节点,不涉及工作流运行,所以不需要什么 runtimeNodes 的。他只需要吧响应结果,拼接到 messages 里就好了。

@c121914yu c121914yu changed the base branch from main to test-agent September 1, 2025 03:48
@c121914yu c121914yu marked this pull request as ready for review September 1, 2025 13:18
Copy link
Contributor

gru-agent bot commented Sep 1, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail c18d366 🚫 Skipped No files need to be tested {"packages/global/core/workflow/constants.ts":"File path does not match include patterns.","packages/global/core/workflow/node/constant.ts":"File path does not match include patterns.","packages/service/core/workflow/dispatch/ai/agent/agentCall.ts":"File path does not match include patterns.","packages/service/core/workflow/dispatch/ai/agent/constants.ts":"File path does not match include patterns.","packages/service/core/workflow/dispatch/ai/agent/index.ts":"File path does not match include patterns.","packages/service/core/workflow/dispatch/ai/agent/type.d.ts":"File path does not match include patterns.","packages/service/core/workflow/dispatch/ai/agent/utils.ts":"File path does not match include patterns.","packages/service/core/workflow/dispatch/ai/tool/constants.ts":"File path does not match include patterns.","packages/service/core/workflow/dispatch/ai/tool/index.ts":"File path does not match include patterns.","packages/service/core/workflow/dispatch/a…

History Assignment

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

@c121914yu c121914yu merged commit 927af14 into labring:test-agent Sep 1, 2025
6 checks passed
c121914yu added a commit that referenced this pull request Sep 1, 2025
});
} catch (error) {
stringToolResponse = getErrText(error);
}
Copy link

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.

Fix in Cursor Fix in Web

@@ -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,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Undefined Node Type Causes React Flow Rendering Errors

The FlowNodeTypeEnum.toolCall node type is mapped to undefined in the nodeTypes object. This will cause runtime errors when React Flow attempts to render a toolCall node, as React cannot render undefined as a component.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants