feat: improve agent collaboration observability
This commit is contained in:
@@ -194,6 +194,21 @@ const getStepColor = (step: ReasoningStep) => {
|
||||
|
||||
const getStepMetaItems = (step: ReasoningStep) => {
|
||||
const items: string[] = [];
|
||||
const communication = step.communication;
|
||||
const actor = communication?.actor || {};
|
||||
const target = communication?.target || {};
|
||||
const actorName =
|
||||
actor.agent_name ||
|
||||
actor.agent_code ||
|
||||
actor.node_label ||
|
||||
step.agent_name ||
|
||||
step.agent_code;
|
||||
const targetName = target.agent_name || target.agent_code || target.node_label;
|
||||
if (actorName && targetName) {
|
||||
items.push(`交接: ${actorName} -> ${targetName}`);
|
||||
} else if (communication?.channel) {
|
||||
items.push(`通道: ${communication.channel}`);
|
||||
}
|
||||
if (step.agent_name || step.agent_code) {
|
||||
items.push(`智能体: ${step.agent_name || step.agent_code}`);
|
||||
}
|
||||
@@ -206,6 +221,9 @@ const getStepMetaItems = (step: ReasoningStep) => {
|
||||
if (step.model || step.model_id) {
|
||||
items.push(`模型: ${step.model || step.model_id}`);
|
||||
}
|
||||
if (communication?.message && communication.message !== step.content) {
|
||||
items.push(`消息: ${communication.message}`);
|
||||
}
|
||||
return items;
|
||||
};
|
||||
|
||||
|
||||
@@ -72,6 +72,16 @@ export interface ReasoningStep {
|
||||
from_subflow?: boolean;
|
||||
collaboration_role?: string;
|
||||
collaboration_mode?: string;
|
||||
communication?: {
|
||||
actor?: Record<string, any>;
|
||||
branch_id?: string;
|
||||
branch_label?: string;
|
||||
channel?: string;
|
||||
event?: string;
|
||||
message?: string;
|
||||
status?: string;
|
||||
target?: Record<string, any>;
|
||||
};
|
||||
output?: any;
|
||||
/** 步骤状态:running 执行中,completed 已完成 */
|
||||
status?: 'completed' | 'running';
|
||||
|
||||
@@ -750,6 +750,7 @@ onUnmounted(() => {
|
||||
:enable-image="enableImage"
|
||||
:enable-voice="enableVoice"
|
||||
:enable-feedback="enableFeedback"
|
||||
:show-reasoning-steps="true"
|
||||
:show-clear-button="showClearButton"
|
||||
:empty-text="emptyText"
|
||||
:welcome-config="welcomeConfig"
|
||||
|
||||
@@ -231,6 +231,17 @@ export function useChatApi(props: AiChatPanelProps): {
|
||||
params: step.params,
|
||||
node_id: step.node_id,
|
||||
node_type: step.node_type,
|
||||
branch_id: step.branch_id,
|
||||
branch_label: step.branch_label,
|
||||
agent_code: step.agent_code,
|
||||
agent_name: step.agent_name,
|
||||
model: step.model,
|
||||
model_id: step.model_id,
|
||||
subflow_name: step.subflow_name,
|
||||
from_subflow: step.from_subflow,
|
||||
collaboration_role: step.collaboration_role,
|
||||
collaboration_mode: step.collaboration_mode,
|
||||
communication: step.communication,
|
||||
output: step.output,
|
||||
status: step.status,
|
||||
timestamp: step.timestamp,
|
||||
|
||||
@@ -172,6 +172,7 @@ export function useEventHandler(config: EventHandlerConfig) {
|
||||
|
||||
const buildReasoningMeta = (event: StreamEvent): Partial<ReasoningStep> => {
|
||||
const collaboration = event.collaboration || {};
|
||||
const communication = event.communication || {};
|
||||
return {
|
||||
branch_id: event.branch_id,
|
||||
branch_label: event.branch_label,
|
||||
@@ -187,6 +188,7 @@ export function useEventHandler(config: EventHandlerConfig) {
|
||||
collaboration_role:
|
||||
collaboration.collaboration_role || collaboration.role || event.collaboration_role,
|
||||
collaboration_mode: event.collaboration_mode || collaboration.collaboration_mode,
|
||||
communication,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -230,6 +232,35 @@ export function useEventHandler(config: EventHandlerConfig) {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'annotation_reply':
|
||||
case 'knowledge_retrieval':
|
||||
case 'observation':
|
||||
case 'thought':
|
||||
case 'tool_call':
|
||||
case 'tool_result': {
|
||||
currentSteps.value.push({
|
||||
type: event.type as ReasoningStep['type'],
|
||||
content:
|
||||
event.content ||
|
||||
event.message ||
|
||||
event.tool ||
|
||||
event.type,
|
||||
tool: event.tool,
|
||||
params: event.params,
|
||||
result: event.result,
|
||||
node_id: event.node_id,
|
||||
node_type: event.node_type,
|
||||
...buildReasoningMeta(event),
|
||||
status: 'completed',
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
updateAssistantMessage(msgId, {
|
||||
reasoning_steps: [...currentSteps.value],
|
||||
...buildMessageMeta(event),
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'answer': {
|
||||
const initialMsg = messages.value.find((m) => m.id === msgId);
|
||||
if (initialMsg && !initialMsg.content?.trim()) {
|
||||
|
||||
Reference in New Issue
Block a user