20260706:新增一些文章
This commit is contained in:
41
concepts/watchdog-pattern.md
Normal file
41
concepts/watchdog-pattern.md
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
title: "Watchdog Pattern(看门狗模式)"
|
||||
created: 2026-06-29
|
||||
updated: 2026-06-29
|
||||
type: concept
|
||||
tags: [safety, loop-engineering, reliability, pattern]
|
||||
sources: [[prompt-to-loop-engineering-2026]]
|
||||
confidence: high
|
||||
---
|
||||
|
||||
# Watchdog Pattern
|
||||
|
||||
> 在 [[loop-engineering|Loop Engineering]] 中,看门狗是专门防御**自旋死循环**的安全机制——独立于主异步线程的外部进程监控 CPU,越过应用层直接强杀。
|
||||
|
||||
## 为什么需要看门狗
|
||||
|
||||
[[circuit-breaker-pattern|熔断器]] 依赖任务级失败计数,但以下场景熔断器无法覆盖:
|
||||
|
||||
- 退避策略缺失导致的自旋(retry loop without backoff)
|
||||
- 模型进入"空转"状态(不断生成但不产生有效输出)
|
||||
- I/O 阻塞导致的假性存活(进程存在但无进展)
|
||||
|
||||
## 工作机制
|
||||
|
||||
1. **独立进程**:与 Agent 主进程完全隔离
|
||||
2. **CPU 监控**:检测占用率是否长期满载
|
||||
3. **I/O 检测**:长时间无 I/O 交互 → 判定为死循环
|
||||
4. **SIGKILL**:越过应用层直接发信号强杀并回收资源
|
||||
|
||||
## 与熔断器的分工
|
||||
|
||||
| 机制 | 监控对象 | 触发条件 | 响应 |
|
||||
|------|---------|---------|------|
|
||||
| [[circuit-breaker-pattern|熔断器]] | 任务级失败 | 连续失败 N 次 | 跳闸 + 回退 |
|
||||
| [[watchdog-pattern|看门狗]] | 进程级异常 | CPU 满载 + 无 I/O | SIGKILL |
|
||||
|
||||
## 相关概念
|
||||
|
||||
- [[circuit-breaker-pattern|熔断器]]
|
||||
- [[loop-contract|Loop Contract]]
|
||||
- [[loop-engineering|Loop Engineering]]
|
||||
Reference in New Issue
Block a user