diff --git a/src/bus/message.rs b/src/bus/message.rs index bfadaab..c674f0b 100644 --- a/src/bus/message.rs +++ b/src/bus/message.rs @@ -585,6 +585,9 @@ impl OutboundMessage { outbound.push(resp); } + // AssistantResponse 已携带 reasoning 时,ToolCall 不再重复; + // 只有 AssistantResponse 没发时,ToolCall 才带 reasoning + let tc_reasoning = if has_content_or_reasoning { None } else { message.reasoning_content.clone() }; outbound.extend(tool_calls.iter().map(|tool_call| { let mut tc = Self::tool_call( channel.to_string(), @@ -596,7 +599,7 @@ impl OutboundMessage { reply_to.clone(), metadata.clone(), ); - tc.reasoning_content = message.reasoning_content.clone(); + tc.reasoning_content = tc_reasoning.clone(); tc })); outbound diff --git a/src/gateway/default_agent_prompt.md b/src/gateway/default_agent_prompt.md index 4b92a47..c0dbdf8 100644 --- a/src/gateway/default_agent_prompt.md +++ b/src/gateway/default_agent_prompt.md @@ -102,6 +102,7 @@ - 回答应以帮助用户完成当前目标为中心。 - 在信息不足时先补关键前提,在信息充分时直接执行。 - Skill 不是工具名。看到可用 Skill 时,不能直接调用 Skill 名称;必须先调用 skill_activate,并传入对应的 name。 +- 调用工具的时候必须同时用简短的话告诉用户你调用工具是做什么 ## 定时任务 @@ -109,5 +110,3 @@ - 默认创建静默任务(silent_agent_task),在独立后台会话中执行,不干扰主对话 - 静默模式下如需发送消息给用户,prompt中需显式使用 send_session_message 工具 -## 注意 -- 不要通过一次调用写入一个很长的文件,请分段写入 diff --git a/src/protocol/ws_adapter.rs b/src/protocol/ws_adapter.rs index 42c0080..c581420 100644 --- a/src/protocol/ws_adapter.rs +++ b/src/protocol/ws_adapter.rs @@ -29,6 +29,8 @@ pub(crate) fn ws_outbound_from_chat_message(message: &ChatMessage) -> Vec Vec clearTimeout(timer) }, [theme]) + const [showThinking, setShowThinking] = useState(() => { + return localStorage.getItem('picobot-show-thinking') !== 'false' + }) + + useEffect(() => { + localStorage.setItem('picobot-show-thinking', String(showThinking)) + }, [showThinking]) + // ---- WebSocket 初始化 ---- // Step 1: 连接建立后先请求通道列表 @@ -443,6 +451,18 @@ function App() { > {theme === 'dark' ? : } +
{} : handleSendMessage} onNavigateToSubAgent={handleNavigateToSubAgent} onStop={handleStopExecution} + showThinking={showThinking} />
diff --git a/web/src/components/Chat/ChatContainer.tsx b/web/src/components/Chat/ChatContainer.tsx index c3602dd..b6cf5dd 100644 --- a/web/src/components/Chat/ChatContainer.tsx +++ b/web/src/components/Chat/ChatContainer.tsx @@ -10,6 +10,7 @@ interface ChatContainerProps { onSendMessage: (content: string, attachments: Attachment[]) => void onNavigateToSubAgent?: (taskId: string, description: string) => void onStop?: () => void + showThinking?: boolean } export function ChatContainer({ @@ -20,11 +21,12 @@ export function ChatContainer({ onSendMessage, onNavigateToSubAgent, onStop, + showThinking = true, }: ChatContainerProps) { return (
- +
void + showThinking?: boolean } function getAttachmentIcon(mediaType: string) { @@ -240,13 +241,13 @@ function ThinkingSection({ content }: { content: string }) { const [expanded, setExpanded] = useState(false) return ( -
+
{expanded && ( -
-
+
+
{content}
@@ -288,7 +289,7 @@ function parseTaskResult(content: string): TaskToolResult | null { } } -export function MessageBubble({ message, onNavigateToSubAgent }: MessageBubbleProps) { +export function MessageBubble({ message, onNavigateToSubAgent, showThinking = true }: MessageBubbleProps) { const isUser = message.role === 'user' const isTool = message.role === 'tool' const isMergedTool = message.type === 'merged_tool' @@ -438,7 +439,7 @@ export function MessageBubble({ message, onNavigateToSubAgent }: MessageBubblePr
{/* 模型思考内容(工具调用时展示) */} - {message.reasoningContent && !toolExpanded && ( + {showThinking && message.reasoningContent && !toolExpanded && (
@@ -502,7 +503,7 @@ export function MessageBubble({ message, onNavigateToSubAgent }: MessageBubblePr {toolExpanded && (
{/* 模型思考内容(展开时也展示) */} - {message.reasoningContent && ( + {showThinking && message.reasoningContent && ( )} {taskResult ? ( @@ -653,7 +654,7 @@ export function MessageBubble({ message, onNavigateToSubAgent }: MessageBubblePr ) : ( // 模型思考内容(仅助手消息,非工具消息) <> - {!isTool && message.reasoningContent && ( + {showThinking && !isTool && message.reasoningContent && ( )} {/* AI 和工具消息使用 Markdown 渲染 */} diff --git a/web/src/components/Chat/MessageList.tsx b/web/src/components/Chat/MessageList.tsx index 0e9a2b9..bc81fac 100644 --- a/web/src/components/Chat/MessageList.tsx +++ b/web/src/components/Chat/MessageList.tsx @@ -6,9 +6,10 @@ import { Sparkles, ArrowDown, ArrowUp } from 'lucide-react' interface MessageListProps { messages: ChatMessage[] onNavigateToSubAgent?: (taskId: string, description: string) => void + showThinking?: boolean } -export function MessageList({ messages, onNavigateToSubAgent }: MessageListProps) { +export function MessageList({ messages, onNavigateToSubAgent, showThinking = true }: MessageListProps) { const bottomRef = useRef(null) const containerRef = useRef(null) const isAtBottomRef = useRef(true) @@ -116,7 +117,7 @@ export function MessageList({ messages, onNavigateToSubAgent }: MessageListProps className="h-full overflow-y-auto p-6 space-y-6" > {messages.map((message) => ( - + ))}