feat: 更新默认代理配置,建议在思考时使用中文以提高上下文理解

This commit is contained in:
oudecheng 2026-06-11 18:20:23 +08:00
parent 7b1bc39031
commit 7c3363aa47
2 changed files with 46 additions and 29 deletions

View File

@ -104,6 +104,7 @@
- Skill 不是工具名。看到可用 Skill 时,不能直接调用 Skill 名称;必须先调用 skill_activate并传入对应的 name。
- 调用工具的时候必须同时用简短的话告诉用户你调用工具是做什么
- 无需担心创建子智能体过多的问题请按用户或者skill的要求创建对应数量的子智能体这样可以隔离上下文更好完成工作
- 思考的时候建议用中文思考
## 定时任务

View File

@ -636,8 +636,7 @@ async fn send_topic_history(
// 将消息转换为 WsOutbound 并发送
for msg in messages {
let outbound = chat_message_to_ws_outbound(&msg);
if let Some(outbound) = outbound {
for outbound in chat_message_to_ws_outbound(&msg) {
let _ = sender.send(outbound).await;
}
}
@ -657,13 +656,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 outbound = chat_message_to_ws_outbound(&msg);
let mut outbounds = chat_message_to_ws_outbound(&msg);
if let Some(ref task_id) = subagent_task_id {
if let Some(ref mut ob) = outbound {
for ob in &mut outbounds {
set_subagent_task_id(ob, task_id);
}
}
if let Some(outbound) = outbound {
for outbound in outbounds {
let _ = sender.send(outbound).await;
}
}
@ -692,8 +691,8 @@ fn set_subagent_task_id(outbound: &mut WsOutbound, task_id: &str) {
}
}
/// 将 ChatMessage 转换为 WsOutbound
fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Option<WsOutbound> {
/// 将 ChatMessage 转换为 WsOutbound 列表
fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Vec<WsOutbound> {
use crate::bus::message::ToolMessageState;
// Helper function to strip media_refs_json from content
@ -750,9 +749,24 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Option<WsOutbou
match msg.role.as_str() {
"assistant" => {
if let Some(tool_calls) = &msg.tool_calls {
// 如果有 tool_calls发送 ToolCall 消息
if let Some(tool_call) = tool_calls.first() {
return Some(WsOutbound::ToolCall {
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 {
id: msg.id.clone(),
tool_call_id: tool_call.id.clone(),
tool_name: tool_call.name.clone(),
@ -762,12 +776,13 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Option<WsOutbou
subagent_task_id: None,
topic_id: None,
timestamp: Some(msg.timestamp / 1000),
reasoning_content: msg.reasoning_content.clone(),
reasoning_content: tc_reasoning.clone(),
});
}
}
outbound
} else {
// 普通助手消息
Some(WsOutbound::AssistantResponse {
vec![WsOutbound::AssistantResponse {
id: msg.id.clone(),
content: msg.content.clone(),
role: msg.role.clone(),
@ -776,12 +791,13 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Option<WsOutbou
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 => Some(WsOutbound::ToolResult {
ToolMessageState::Completed => vec![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(),
@ -791,8 +807,8 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Option<WsOutbou
topic_id: None,
duration_ms: msg.tool_duration_ms,
timestamp: Some(msg.timestamp / 1000),
}),
ToolMessageState::PendingUserAction => Some(WsOutbound::ToolPending {
}],
ToolMessageState::PendingUserAction => vec![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(),
@ -802,10 +818,10 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Option<WsOutbou
subagent_task_id: None,
topic_id: None,
timestamp: Some(msg.timestamp / 1000),
}),
}],
}
}
"user" => Some(WsOutbound::AssistantResponse {
"user" => vec![WsOutbound::AssistantResponse {
id: msg.id.clone(),
content: strip_media_refs_json(&msg.content),
role: msg.role.clone(),
@ -814,8 +830,8 @@ fn chat_message_to_ws_outbound(msg: &crate::bus::ChatMessage) -> Option<WsOutbou
topic_id: None,
timestamp: Some(msg.timestamp / 1000),
reasoning_content: None,
}),
_ => None,
}],
_ => Vec::new(),
}
}