Compare commits
No commits in common. "f808bd09ea1dc12c39ef919a679da4f6412c7f60" and "4487f1a490f4cabe30871d8f854a548c2ed60540" have entirely different histories.
f808bd09ea
...
4487f1a490
@ -103,8 +103,7 @@
|
||||
- 在信息不足时先补关键前提,在信息充分时直接执行。
|
||||
- Skill 不是工具名。看到可用 Skill 时,不能直接调用 Skill 名称;必须先调用 skill_activate,并传入对应的 name。
|
||||
- 调用工具的时候必须同时用简短的话告诉用户你调用工具是做什么
|
||||
- 无需担心创建子智能体过多的问题,请按用户或者skill的要求创建对应数量的子智能体,这样可以隔离上下文,更好完成工作
|
||||
- 思考的时候建议用中文思考
|
||||
|
||||
|
||||
## 定时任务
|
||||
|
||||
|
||||
@ -636,7 +636,8 @@ async fn send_topic_history(
|
||||
|
||||
// 将消息转换为 WsOutbound 并发送
|
||||
for msg in messages {
|
||||
for outbound in chat_message_to_ws_outbound(&msg) {
|
||||
let outbound = chat_message_to_ws_outbound(&msg);
|
||||
if let Some(outbound) = outbound {
|
||||
let _ = sender.send(outbound).await;
|
||||
}
|
||||
}
|
||||
@ -656,13 +657,13 @@ async fn send_task_messages(
|
||||
tracing::info!(session_id = %session_id, message_count = messages.len(), "Sending task messages");
|
||||
|
||||
for msg in messages {
|
||||
let mut outbounds = chat_message_to_ws_outbound(&msg);
|
||||
let mut outbound = chat_message_to_ws_outbound(&msg);
|
||||
if let Some(ref task_id) = subagent_task_id {
|
||||
for ob in &mut outbounds {
|
||||
if let Some(ref mut ob) = outbound {
|
||||
set_subagent_task_id(ob, task_id);
|
||||
}
|
||||
}
|
||||
for outbound in outbounds {
|
||||
if let Some(outbound) = outbound {
|
||||
let _ = sender.send(outbound).await;
|
||||
}
|
||||
}
|
||||
@ -691,8 +692,8 @@ fn set_subagent_task_id(outbound: &mut WsOutbound, task_id: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
/// 将 ChatMessage 转换为 WsOutbound 列表
|
||||
fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound> {
|
||||
/// 将 ChatMessage 转换为 WsOutbound
|
||||
fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Option<WsOutbound> {
|
||||
use crate::bus::message::ToolMessageState;
|
||||
|
||||
// Helper function to strip media_refs_json from content
|
||||
@ -749,24 +750,9 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
||||
match msg.role.as_str() {
|
||||
"assistant" => {
|
||||
if let Some(tool_calls) = &msg.tool_calls {
|
||||
let mut outbound = Vec::new();
|
||||
let has_content_or_reasoning = !msg.content.trim().is_empty() || msg.reasoning_content.is_some();
|
||||
if has_content_or_reasoning {
|
||||
outbound.push(WsOutbound::AssistantResponse {
|
||||
id: msg.id.clone(),
|
||||
content: msg.content.clone(),
|
||||
role: msg.role.clone(),
|
||||
attachments: Vec::new(),
|
||||
subagent_task_id: None,
|
||||
topic_id: None,
|
||||
timestamp: Some(msg.timestamp / 1000),
|
||||
reasoning_content: msg.reasoning_content.clone(),
|
||||
});
|
||||
}
|
||||
// AssistantResponse 已携带 reasoning 时,ToolCall 不再重复
|
||||
let tc_reasoning = if has_content_or_reasoning { None } else { msg.reasoning_content.clone() };
|
||||
for tool_call in tool_calls {
|
||||
outbound.push(WsOutbound::ToolCall {
|
||||
// 如果有 tool_calls,发送 ToolCall 消息
|
||||
if let Some(tool_call) = tool_calls.first() {
|
||||
return Some(WsOutbound::ToolCall {
|
||||
id: msg.id.clone(),
|
||||
tool_call_id: tool_call.id.clone(),
|
||||
tool_name: tool_call.name.clone(),
|
||||
@ -776,13 +762,12 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
||||
subagent_task_id: None,
|
||||
topic_id: None,
|
||||
timestamp: Some(msg.timestamp / 1000),
|
||||
reasoning_content: tc_reasoning.clone(),
|
||||
reasoning_content: msg.reasoning_content.clone(),
|
||||
});
|
||||
}
|
||||
outbound
|
||||
} else {
|
||||
}
|
||||
// 普通助手消息
|
||||
vec![WsOutbound::AssistantResponse {
|
||||
Some(WsOutbound::AssistantResponse {
|
||||
id: msg.id.clone(),
|
||||
content: msg.content.clone(),
|
||||
role: msg.role.clone(),
|
||||
@ -791,13 +776,12 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
||||
topic_id: None,
|
||||
timestamp: Some(msg.timestamp / 1000),
|
||||
reasoning_content: msg.reasoning_content.clone(),
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
"tool" => {
|
||||
let tool_state = msg.tool_state.as_ref().unwrap_or(&ToolMessageState::Completed);
|
||||
match tool_state {
|
||||
ToolMessageState::Completed => vec![WsOutbound::ToolResult {
|
||||
ToolMessageState::Completed => Some(WsOutbound::ToolResult {
|
||||
id: msg.id.clone(),
|
||||
tool_call_id: msg.tool_call_id.clone().unwrap_or_default(),
|
||||
tool_name: msg.tool_name.clone().unwrap_or_default(),
|
||||
@ -807,8 +791,8 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
||||
topic_id: None,
|
||||
duration_ms: msg.tool_duration_ms,
|
||||
timestamp: Some(msg.timestamp / 1000),
|
||||
}],
|
||||
ToolMessageState::PendingUserAction => vec![WsOutbound::ToolPending {
|
||||
}),
|
||||
ToolMessageState::PendingUserAction => Some(WsOutbound::ToolPending {
|
||||
id: msg.id.clone(),
|
||||
tool_call_id: msg.tool_call_id.clone().unwrap_or_default(),
|
||||
tool_name: msg.tool_name.clone().unwrap_or_default(),
|
||||
@ -818,10 +802,10 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
||||
subagent_task_id: None,
|
||||
topic_id: None,
|
||||
timestamp: Some(msg.timestamp / 1000),
|
||||
}],
|
||||
}),
|
||||
}
|
||||
}
|
||||
"user" => vec![WsOutbound::AssistantResponse {
|
||||
"user" => Some(WsOutbound::AssistantResponse {
|
||||
id: msg.id.clone(),
|
||||
content: strip_media_refs_json(&msg.content),
|
||||
role: msg.role.clone(),
|
||||
@ -830,8 +814,8 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
||||
topic_id: None,
|
||||
timestamp: Some(msg.timestamp / 1000),
|
||||
reasoning_content: None,
|
||||
}],
|
||||
_ => Vec::new(),
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -589,11 +589,6 @@ export function MessageBubble({ message, onNavigateToSubAgent, showThinking = tr
|
||||
)
|
||||
}
|
||||
|
||||
// 隐藏思考且无实质内容时,不渲染空的助手消息气泡
|
||||
if (!isUser && !isTool && !isMergedTool && !showThinking && !message.content.trim() && message.reasoningContent) {
|
||||
return null
|
||||
}
|
||||
|
||||
const getIcon = () => {
|
||||
if (isUser) return <User className="h-4 w-4" />
|
||||
if (isTool) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user