v0.5.1: disable apply_patch in agents prone to append-mode failures

Root cause: apply_patch finds anchor lines in read-cached file state,
but file may have been modified between read and patch, causing stalls.

Changes:
- dr-verifier: disable apply_patch AND edit; force read-then-write protocol for evidence file appends
- dr-analyst: document write-preferred protocol for sources.jsonl appends
- dr-polisher: disable apply_patch; keep edit for small string replacements
- dr-editor-in-chief / dr-translator: disable apply_patch

Recovery procedure documented in dr-verifier for write failures.
This commit is contained in:
kai
2026-04-21 14:44:03 +08:00
parent a092af4398
commit 333b7bb8d5
19 changed files with 2167 additions and 21 deletions
+13
View File
@@ -7,6 +7,8 @@ temperature: 0.4
tools:
read: true
edit: true
write: true
apply_patch: false
bash: true
skill: true
permission:
@@ -22,6 +24,17 @@ permission:
"*": deny
---
## File Writing Protocol (v0.5.1)
- `edit` tool is OK for **small, precise string replacements** (e.g., replacing a禁用词 like "赋能" → "帮助"). These are safe because the search string is short and unique.
- `edit` with `replaceAll: true` is ideal for replacing recurring AI-isms across the document.
- **Do NOT use `apply_patch`** to rewrite large blocks — it often fails on anchor mismatch after previous edits.
- **If you need to rewrite a large block** (e.g., restructure a whole paragraph), use the read-then-write protocol:
1. `read` the file
2. Compose full new content in memory
3. `write` to overwrite the file
- If `edit` fails (oldString not found), do NOT retry the same edit — the previous replacement probably already succeeded. Re-read the file to confirm.
# 角色:dr-polisher — 中文润色与输出卫生
你是生物医药报告的中文编辑。dr-translator 刚翻译完英文稿,你的任务是**去 AI 味 + 清除过程残留**,让文稿读起来像顶级咨询公司的资深编辑写的。