openclaw 网盘下载
OpenClaw

技能详情(站内镜像,无评论)

首页 > 技能库 > tool-call-retry

Auto retry & fix LLM tool calls with exponential backoff, format validation, error correction, boost tool call success rate by 90%

开发与 DevOps

许可证:MIT-0

MIT-0 ·免费使用、修改和重新分发。无需归因。

版本:v1.0.1

统计:⭐ 0 · 604 · 9 current installs · 9 all-time installs

0

安装量(当前) 9

🛡 VirusTotal :良性 · OpenClaw :良性

Package:ayalili/tool-call-retry

安全扫描(ClawHub)

  • VirusTotal :良性
  • OpenClaw :良性

OpenClaw 评估

The skill is an internally consistent retry-wrapper for tool calls (exponential backoff, validation, optional error-fixing) and its code, docs, and requirements align with that purpose.

目的

Name, description, SKILL.md, README, and the TypeScript implementation all describe and implement the same functionality: a retry wrapper around a provided tool function with validation, error-handler hooks, and an in-memory idempotency cache. There are no unrelated credentials, binaries, or config paths requested.

说明范围

Runtime instructions and examples only describe calling a provided tool function (toolFn) and optional validator/errorHandler callbacks. The skill does not instruct reading unrelated files, env vars, or sending data to hidden endpoints. Custom callbacks (validatorFn/errorHandlerFn) run user-supplied code and therefore have normal scope to make network calls or access data in their closures — this is expected behavior for this wrapper but shoul…

安装机制

No explicit install spec; this is instruction/code-only. The implementation imports zod from deno.land via an HTTPS URL (https://deno.land/x/zod@v3.22.4). Using a well-known public host like deno.land is common, but it does mean a remote fetch of that dependency will occur at runtime — verify you trust the referenced version.

证书

The skill requests no environment variables or credentials. That matches its purpose. Note: user-supplied callbacks (toolFn, errorHandlerFn, validatorFn) run arbitrary code and may themselves access environment variables or secrets available in the runtime; that is expected but not caused by the skill.

持久

The skill keeps an in-memory idempotencyCache (Map) for idempotencyKey-based deduplication. This cache is process-local and ephemeral (no persistent storage/privileged behavior). 'always' is false and the skill does not modify other skills or system configs.

综合结论

This skill appears to do exactly what it claims: wrap a provided tool function with retry/validation and optional error-fixing. Before installing, consider the following: 1) The implementation imports zod from deno.land at runtime — confirm you trust that remote dependency and version. 2) validatorFn and errorHandlerFn are user-supplied callbacks that execute arbitrary code and therefore can access any runtime secrets or make network calls; en…

安装(复制给龙虾 AI)

将下方整段复制到龙虾中文库对话中,由龙虾按 SKILL.md 完成安装。

请把本段交给龙虾中文库(龙虾 AI)执行:为本机安装 OpenClaw 技能「tool-call-retry」。简介:Auto retry & fix LLM tool calls with exponential backoff, format validation, er…。
请 fetch 以下地址读取 SKILL.md 并按文档完成安装:https://raw.githubusercontent.com/openclaw/skills/refs/heads/main/skills/ayalili/tool-call-retry/SKILL.md
(来源:yingzhi8.cn 技能库)

SKILL.md

打开原始 SKILL.md(GitHub raw)

---
name: tool-call-retry
slug: tool-call-retry
description: Auto retry & fix LLM tool calls with exponential backoff, format validation, error correction, boost tool call success rate by 90%
---

# 🔥 工具调用自动重试器
## 核心亮点
1. ✅ **成功率提升90%+**:内置指数退避重试、格式校验、错误自动修复,解决Agent工具调用不稳定的核心痛点
2. 🛡️ **全链路异常兜底**:自定义错误处理、参数修复逻辑,支持复杂场景下的错误自愈
3. ⚡ **零侵入增强**:无需修改原有工具代码,一行封装即可获得重试能力,性能开销<1ms
4. 🔑 **幂等性保证**:支持幂等性键,避免重复调用导致的副作用

## 🎯 适用场景
- 所有调用外部API/工具的Agent场景
- 不稳定的第三方服务调用
- 大模型工具调用格式错误自动修复
- 高可靠性要求的Agent执行链路

## 📝 参数说明
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|------|------|------|--------|------|
| toolFn | Function | 是 | - | 要执行的工具函数,返回Promise |
| args | any | 否 | {} | 调用工具的参数 |
| maxRetries | number | 否 | 3 | 最大重试次数,1-10 |
| initialDelayMs | number | 否 | 1000 | 初始重试延迟,100-10000ms |
| validatorFn | Function | 否 | ()=>true | 结果校验函数,返回true表示结果合法 |
| errorHandlerFn | Function | 否 | undefined | 错误处理函数,可返回修复后的参数或中止重试 |
| idempotencyKey | string | 否 | undefined | 幂等性键,相同键的调用只会执行一次 |

## 💡 开箱即用示例
### 基础用法(零配置)
```typescript
const fetchWeather = async (params: { city: string }) => {
  const res = await fetch(`https://api.weather.com/${params.city}`);
  return res.json();
};

const result = await skills.toolCallRetry({
  toolFn: fetchWeather,
  args: { city: "Beijing" }
});
```

### 带结果校验
```typescript
const result = await skills.toolCallRetry({
  toolFn: callLLM,
  args: { prompt: "Generate JSON output" },
  validatorFn: (res) => typeof res === "object" && res !== null && res.code === 0,
  maxRetries: 5
});
```

### 高级用法(错误自动修复)
```typescript
const result = await skills.toolCallRetry({
  toolFn: callDatabase,
  args: { sql: "SELECT * FROM users" },
  errorHandlerFn: async (error, attempt) => {
    if (error.message.includes("SQL syntax error")) {
      // 自动修复SQL语法
      const fixedSql = await fixSqlWithLLM(error.message);
      return { args: { sql: fixedSql } };
    }
    if (attempt >= 2) {
      // 重试2次失败后中止
      return { abort: true };
    }
  }
});
```

## 🔧 技术实现说明
- 采用指数退避重试算法,避免服务被打垮
- 全链路类型安全,所有参数带Zod校验
- 支持自定义校验和错误修复逻辑,可扩展性强
- 轻量无依赖,仅200行代码,无额外性能开销