← 返回 Skills 市场
ayalili

tool-call-retry

作者 Ayalili · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ 安全检测通过
1414
总下载
1
收藏
13
当前安装
2
版本数
在 OpenClaw 中安装
/install tool-call-retry
功能描述
Auto retry & fix LLM tool calls with exponential backoff, format validation, error correction, boost tool call success rate by 90%
使用说明 (SKILL.md)

🔥 工具调用自动重试器

核心亮点

  1. 成功率提升90%+:内置指数退避重试、格式校验、错误自动修复,解决Agent工具调用不稳定的核心痛点
  2. 🛡️ 全链路异常兜底:自定义错误处理、参数修复逻辑,支持复杂场景下的错误自愈
  3. 零侵入增强:无需修改原有工具代码,一行封装即可获得重试能力,性能开销\x3C1ms
  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 幂等性键,相同键的调用只会执行一次

💡 开箱即用示例

基础用法(零配置)

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" }
});

带结果校验

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

高级用法(错误自动修复)

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行代码,无额外性能开销
安全使用建议
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; ensure callbacks you provide are safe and don't leak sensitive data. 3) Idempotency is handled in-memory only (per process); for long-lived deduplication across restarts you’ll need your own persistent store. 4) If your toolFn has side effects (database writes, payments, emails), use idempotencyKey and tune maxRetries to avoid duplicate side effects. 5) The skill logs to console and uses setTimeout for delays — no hidden network exfiltration is present in the skill itself. Overall it is coherent and small, but review/verify any callbacks you pass in and the remote zod dependency before use.
功能分析
Type: OpenClaw Skill Name: tool-call-retry Version: 1.0.1 The skill is a utility wrapper designed to provide exponential backoff retries and error correction for other tool calls. The implementation in `index.ts` uses standard TypeScript logic and the Zod library for parameter validation, aligning perfectly with its stated purpose in `SKILL.md`. No evidence of data exfiltration, unauthorized execution, or malicious prompt injection was found.
能力评估
Purpose & Capability
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.
Instruction Scope
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 should be considered by the integrator.
Install Mechanism
No explicit install spec; this is instruction/code-only. The implementation imports zod from deno.land via an HTTPS URL (https://deno.land/x/[email protected]). 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.
Credentials
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.
Persistence & Privilege
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.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install tool-call-retry
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /tool-call-retry 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
- Removed the skill.yaml file from the project. - Skill metadata (name, description) is now provided exclusively in SKILL.md. - No functional or API changes in this version.
v1.0.0
- Initial release of tool-call-retry v1.0.0. - Adds automatic retry with exponential backoff for tool/API calls. - Includes result format validation and custom error correction logic. - Supports idempotency keys to prevent repeated side effects. - Provides plug-and-play usage with minimal configuration required.
元数据
Slug tool-call-retry
版本 1.0.1
许可证 MIT-0
累计安装 13
当前安装数 13
历史版本数 2
常见问题

tool-call-retry 是什么?

Auto retry & fix LLM tool calls with exponential backoff, format validation, error correction, boost tool call success rate by 90%. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1414 次。

如何安装 tool-call-retry?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install tool-call-retry」即可一键安装,无需额外配置。

tool-call-retry 是免费的吗?

是的,tool-call-retry 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

tool-call-retry 支持哪些平台?

tool-call-retry 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 tool-call-retry?

由 Ayalili(@ayalili)开发并维护,当前版本 v1.0.1。

💬 留言讨论