fix(spawner): Review M1/M2 — 删除 overflow/timeout 死代码,只保留 precheck;更新设计文档 v5
CI / lint (pull_request) Successful in 8s
CI / test (pull_request) Successful in 8s
CI / notify-on-failure (pull_request) Successful in 0s

M1: overflow/timeout 标记不含 sessionKey,被前置过滤跳过是死代码。
    precheck 总在 overflow 之前触发且含 sessionKey,已覆盖 overflow 场景。
    删除 overflow/timeout 分支,只保留 precheck route=compact_then_truncate。

M2: §24 设计文档新增 v5 章节描述(方案概述、三种触发路径分析、为什么只依赖 precheck)。
This commit is contained in:
cfdaily
2026-06-13 07:01:54 +08:00
parent 36ba629b69
commit 6c6e884ce3
2 changed files with 63 additions and 23 deletions
+15 -20
View File
@@ -1388,13 +1388,18 @@ curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_
agent_id: str, window_seconds: int = 900) -> Optional[str]:
"""v5: 检查 gateway 日志,找最近的 compact 开始标记。
开始标记匹配规则(message 字段包含以下任一):
- "attempting auto-compaction" overflow 路径)
- "[timeout-compaction]" 且包含 "attempting" timeout 路径)
- "[context-overflow-precheck]""route=compact_then_truncate" precheck 路径)
只检测 precheck 路径:message 含 "[context-overflow-precheck]"
"route=compact_then_truncate"。原因:
- overflow 标记("attempting auto-compaction")不含 sessionKey
被 `session_key not in msg` 前置过滤跳过,是死代码。
- timeout 标记推测同理不含 sessionKey。
- precheck 标记含 sessionKey 且实测总在 overflow 之前触发(同一 compact
事件,precheck 先检测到,overflow 是 fallback),所以 precheck 已覆盖
overflow 场景。
- threshold/manual 触发的 compact 无开始标记(静默执行),依赖
counter+lock+status 保护,不需要 gateway 日志检测。
同时需要包含目标 agent 的 sessionKey(如 agent:simayi-challenger:main
超时兜底:开始标记超过 window_seconds 自动忽略。
超时兜底:开始标记超过 window_seconds(默认 15 分钟)自动忽略
返回最近一个开始标记的 UTC ISO 时间字符串(带 Z 后缀),或 None。
"""
@@ -1434,20 +1439,10 @@ curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_
if session_key not in msg:
continue
# 检测三种开始标记
is_start = False
# overflow: "attempting auto-compaction"
if "attempting auto-compaction" in msg:
is_start = True
# timeout: "[timeout-compaction]" + "attempting"
elif "[timeout-compaction]" in msg and "attempting" in msg:
is_start = True
# precheck: "[context-overflow-precheck]" + "route=compact_then_truncate"
elif ("[context-overflow-precheck]" in msg
and "route=compact_then_truncate" in msg):
is_start = True
if not is_start:
# 检测 precheck 路径:route=compact_then_truncate
# overflow/timeout 标记不含 sessionKey,被前置过滤跳过(死代码),已删除
if ("[context-overflow-precheck]" not in msg
or "route=compact_then_truncate" not in msg):
continue
# 解析时间