@t-chen-cn

Retry Plugin Build

OpenClaw plugin: 拦截 /retry 和 /重试,清除上一轮对话上下文

当前版本
v1.0.0
code-plugin社区source-linked

Retry Plugin for OpenClaw

拦截 /retry/重试 命令,清除上一轮对话上下文,让 Agent 在干净的上下文中重新回复。

工作原理

用户发送 /retry 或 /重试
    ↓
Gateway 收到消息
    ↓
┌─ Retry Plugin ─────────────────────────────┐
│  1. message_received hook 检测到 /retry     │
│  2. 立即截断当前 session 的 JSONL           │
│     → 移除倒数第二轮 user+assistant 对话     │
│     → 自动创建 .bak 备份                    │
│  3. before_prompt_build hook 注入系统指令    │
│     → LLM 回复 "🧹 已清除..."               │
│  4. 用户重新发送消息                         │
│     → Agent 在干净的上下文中回复             │
└────────────────────────────────────────────┘

全程 0 LLM 参与理解命令,完全确定性执行。

安装

# 从 ClawHub 安装(推荐)
openclaw plugins install clawhub:openclaw-retry-plugin

# 从 GitHub 安装
openclaw plugins install git:github.com:tchen001/openclaw-retry-plugin

# 本地安装
openclaw plugins install --link /path/to/openclaw-retry-plugin

# 安装后必须重启 Gateway
openclaw gateway restart

使用

在任何支持的 Agent 对话中发送:

命令效果
/retry清除上一轮对话,Agent 回复"已清除"
/重试同上

示例:

你: 帮我写一封邮件给客户
Agent: [回复了你不满意的内容]
你: /retry
Agent: 🧹 已清除上一轮对话~可以重新发送了 😊
你: 帮我写一封邮件给客户,语气正式一点
Agent: [基于干净上下文重新回复]

配置

openclaw.jsonplugins.entries.retry-plugin 中配置:

{
  "plugins": {
    "entries": {
      "retry-plugin": {
        "enabled": true,
        "config": {
          "retryTriggers": ["/retry", "/重试"],
          "responseText": "🧹 已清除上一轮对话~可以重新发送了 😊"
        }
      }
    }
  }
}

兼容性

  • OpenClaw >= 2026.3.24-beta.2
  • 支持所有 Agent(main, linling_x, tangyvan_x, yunyao 等)
  • 支持所有 Channel(Telegram, Discord, WebChat 等)

License

MIT

源码与版本

源码仓库

T-Chen-CN/openclaw-retry-plugin

打开仓库

源码提交

a2a99276f8ed9694acc87484d4ac9eb4251786a6

查看提交

安装命令

openclaw plugins install clawhub:openclaw-retry-plugin

元数据

  • 包名: openclaw-retry-plugin
  • 创建时间: 2026/05/08
  • 更新时间: 2026/05/08
  • 执行代码:
  • 源码标签: a2a99276f8ed9694acc87484d4ac9eb4251786a6

兼容性

  • 构建于 OpenClaw: 2026.3.24-beta.2
  • 插件 API 范围: >=2026.3.24-beta.2
  • 标签: latest
  • 文件数: 5