trace: 标注被截断的链路消息,避免误读为模型未写完
2026-10-29 实弹:468 字 final_answer 在链路里只剩前 300 字、 断在 fu 后,控制台照原样当助手回复展示,用户误以为模型 没写完。截断本身是设计(防链路文件写爆),缺的是标记。 - host.py _summarize_trace_item:agentMessage 超 300 字时 条目带 truncated=True,短消息不带,完整回复仍在任务 result_text 里,不在链路条目里。 - 控制台:TraceEntry 加 truncated 字段,mapTrace 与 traceLineText 在被截断的消息后标注“链路摘要已截断至 300 字,完整回复见右侧任务结果”,console.html 为构建产物同步。 - 单测:tests/test_host_trace.py 新增截断标记用例(468 字 截 300 字且带标记、短消息不带标记)。 验证:host 10 项、cloud test_task_trace 14 项全过; React tsc+vite 构建通过,产物 322151 字节、含截断标注、 含 #150 的 total_tokens/首字/总耗时,无回退。
This commit is contained in:
1 parent
fd9fe5f254
commit
ce85043a24
6 files changed
+36
-7
No files matched your search
@@ -241,6 +241,9 @@ def _summarize_trace_item(method, params):
|
||||
|
||||
只取过程事实,不取大文本:命令截 500 字、消息截 300 字、
|
||||
思考摘要截 200 字;fileChange 一项一变化拆多条。
|
||||
消息被截断时条目带 truncated=True(控制台据此标注“链路
|
||||
摘要已截断”,不得把截断后的文本当成模型的完整回复;
|
||||
完整回复在任务的 result_text 里,不在链路条目里)。
|
||||
返回 [] 表示该通知不进链路(userMessage 等)。
|
||||
ts 取通知的 completedAtMs/startedAtMs(毫秒 epoch),
|
||||
没有时为 None,服务端展示时按无时间处理。
|
||||
@@ -278,8 +281,11 @@ def _summarize_trace_item(method, params):
|
||||
text = item.get("text") or ""
|
||||
if not text:
|
||||
return []
|
||||
return [{"kind": "message", "id": item_id, "ts": ts, "thread": thread,
|
||||
"phase": item.get("phase") or "", "text": text[:300]}]
|
||||
entry = {"kind": "message", "id": item_id, "ts": ts, "thread": thread,
|
||||
"phase": item.get("phase") or "", "text": text[:300]}
|
||||
if len(text) > 300:
|
||||
entry["truncated"] = True
|
||||
return [entry]
|
||||
if item_type == "reasoning":
|
||||
summary = item.get("summary") or item.get("content") or []
|
||||
text = " ".join(s for s in summary if isinstance(s, str)).strip()
|
||||
|
||||
Reference in new issue
Block a user