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 不是工具名。看到可用 Skill 时,不能直接调用 Skill 名称;必须先调用 skill_activate,并传入对应的 name。
|
||||||
- 调用工具的时候必须同时用简短的话告诉用户你调用工具是做什么
|
- 调用工具的时候必须同时用简短的话告诉用户你调用工具是做什么
|
||||||
- 无需担心创建子智能体过多的问题,请按用户或者skill的要求创建对应数量的子智能体,这样可以隔离上下文,更好完成工作
|
|
||||||
- 思考的时候建议用中文思考
|
|
||||||
|
|
||||||
## 定时任务
|
## 定时任务
|
||||||
|
|
||||||
|
|||||||
@ -636,7 +636,8 @@ async fn send_topic_history(
|
|||||||
|
|
||||||
// 将消息转换为 WsOutbound 并发送
|
// 将消息转换为 WsOutbound 并发送
|
||||||
for msg in messages {
|
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;
|
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");
|
tracing::info!(session_id = %session_id, message_count = messages.len(), "Sending task messages");
|
||||||
|
|
||||||
for msg in 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 {
|
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);
|
set_subagent_task_id(ob, task_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for outbound in outbounds {
|
if let Some(outbound) = outbound {
|
||||||
let _ = sender.send(outbound).await;
|
let _ = sender.send(outbound).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -691,8 +692,8 @@ fn set_subagent_task_id(outbound: &mut WsOutbound, task_id: &str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 将 ChatMessage 转换为 WsOutbound 列表
|
/// 将 ChatMessage 转换为 WsOutbound
|
||||||
fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound> {
|
fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Option<WsOutbound> {
|
||||||
use crate::bus::message::ToolMessageState;
|
use crate::bus::message::ToolMessageState;
|
||||||
|
|
||||||
// Helper function to strip media_refs_json from content
|
// 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() {
|
match msg.role.as_str() {
|
||||||
"assistant" => {
|
"assistant" => {
|
||||||
if let Some(tool_calls) = &msg.tool_calls {
|
if let Some(tool_calls) = &msg.tool_calls {
|
||||||
let mut outbound = Vec::new();
|
// 如果有 tool_calls,发送 ToolCall 消息
|
||||||
let has_content_or_reasoning = !msg.content.trim().is_empty() || msg.reasoning_content.is_some();
|
if let Some(tool_call) = tool_calls.first() {
|
||||||
if has_content_or_reasoning {
|
return Some(WsOutbound::ToolCall {
|
||||||
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 {
|
|
||||||
id: msg.id.clone(),
|
id: msg.id.clone(),
|
||||||
tool_call_id: tool_call.id.clone(),
|
tool_call_id: tool_call.id.clone(),
|
||||||
tool_name: tool_call.name.clone(),
|
tool_name: tool_call.name.clone(),
|
||||||
@ -776,28 +762,26 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
|||||||
subagent_task_id: None,
|
subagent_task_id: None,
|
||||||
topic_id: None,
|
topic_id: None,
|
||||||
timestamp: Some(msg.timestamp / 1000),
|
timestamp: Some(msg.timestamp / 1000),
|
||||||
reasoning_content: tc_reasoning.clone(),
|
reasoning_content: msg.reasoning_content.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
outbound
|
|
||||||
} else {
|
|
||||||
// 普通助手消息
|
|
||||||
vec![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(),
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
|
// 普通助手消息
|
||||||
|
Some(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(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
"tool" => {
|
"tool" => {
|
||||||
let tool_state = msg.tool_state.as_ref().unwrap_or(&ToolMessageState::Completed);
|
let tool_state = msg.tool_state.as_ref().unwrap_or(&ToolMessageState::Completed);
|
||||||
match tool_state {
|
match tool_state {
|
||||||
ToolMessageState::Completed => vec![WsOutbound::ToolResult {
|
ToolMessageState::Completed => Some(WsOutbound::ToolResult {
|
||||||
id: msg.id.clone(),
|
id: msg.id.clone(),
|
||||||
tool_call_id: msg.tool_call_id.clone().unwrap_or_default(),
|
tool_call_id: msg.tool_call_id.clone().unwrap_or_default(),
|
||||||
tool_name: msg.tool_name.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,
|
topic_id: None,
|
||||||
duration_ms: msg.tool_duration_ms,
|
duration_ms: msg.tool_duration_ms,
|
||||||
timestamp: Some(msg.timestamp / 1000),
|
timestamp: Some(msg.timestamp / 1000),
|
||||||
}],
|
}),
|
||||||
ToolMessageState::PendingUserAction => vec![WsOutbound::ToolPending {
|
ToolMessageState::PendingUserAction => Some(WsOutbound::ToolPending {
|
||||||
id: msg.id.clone(),
|
id: msg.id.clone(),
|
||||||
tool_call_id: msg.tool_call_id.clone().unwrap_or_default(),
|
tool_call_id: msg.tool_call_id.clone().unwrap_or_default(),
|
||||||
tool_name: msg.tool_name.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,
|
subagent_task_id: None,
|
||||||
topic_id: None,
|
topic_id: None,
|
||||||
timestamp: Some(msg.timestamp / 1000),
|
timestamp: Some(msg.timestamp / 1000),
|
||||||
}],
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"user" => vec![WsOutbound::AssistantResponse {
|
"user" => Some(WsOutbound::AssistantResponse {
|
||||||
id: msg.id.clone(),
|
id: msg.id.clone(),
|
||||||
content: strip_media_refs_json(&msg.content),
|
content: strip_media_refs_json(&msg.content),
|
||||||
role: msg.role.clone(),
|
role: msg.role.clone(),
|
||||||
@ -830,8 +814,8 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound>
|
|||||||
topic_id: None,
|
topic_id: None,
|
||||||
timestamp: Some(msg.timestamp / 1000),
|
timestamp: Some(msg.timestamp / 1000),
|
||||||
reasoning_content: None,
|
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 = () => {
|
const getIcon = () => {
|
||||||
if (isUser) return <User className="h-4 w-4" />
|
if (isUser) return <User className="h-4 w-4" />
|
||||||
if (isTool) {
|
if (isTool) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user