diff --git a/wiki/feature-map.md b/wiki/feature-map.md index 1b60936..3ad5566 100644 --- a/wiki/feature-map.md +++ b/wiki/feature-map.md @@ -1,6 +1,6 @@ --- title: 功能链路映射 -updated: 2026-04-21 +updated: 2026-04-22 status: active tags: [reference, feature-map, testing] --- @@ -122,6 +122,21 @@ tags: [reference, feature-map, testing] ## 自主能力 / Hands (4 条) +### F-09.5: Agent 搜索(网络搜索) + +| 维度 | 内容 | +|------|------| +| 用户入口 | 聊天中输入搜索请求(如"搜索今天的新闻") | +| 前端关键文件 | ChatArea.tsx (stripToolNarration), StreamingText.tsx (ReactMarkdown) | +| 触发机制 | LLM 判断需要搜索 → ToolUse{hand_researcher} → AgentLoop 执行 | +| Tauri 命令 | 无独立命令,通过 agent_chat_stream → loop_runner → hand_execute | +| Rust 核心 | zclaw-hands/researcher.rs: search_native() → Baidu + Bing CN 并行 | +| 网页获取 | fetch_via_jina() (Jina Reader API) → fetch_direct() (降级) | +| LLM 兼容 | 扁平 input_schema + empty-input 回退(_fallback_query 注入) | +| UI 处理 | hand 消息隐藏 + stripToolNarration 行级过滤 + ReactMarkdown 渲染 | +| 搜索引擎 | Baidu + Bing CN(国内优先), DuckDuckGo fallback | +| 测试状态 | ✅ E2E 验证通过 (commit 5816f56 + 81005c3) | + ### F-10: 触发 Hand | 维度 | 内容 | diff --git a/wiki/hands-skills.md b/wiki/hands-skills.md index 7492fc5..a54013d 100644 --- a/wiki/hands-skills.md +++ b/wiki/hands-skills.md @@ -1,6 +1,6 @@ --- title: Hands + Skills + MCP -updated: 2026-04-21 +updated: 2026-04-22 status: active tags: [module, hands, skills, mcp] --- @@ -28,7 +28,7 @@ tags: [module, hands, skills, mcp] |------|------|------|--------|------| | Browser | 浏览器自动化 (23 Tauri命令) | WebDriver | 8 | `hands/browser.HAND.toml` | | Collector | 数据收集聚合 | — | 8 | `hands/collector.HAND.toml` | -| Researcher | 深度研究 | LLM | 22 | `hands/researcher.HAND.toml` | +| Researcher | 深度研究 + 网络搜索 | 网络 | 22 | `hands/researcher.HAND.toml` | | Clip | 视频处理 | FFmpeg | 30 | `hands/clip.HAND.toml` | | Twitter | Twitter 自动化 (12 API v2) | OAuth 1.0a | 25 | `hands/twitter.HAND.toml` | | Quiz | 测验生成 | — | — | `hands/quiz.HAND.toml` | @@ -36,6 +36,29 @@ tags: [module, hands, skills, mcp] Hands 测试分布(前 5): Clip(30), Twitter(25), Researcher(22), Browser(8), Collector(8) +### Researcher 搜索能力(04-22 修复) + +Researcher 是 ZCLAW 的核心搜索 Hand,支持从对话中直接触发网络搜索和网页获取。 + +**搜索引擎**: Baidu + Bing CN 并行(国内用户可用),DuckDuckGo 作为 fallback +**网页获取**: Jina Reader API(优先,返回干净 Markdown)→ 直接 HTTP fetch(降级) +**LLM 兼容**: 扁平化 input_schema(action/query/url/urls/engine),兼容 glm-5.1 等国产模型 +**空参数回退**: 当 LLM 发送空 `{}` 时,loop_runner 自动注入用户消息作为 `_fallback_query` + +``` +用户消息 "搜索今天的新闻" + → LLM 生成 ToolUse{hand_researcher, {action:"search", query:"今日新闻"}} + → AgentLoop → ResearcherHand.execute() + → execute_search() → search_native() → Baidu + Bing CN 并行 + → 搜索结果 (10条) → ToolResult → LLM 基于结果生成回复 + → 前端 stripToolNarration 过滤内部叙述 + ReactMarkdown 渲染排版 +``` + +关键修复 (commit 5816f56 + 81005c3): +- **schema 简化**: `oneOf`+`const` → 扁平属性,解决 glm-5.1 不理解复杂 schema 导致空参数 +- **empty-input 回退**: loop_runner 检测 `{}` → 注入 `_fallback_query` → researcher 自动搜索 +- **排版修复**: stripToolNarration 从句子级拆分改为行级过滤,保留 markdown 结构 + ### 已删除 Hands (04-17 Phase 5 空壳清理) | Hand | 原状态 | 删除原因 | diff --git a/wiki/known-issues.md b/wiki/known-issues.md index dc9b8d5..7da1a66 100644 --- a/wiki/known-issues.md +++ b/wiki/known-issues.md @@ -1,6 +1,6 @@ --- title: 已知问题 -updated: 2026-04-20 +updated: 2026-04-22 status: active tags: [issues, bugs] --- @@ -25,6 +25,15 @@ tags: [issues, bugs] | 审计 04-20 P0 | 2 | **全部已修复** (commit f291736) | | 审计 04-20 P1 | 3 | **全部已修复** (commit f291736) | | 审计 04-20 P2 | 2 | 待处理 (B-SCHED-5 任务名噪声 + B-CHAT-7 混合域截断) | +| 搜索 04-22 P1 | 3 | **全部已修复** (commit 5816f56 + 81005c3) | + +## 搜索功能修复 04-22 + +| ID | 级别 | 问题 | 修复 | commit | +|------|------|------|------|--------| +| SEARCH-1 | P1 | glm-5.1 不理解 oneOf+const schema,tool_calls 参数为空 `{}` | 扁平化 input_schema (action/query/url/urls/engine) + empty-input 回退注入 | 5816f56 | +| SEARCH-2 | P1 | DuckDuckGo 被墙,搜索优先使用 Google | 改为 Baidu + Bing CN 并行,DDG 仅 fallback | 5816f56 | +| SEARCH-3 | P1 | stripToolNarration 按句子拆分破坏 markdown 排版 | 改为行级过滤,保留 markdown 结构行 | 81005c3 | ## E2E 全系统功能测试 04-17 (129 链路) diff --git a/wiki/log.md b/wiki/log.md index f148673..fa532c9 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -1,6 +1,6 @@ --- title: 变更日志 -updated: 2026-04-21 +updated: 2026-04-22 status: active tags: [log, history] --- @@ -9,6 +9,20 @@ tags: [log, history] > Append-only 操作记录。格式: `## [日期] 类型 | 描述` +## [2026-04-22] fix | Agent 搜索功能修复 — glm 空参数 + schema 简化 + 排版修复 (commit 5816f56 + 81005c3) + +**根因**: glm-5.1 不理解 `oneOf`+`const` 复杂 JSON Schema,tool_calls arguments 始终为空 `{}`。 +加上 DuckDuckGo 被墙导致搜索引擎选择不正确,以及 stripToolNarration 破坏了 markdown 排版。 + +**修复 3 项**: +1. `researcher.rs` input_schema 扁平化 + `_fallback_query` 回退 (5816f56) +2. `loop_runner.rs` 空参数检测 → 注入用户消息作为查询 (5816f56) +3. `ChatArea.tsx` stripToolNarration 改为行级过滤,保留 markdown 结构 (81005c3) + +**影响文件**: `crates/zclaw-hands/src/hands/researcher.rs`, `crates/zclaw-runtime/src/loop_runner.rs`, `desktop/src/components/ChatArea.tsx` + +**验证**: E2E 搜索 "今日科技新闻" — Baidu + Bing CN 并行返回 10 条结果,LLM 生成排版正确的回复 + ## [2026-04-21] fix | Phase 0+1 突破之路 — 8 项基础链路修复 (commit c1dea6e + 9a2611d) **Phase 0 地基修复 (2 项)**: