diff --git a/langgraph/src/agent/enterprise/tools/soc-client.ts b/langgraph/src/agent/enterprise/tools/soc-client.ts index ccca3ae..4ea771b 100644 --- a/langgraph/src/agent/enterprise/tools/soc-client.ts +++ b/langgraph/src/agent/enterprise/tools/soc-client.ts @@ -236,7 +236,7 @@ export async function webRead(url: string): Promise<{ content: string; title: st Authorization: `Bearer ${config.jina.apiKey}`, Accept: "application/json", }, - signal: AbortSignal.timeout(getToolConfig("web_search").timeoutMs), + signal: AbortSignal.timeout(getToolConfig("web_read").timeoutMs), }); if (!resp.ok) throw new Error(`Jina read failed: ${resp.status}`); const data = await resp.json(); diff --git a/langgraph/src/agent/searcher/nodes/agent.ts b/langgraph/src/agent/searcher/nodes/agent.ts index 9ca61f3..5d5275e 100644 --- a/langgraph/src/agent/searcher/nodes/agent.ts +++ b/langgraph/src/agent/searcher/nodes/agent.ts @@ -11,10 +11,11 @@ const SYSTEM_PROMPT = `你是深度搜索助手。通过多步搜索为用户找 ## 搜索策略 1. 分析问题关键词和意图,确定搜索方向 -2. google_search 快速获取概览,web_search_deep 获取完整内容——根据问题深度选择 -3. 需要详细内容时,用 web_read 读取页面全文 -4. 首次结果不理想则调整关键词或换用另一种搜索工具重试 +2. 第一步:先调用 google_search 获取概览,**等待搜索结果返回后**再决定下一步 +3. 如需更深内容,**在单独的一步**调用 web_read 读取特定页面——不要在同一次调用中同时发起 google_search 和 web_read +4. 首次结果不理想则调整关键词或换用 web_search_deep 重试 5. 复杂问题拆分为子问题分别搜索,最后综合 +6. **严禁**:在同一轮 tool_calls 中同时调用 google_search 和 web_read ## 引用格式 - 回答中用 [1][2] 标注来源 diff --git a/langgraph/src/agent/utils/toolConfig.ts b/langgraph/src/agent/utils/toolConfig.ts index 820dcb4..fe9d620 100644 --- a/langgraph/src/agent/utils/toolConfig.ts +++ b/langgraph/src/agent/utils/toolConfig.ts @@ -10,7 +10,8 @@ export const TOOL_CONFIGS: Record = { ticket_list: { timeoutMs: 15_000, maxRetries: 2, backoffMs: 500 }, ticket_detail: { timeoutMs: 15_000, maxRetries: 2, backoffMs: 500 }, google_search: { timeoutMs: 10_000, maxRetries: 1 }, - web_search: { timeoutMs: 30_000, maxRetries: 1 }, + web_search: { timeoutMs: 10_000, maxRetries: 1 }, + web_read: { timeoutMs: 8_000, maxRetries: 1 }, web_search_deep: { timeoutMs: 45_000, maxRetries: 1 }, sandbox_run: { timeoutMs: 15_000, maxRetries: 1 }, code_execute: { timeoutMs: 15_000, maxRetries: 1 }, diff --git a/langgraph/src/main.tsx b/langgraph/src/main.tsx index cb0d288..d2a7602 100644 --- a/langgraph/src/main.tsx +++ b/langgraph/src/main.tsx @@ -546,8 +546,19 @@ function App() { reader.readAsDataURL(file); } - // ── Active messages: prefer streaming messages, fall back to historical ── - const activeMessages: Message[] = thread.messages.length > 0 ? thread.messages : historicalMessages; + // ── Active messages: prefer streaming messages, fall back to cached/historical ── + // Use a ref to cache the last known non-empty messages, preventing flash when + // thread.messages briefly becomes [] during a new submission. + const lastMessagesRef = useRef([]); + if (thread.messages.length > 0) { + lastMessagesRef.current = thread.messages; + } + const activeMessages: Message[] = + thread.messages.length > 0 + ? thread.messages + : lastMessagesRef.current.length > 0 + ? lastMessagesRef.current + : historicalMessages; // ── Collect completed tool call IDs ───────────────────────────────────── const completedToolIds = new Set(