fix: 修复Agent Loop工具调用重复问题,移除web_fetch截断
- 新增工具调用缓存机制,避免重复调用相同工具+参数 - 新增同轮内重复检测和跨轮次重复检测,连续两轮相同调用自动终止循环 - TOOLS_USAGE_GUIDE 新增第8条严禁重复调用规则 - web_fetch 默认不截断(max_chars=0),返回完整内容 - 移除 tool-registry.ts executeTool 中重复的 logToolStart 调用
This commit is contained in:
@@ -433,9 +433,9 @@ export async function handleWebFetch(params: { url: string; max_chars?: number;
|
||||
return { success: false, error: '仅支持 http/https 协议' };
|
||||
}
|
||||
|
||||
const maxChars = params.max_chars || 10000;
|
||||
const maxChars = params.max_chars || 0; // 0 = 不截断,返回全部内容
|
||||
|
||||
sendLog('info', `🌐 web_fetch`, `${url} (${maxChars} chars)`);
|
||||
sendLog('info', `🌐 web_fetch`, `${url} (${maxChars > 0 ? maxChars + ' chars' : '完整内容'})`);
|
||||
const resp = await fetch(url, {
|
||||
headers: { 'User-Agent': 'MetonaOllama/1.0' },
|
||||
signal: AbortSignal.timeout(15000)
|
||||
@@ -466,7 +466,7 @@ export async function handleWebFetch(params: { url: string; max_chars?: number;
|
||||
.trim();
|
||||
}
|
||||
|
||||
const truncated = text.length > maxChars;
|
||||
const truncated = maxChars > 0 && text.length > maxChars;
|
||||
if (truncated) text = text.slice(0, maxChars);
|
||||
|
||||
sendLog('success', `🌐 web_fetch 完成`, `${resp.status} | ${text.length} chars${truncated ? ' (已截断)' : ''}`);
|
||||
|
||||
Reference in New Issue
Block a user