diff --git a/web/app/components/workflow/nodes/agent/use-config.ts b/web/app/components/workflow/nodes/agent/use-config.ts index 9cd3d12d87..fcd1bed5aa 100644 --- a/web/app/components/workflow/nodes/agent/use-config.ts +++ b/web/app/components/workflow/nodes/agent/use-config.ts @@ -1,6 +1,7 @@ import { useStrategyProviderDetail } from '@/service/use-strategy' import useNodeCrud from '../_base/hooks/use-node-crud' import useVarList from '../_base/hooks/use-var-list' +import useOneStepRun from '../_base/hooks/use-one-step-run' import type { AgentNodeType } from './types' import { useNodesReadOnly, @@ -19,6 +20,27 @@ const useConfig = (id: string, payload: AgentNodeType) => { const strategyProvider = useStrategyProviderDetail( inputs.agent_strategy_provider_name || '', ) + + // single run + const agentInputKey = `${id}.input_selector` + const { + isShowSingleRun, + showSingleRun, + hideSingleRun, + toVarInputs, + runningStatus, + handleRun, + handleStop, + runInputData, + setRunInputData, + runResult, + } = useOneStepRun({ + id, + data: inputs, + defaultRunInputData: { + [agentInputKey]: [''], + }, + }) const currentStrategy = strategyProvider.data?.declaration.strategies.find( str => str.identity.name === inputs.agent_strategy_name, ) @@ -59,6 +81,18 @@ const useConfig = (id: string, payload: AgentNodeType) => { onFormChange, currentStrategyStatus, strategyProvider: strategyProvider.data, + + isShowSingleRun, + showSingleRun, + hideSingleRun, + toVarInputs, + runningStatus, + handleRun, + handleStop, + runInputData, + setRunInputData, + runResult, + agentInputKey, } } diff --git a/web/app/components/workflow/nodes/tool/panel.tsx b/web/app/components/workflow/nodes/tool/panel.tsx index 01dff077eb..251e7242bf 100644 --- a/web/app/components/workflow/nodes/tool/panel.tsx +++ b/web/app/components/workflow/nodes/tool/panel.tsx @@ -15,6 +15,8 @@ import BeforeRunForm from '@/app/components/workflow/nodes/_base/components/befo import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' import ResultPanel from '@/app/components/workflow/run/result-panel' import { useToolIcon } from '@/app/components/workflow/hooks' +import { useLogs } from '@/app/components/workflow/run/hooks' +import formatToTracingNodeList from '@/app/components/workflow/run/utils/format-log' const i18nPrefix = 'workflow.nodes.tool' @@ -51,6 +53,8 @@ const Panel: FC> = ({ outputSchema, } = useConfig(id, data) const toolIcon = useToolIcon(data) + const logsParams = useLogs() + const nodeInfo = formatToTracingNodeList([runResult], t)[0] if (isLoading) { return
@@ -161,7 +165,8 @@ const Panel: FC> = ({ runningStatus={runningStatus} onRun={handleRun} onStop={handleStop} - result={} + {...logsParams} + result={} /> )}
diff --git a/web/app/components/workflow/run/agent-log/agent-log-nav.tsx b/web/app/components/workflow/run/agent-log/agent-log-nav.tsx index a56730a45a..21663c8c56 100644 --- a/web/app/components/workflow/run/agent-log/agent-log-nav.tsx +++ b/web/app/components/workflow/run/agent-log/agent-log-nav.tsx @@ -4,7 +4,7 @@ import Button from '@/app/components/base/button' import type { AgentLogItemWithChildren } from '@/types/workflow' type AgentLogNavProps = { - agentOrToolLogItemStack: { id: string; label: string }[] + agentOrToolLogItemStack: AgentLogItemWithChildren[] onShowAgentOrToolLog: (detail?: AgentLogItemWithChildren) => void } const AgentLogNav = ({ diff --git a/web/app/components/workflow/run/agent-log/agent-result-panel.tsx b/web/app/components/workflow/run/agent-log/agent-result-panel.tsx index 3028384f4a..d02e69f8da 100644 --- a/web/app/components/workflow/run/agent-log/agent-result-panel.tsx +++ b/web/app/components/workflow/run/agent-log/agent-result-panel.tsx @@ -1,9 +1,10 @@ +import { RiAlertFill } from '@remixicon/react' import AgentLogItem from './agent-log-item' import AgentLogNav from './agent-log-nav' import type { AgentLogItemWithChildren } from '@/types/workflow' type AgentResultPanelProps = { - agentOrToolLogItemStack: { id: string; label: string }[] + agentOrToolLogItemStack: AgentLogItemWithChildren[] agentOrToolLogListMap: Record onShowAgentOrToolLog: (detail?: AgentLogItemWithChildren) => void } @@ -34,6 +35,22 @@ const AgentResultPanel = ({ } } + { + top.hasCircle && ( +
+
+ +
+ There is circular invocation of tools/nodes in the current workflow. +
+
+ ) + } ) } diff --git a/web/app/components/workflow/run/hooks.ts b/web/app/components/workflow/run/hooks.ts index b9c879a204..55ddc4cbfc 100644 --- a/web/app/components/workflow/run/hooks.ts +++ b/web/app/components/workflow/run/hooks.ts @@ -33,7 +33,7 @@ export const useLogs = () => { setIterationResultDurationMap(iterDurationMap) }, [setShowIteratingDetailTrue, setIterationResultList, setIterationResultDurationMap]) - const [agentOrToolLogItemStack, setAgentOrToolLogItemStack] = useState<{ id: string; label: string }[]>([]) + const [agentOrToolLogItemStack, setAgentOrToolLogItemStack] = useState([]) const agentOrToolLogItemStackRef = useRef(agentOrToolLogItemStack) const [agentOrToolLogListMap, setAgentOrToolLogListMap] = useState>({}) const agentOrToolLogListMapRef = useRef(agentOrToolLogListMap) @@ -43,14 +43,14 @@ export const useLogs = () => { agentOrToolLogItemStackRef.current = [] return } - const { id, label, children } = detail + const { id, children } = detail let currentAgentOrToolLogItemStack = agentOrToolLogItemStackRef.current.slice() const index = currentAgentOrToolLogItemStack.findIndex(logItem => logItem.id === id) if (index > -1) currentAgentOrToolLogItemStack = currentAgentOrToolLogItemStack.slice(0, index + 1) else - currentAgentOrToolLogItemStack = [...currentAgentOrToolLogItemStack.slice(), { id, label }] + currentAgentOrToolLogItemStack = [...currentAgentOrToolLogItemStack.slice(), detail] setAgentOrToolLogItemStack(currentAgentOrToolLogItemStack) agentOrToolLogItemStackRef.current = currentAgentOrToolLogItemStack diff --git a/web/app/components/workflow/run/node.tsx b/web/app/components/workflow/run/node.tsx index 2fdab2bb7b..4d27c9bb4c 100644 --- a/web/app/components/workflow/run/node.tsx +++ b/web/app/components/workflow/run/node.tsx @@ -81,6 +81,7 @@ const NodePanel: FC = ({ const isIterationNode = nodeInfo.node_type === BlockEnum.Iteration const isRetryNode = hasRetryNode(nodeInfo.node_type) && nodeInfo.retryDetail const isAgentNode = nodeInfo.node_type === BlockEnum.Agent + const isToolNode = nodeInfo.node_type === BlockEnum.Tool return (
@@ -144,7 +145,7 @@ const NodePanel: FC = ({ /> )} { - isAgentNode && onShowAgentOrToolLog && ( + (isAgentNode || isToolNode) && onShowAgentOrToolLog && ( = ({ const isIterationNode = nodeInfo?.node_type === BlockEnum.Iteration const isRetryNode = hasRetryNode(nodeInfo?.node_type) && nodeInfo?.retryDetail const isAgentNode = nodeInfo?.node_type === BlockEnum.Agent + const isToolNode = nodeInfo?.node_type === BlockEnum.Tool return (
@@ -90,7 +91,7 @@ const ResultPanel: FC = ({ ) } { - isAgentNode && handleShowAgentOrToolLog && ( + (isAgentNode || isToolNode) && handleShowAgentOrToolLog && ( handleShowAgentOrToolLog?: (detail?: AgentLogItemWithChildren) => void }