llm: 工具回执夹图改批次后 user 合并投递 + 同回合去重护栏(线上死循环复盘)
多模态上游兼容性事故:tool 角色消息带 image_url 块是非标准形态,大量 OpenAI 兼容上游整批忽略或只认批次最后一张——模型看不到图、却见回执写着 「已回传」,加上旧催读文案「如需重读请再次 read_file」火上浇油,模型一轮轮 重读同一批图烧 token 死循环。改为: - llm.js buildMessages:未消费的 tool 回执图不塞回执内(回执降级纯文本), image_ref 现签外链后统一并入该批回执之后的一条 user 消息(user 角色各家 通吃);每张图前配一行「[图片 N,对应回执] <回执首行>」标签,模型可对号; 旧库 data: URL 块原样并入;签不到降级文字占位。顺序天然满足 assistant→ tool 紧邻配对约束(合并消息落在整段历史尾部)。 - 两处催读文案(已省略/外链不可用)改为「请告知用户、勿反复重读同一文件」。 - engine.js runLoopInner 死循环护栏:run.imgDelivered 按图 rel 去重,同回合 再读同图只回文字提示不再签新图;run 随回合销毁,新回合自动重置,正常 追问重看不受影响。 - definitions.json read_file 描述同步新形态(图在批次回执后的独立 user 消息到达;同回合重读不再带像素,勿重试)。 - ARCHITECTURE.md §5.1 图片约定、§14 陷阱 7 改写,记录本次复盘。 验证:容器内构造 history 直调 buildMessages 六场景单测全过(合并/标签/ 现签/签失败占位/已消费省略/同批多图序号/旧 data: 透传/user 行原位现签); JSON 与 node --check 通过;restart agent-core 启动干净、微信对账正常。
This commit is contained in:
@@ -202,7 +202,7 @@
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "read_file",
|
||||
"description": "Reads the content of a file.\n\nText files: each returned line is prefixed with a line number right-aligned in a 6-character field, followed by a tab, then the line content.\n\nLarge text files (roughly over 16 KB) are not returned in full: you get an outline listing top-level symbols (or Markdown headings) with line numbers instead. The outline IS a successful response — do NOT retry the same call without a line range; use the outline line numbers with `start_line` / `end_line` to read specific sections. If no outline can be extracted, a first-1KB excerpt is returned instead. Supplying `start_line` or `end_line` disables outline mode.\n\nImage files (PNG, JPEG, WebP, GIF, BMP, TIFF) are returned as visual content you can analyze directly, but only if the current model supports vision; otherwise a text placeholder is returned — that placeholder is not an error. Very large images (roughly over 50 MB) are skipped, and images may be downscaled (long edge ~2000 px, re-encoded as JPEG) before being returned.\n\nBinary files are not returned as text; a short notice is returned instead. Text files over 32 MB cannot be read by this tool — use `terminal` (grep -n / head / sed -n).",
|
||||
"description": "Reads the content of a file.\n\nText files: each returned line is prefixed with a line number right-aligned in a 6-character field, followed by a tab, then the line content.\n\nLarge text files (roughly over 16 KB) are not returned in full: you get an outline listing top-level symbols (or Markdown headings) with line numbers instead. The outline IS a successful response — do NOT retry the same call without a line range; use the outline line numbers with `start_line` / `end_line` to read specific sections. If no outline can be extracted, a first-1KB excerpt is returned instead. Supplying `start_line` or `end_line` disables outline mode.\n\nImage files (PNG, JPEG, WebP, GIF, BMP, TIFF) are returned as visual content you can analyze directly, but only if the current model supports vision; otherwise a text placeholder is returned — that placeholder is not an error. The tool result itself carries a text notice only; the actual image pixels arrive in a separate user message right after the batch of tool results, each image preceded by a label naming the read_file result it belongs to. Re-reading the same image within one turn returns a text-only notice without pixels — if an image never arrives, tell the user instead of retrying the read. Very large images (roughly over 50 MB) are skipped, and images may be downscaled (long edge ~2000 px, re-encoded as JPEG) before being returned.\n\nBinary files are not returned as text; a short notice is returned instead. Text files over 32 MB cannot be read by this tool — use `terminal` (grep -n / head / sed -n).",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
||||
Reference in New Issue
Block a user