agent-interrupt
One command. Agent stops. Memory rolled back. Like it never happened.
When an agent goes off-track — running the wrong task, stuck in a loop, or executing something you didn't intend — agent-interrupt kills it cleanly and rewinds its memory to before it received that task.
Quick Start
After installing, run once to set up all your agents:
CODEBLOCK0
Then just tell your assistant:
CODEBLOCK1
What It Does
- 1. Kills the process — Finds and terminates the agent's running subprocess (precise PID or workspace path fallback)
- Verifies it's dead — Aborts if any process survives; transcript stays untouched
- Backs up memory — Saves the removed messages to
interrupt-logs/ for recovery - Rolls back transcript — Deletes the last user message (the task trigger) and everything after it
- Agent wakes up clean — It enters standby with no memory of the interrupted task
Fuzzy Agent Matching
No need to remember exact agent IDs. It understands names:
CODEBLOCK2
Precise Kill (Recommended)
For agents running long scripts, use run.py wrapper so they can be killed precisely:
CODEBLOCK3
INLINECODE3 automatically adds this protocol to all your agents' AGENTS.md files.
New agents added later are picked up automatically via a background watcher.
Recovery
Every rollback is backed up:
~/.openclaw/agents/<id>/interrupt-logs/rollback-YYYYMMDD-HHMMSS.jsonl
Append the backup lines back to the transcript to restore.
Scripts
| Script | Purpose |
|---|
| INLINECODE5 | Kill + rollback (main script) |
| INLINECODE6 |
One-time setup for all agents |
|
run.py | Wrapper for precise kill support |
|
watch.py | Auto-injects new agents (runs via cron) |
|
mark.py | Manual PID registration (advanced) |
Platform
Works on Windows, Linux, macOS. No external dependencies beyond Python stdlib.
agent-interrupt
一条命令。Agent停止。记忆回滚。仿佛从未发生。
当agent偏离轨道——运行错误任务、陷入循环或执行非预期操作时,agent-interrupt 可将其彻底终止,并将记忆回滚至接收该任务之前的状态。
快速开始
安装后,运行一次即可设置所有agent:
bash
python -X utf8 scripts/install.py
然后只需告知你的助手:
kill dev1
kill all
功能说明
- 1. 终止进程 — 查找并结束agent正在运行的子进程(精确PID或工作区路径回退)
- 验证终止 — 若仍有进程存活则中止操作;对话记录保持不变
- 备份记忆 — 将移除的消息保存至 interrupt-logs/ 目录以便恢复
- 回滚对话 — 删除最后一条用户消息(任务触发器)及其后的所有内容
- Agent干净唤醒 — 进入待机状态,对中断任务毫无记忆
模糊Agent匹配
无需记住精确的agent ID。支持名称识别:
kill dev1 → 匹配 zero_dev1
kill pm → 匹配 zero_pm
kill 开发工程师 → 匹配中文名称
kill all → 中断除主agent外的所有agent
精确终止(推荐)
对于运行长脚本的agent,使用 run.py 封装器以实现精确终止:
bash
替代:python your_script.py
python -X utf8 scripts/run.py --agent
agentid> -- python your_script.py
install.py 会自动将此协议添加至所有agent的 AGENTS.md 文件。
后续新增的agent将通过后台监视器自动捕获。
恢复
每次回滚均有备份:
~/.openclaw/agents//interrupt-logs/rollback-YYYYMMDD-HHMMSS.jsonl
将备份行追加回对话记录即可恢复。
脚本
| 脚本 | 用途 |
|---|
| interrupt.py | 终止+回滚(主脚本) |
| install.py |
一次性设置所有agent |
| run.py | 精确终止支持封装器 |
| watch.py | 自动注入新agent(通过cron运行) |
| mark.py | 手动PID注册(高级功能) |
平台支持
适用于Windows、Linux、macOS。除Python标准库外无外部依赖。