feat(review): 审查阶段对齐绘图区分辨率 + 放大取证闭环
发现的缺口:maximized_drawing_area 原先只包住取证循环,审查阶段没被包住 → LLM 在受控子循环里 zoom + 截图拿到的是未最大化的 2110x462(正是上一轮刚解决的 低分辨率问题,在最需要放大看细节的审查阶段又出现了);且审查中的 zoom 不复位视口, 跑完把用户的 CAD 留在最后一次放大处。 改动: 1. __main__.run_review:把 maximized_drawing_area 从「只包取证」扩到「包取证 + 审查」 (两者都要截图);report/annotate 留在 with 之外。 2. phases/review.py:新增 _VIEW_TOOLS;review_frame 拆成外壳 + _review_frame, 外壳 try/finally 里仅当确实动过视口才复位到该图框整幅视图 (zoom_to_window(win, margin=0.02))。纯查结构化数据的路径不受影响。 3. checklist.build_system_prompt:把「可调用只读工具」改写成明确的放大取证协议—— 截图看不清时用 zoom_to_window(坐标由图框/实体 bbox 算)或 zoom_to_entity, 再 get_viewport_screenshot 复核;并约束不要为看图而反复放大。 次生问题(同轮修复):_MAX_OBS_IMAGES 原为硬编码 3,而模型一轮内会发 8 次截图 → 拍了 8 张只回灌 3 张。改为配置项 REVIEW_OBS_IMAGES(默认 6),并把预算耗尽的占位 文案改成明确告知模型「不要再请求截图,请给出结论」。 实测(真实图纸 1 图框,新增 verify_review_maximized.py):取证与审查两阶段窗口均为 [-4,-2,3444,1442](最大化态),结束精确还原 [68,0,2316,960],三项全 PASS; 子循环里 LLM 连发 8 组 zoom_to_window + get_viewport_screenshot,提示词生效。 pytest 304 passed。
This commit is contained in:
1 parent
931a430ba4
commit
e8140f2bc5
11 files changed
+320
-40
No files matched your search
+31
-30
@@ -62,11 +62,13 @@ def run_review(ctx, args):
|
||||
|
||||
system_prompt = build_system_prompt(ctx.checklist, allow_tools=True)
|
||||
|
||||
print("[2/4] 取证:逐图框采集(串行) ...")
|
||||
evidences = []
|
||||
# 截屏前把绘图区最大化(窗口铺满 + 干净屏幕),采集完在 finally 里还原;
|
||||
# 旧版插件没有该工具时静默降级。
|
||||
frame_findings = []
|
||||
|
||||
# 截屏前把绘图区最大化(窗口铺满 + 干净屏幕)。**取证与审查都要截图**——审查阶段的
|
||||
# 受控子循环会按需放大复核,故一并包住,结束在 finally 里还原;旧版插件无此工具时静默降级。
|
||||
with evidence_phase.maximized_drawing_area(ctx):
|
||||
print("[2/4] 取证:逐图框采集(串行) ...")
|
||||
for idx, frame in enumerate(frames, 1):
|
||||
print(
|
||||
f" - 图框 {idx}/{len(frames)} kind={frame.get('kind')} "
|
||||
@@ -82,35 +84,34 @@ def run_review(ctx, args):
|
||||
f"截图 {len(evidence_images(ev))} 张"
|
||||
)
|
||||
|
||||
if args.plan_only:
|
||||
path = _dump_evidence(evidences)
|
||||
print(f"[evidence] 已写入 {path}")
|
||||
return 0
|
||||
if args.plan_only:
|
||||
path = _dump_evidence(evidences)
|
||||
print(f"[evidence] 已写入 {path}")
|
||||
return 0
|
||||
|
||||
print("[3/4] 审查:确定性检查前置 + 逐图框 LLM 审查(含受控只读取证子循环) ...")
|
||||
frame_findings = []
|
||||
for ev in evidences:
|
||||
print(f" - 审查图框 {ev['index']} ...")
|
||||
checks = (
|
||||
checks_phase.run_deterministic_checks(ctx, ev)
|
||||
if config.DETERMINISTIC_CHECKS
|
||||
else []
|
||||
)
|
||||
conclusion = review.review_frame(ctx, ev, system_prompt)
|
||||
finding = findings_mod.build_finding(
|
||||
ev, conclusion, checks, validate_handles=config.VALIDATE_HANDLES
|
||||
)
|
||||
frame_findings.append(finding)
|
||||
print("[3/4] 审查:确定性检查前置 + 逐图框 LLM 审查(含受控只读取证子循环) ...")
|
||||
for ev in evidences:
|
||||
print(f" - 审查图框 {ev['index']} ...")
|
||||
checks = (
|
||||
checks_phase.run_deterministic_checks(ctx, ev)
|
||||
if config.DETERMINISTIC_CHECKS
|
||||
else []
|
||||
)
|
||||
conclusion = review.review_frame(ctx, ev, system_prompt)
|
||||
finding = findings_mod.build_finding(
|
||||
ev, conclusion, checks, validate_handles=config.VALIDATE_HANDLES
|
||||
)
|
||||
frame_findings.append(finding)
|
||||
|
||||
counts = finding["counts"]
|
||||
preview = finding["summary"]
|
||||
if len(preview) > 200:
|
||||
preview = preview[:200] + "..."
|
||||
print(
|
||||
f" 结论:{preview}"
|
||||
f"(确定性 {counts['deterministic']} / LLM {counts['llm']}"
|
||||
f" / 未核实 {counts['unverified']})"
|
||||
)
|
||||
counts = finding["counts"]
|
||||
preview = finding["summary"]
|
||||
if len(preview) > 200:
|
||||
preview = preview[:200] + "..."
|
||||
print(
|
||||
f" 结论:{preview}"
|
||||
f"(确定性 {counts['deterministic']} / LLM {counts['llm']}"
|
||||
f" / 未核实 {counts['unverified']})"
|
||||
)
|
||||
|
||||
print("[4/4] 汇总报告 ...")
|
||||
markdown = report.summarize(ctx, frame_findings)
|
||||
|
||||
Reference in new issue
Block a user