fix: 联网搜索强制注入当前日期(system prompt + 工具层双保险)

This commit is contained in:
thzxx
2026-04-20 10:17:34 +08:00
parent eba0b4df5e
commit 6be27f4cfd
2 changed files with 7 additions and 4 deletions
+4 -2
View File
@@ -255,8 +255,10 @@ export async function handleWebSearch(params: { query: string; max_results?: num
return { success: false, error: '未找到搜索结果,请尝试其他关键词' };
}
// 构建格式化的搜索结果
const formatted = results.map((r, i) =>
// 构建格式化的搜索结果(附带当前日期)
const now = new Date();
const dateStr = `${now.getFullYear()}${now.getMonth() + 1}${now.getDate()}`;
const formatted = `[当前日期: ${dateStr}(搜索时的实时日期)]\n\n` + results.map((r, i) =>
`[${i + 1}] ${r.title}\n URL: ${r.url}\n ${r.snippet}`
).join('\n\n');