← Back to Plugins
Tools

Retry

T-Chen-CN By T-Chen-CN 👁 29 views ▲ 0 votes

OpenClaw plugin: intercept /retry, clear last conversation turn

GitHub

Install

openclaw plugins install clawhub:openclaw-retry-plugin

Configuration Example

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

README

# 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 参与理解命令**,完全确定性执行。

## 安装

```bash
# 从 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.json` 的 `plugins.entries.retry-plugin` 中配置:

```json
{
  "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
tools

Comments

Sign in to leave a comment

Loading comments...