mirror of
https://github.com/cexll/myclaude.git
synced 2026-03-02 15:23:16 +08:00
fix(harness): replace implicit .harness-active absence with explicit .harness-reflect marker for self-reflect triggering
Fixes two bugs: - False positive: stale harness-tasks.json from previous runs triggered self-reflect when harness wasn't active - False negative: self-reflect didn't trigger after harness completed all tasks Generated with SWE-Agent.ai Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
This commit is contained in:
@@ -260,6 +260,11 @@ def main() -> int:
|
||||
# If nothing left to do, allow stop
|
||||
if not pending_eligible and not retryable and not in_progress_blocking:
|
||||
_reset_block_counter(root)
|
||||
# Signal self-reflect hook BEFORE removing active marker
|
||||
try:
|
||||
(root / ".harness-reflect").touch()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
(root / ".harness-active").unlink(missing_ok=True)
|
||||
except Exception:
|
||||
|
||||
@@ -146,13 +146,15 @@ def main() -> int:
|
||||
if not session_id:
|
||||
return 0 # 无 session_id,放行
|
||||
|
||||
# 守卫 1:harness 从未初始化过 → 完全不触发自检
|
||||
# 守卫:仅当 harness 完成所有任务后(.harness-reflect 存在)才触发自省
|
||||
# 这避免了两个问题:
|
||||
# 1. 历史残留的 harness-tasks.json 导致误触发(false positive)
|
||||
# 2. harness-stop.py 移除 .harness-active 后 Claude Code 跳过后续 hook(false negative)
|
||||
root = _find_harness_root(payload)
|
||||
if root is None:
|
||||
return 0 # harness 未曾使用,不触发自省
|
||||
return 0
|
||||
|
||||
# 守卫 2:harness 仍活跃 → 由 harness-stop.py 全权管理
|
||||
if (root / ".harness-active").is_file():
|
||||
if not (root / ".harness-reflect").is_file():
|
||||
return 0
|
||||
|
||||
# 读取最大迭代次数
|
||||
@@ -168,8 +170,12 @@ def main() -> int:
|
||||
# 读取当前计数
|
||||
count = _read_counter(session_id)
|
||||
|
||||
# 超过最大次数,放行
|
||||
# 超过最大次数,清理 marker 并放行
|
||||
if count >= max_iter:
|
||||
try:
|
||||
(root / ".harness-reflect").unlink(missing_ok=True)
|
||||
except Exception:
|
||||
pass
|
||||
return 0
|
||||
|
||||
# 递增计数
|
||||
|
||||
Reference in New Issue
Block a user