tool-call-retry

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

3,891 stars

Best use case

tool-call-retry is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

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

Teams using tool-call-retry should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/tool-call-retry/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/ayalili/tool-call-retry/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/tool-call-retry/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How tool-call-retry Compares

Feature / Agenttool-call-retryStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

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

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# 🔥 工具调用自动重试器
## 核心亮点
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行代码,无额外性能开销

Related Skills

AI Coding Toolkit — Master Every AI Coding Assistant

3891
from openclaw/skills

> The complete methodology for 10X productivity with AI-assisted development. Covers Cursor, Windsurf, Cline, Aider, Claude Code, GitHub Copilot, and more — tool-agnostic principles that work everywhere.

china-tools-sourcing

3891
from openclaw/skills

Comprehensive tools industry sourcing guide for international buyers – provides detailed information about China's hand tools, power tools, garden tools, measuring tools, and industrial tool manufacturing clusters, supply chain structure, regional specializations, and industry trends (2026 updated).

github-tools

3891
from openclaw/skills

Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.

DevOps & Infrastructure

Bland AI — Voice Calling Skill

3891
from openclaw/skills

Make and manage AI-powered phone calls via the Bland AI API.

Workflow & Productivity

pdf-tool

3891
from openclaw/skills

PDF文字提取工具 — 支持从PDF文件中提取文字内容,用于解析简历。by Barry

phone-calls

3891
from openclaw/skills

Make and manage real phone calls through Twilio. Handles outbound calls with a stated objective, monitors call progress, and returns transcripts and summaries. Use when the user wants to call someone, check on a call, or review call history.

call-screening

3891
from openclaw/skills

Screen incoming phone calls with an AI receptionist. Amber answers calls, identifies the caller, determines the purpose, takes a message, and delivers a structured summary. Use when the user wants to set up call screening, check screened call results, or customize screening behavior.

devtools-secrets

3891
from openclaw/skills

Knowledge and guardrails for the mise + fnox + infisical secrets toolchain. Use when the user asks to "configure secrets", "set up fnox", "infisical", "mise env", "secrets management", "environment variables for secrets", or mentions secret injection, secret providers, or env var hygiene.

searxng-tool-for-openclaw

3891
from openclaw/skills

Install an OpenClaw plugin that adds SearXNG-powered web search without paid search APIs.

Feishu SuperToolkit

3891
from openclaw/skills

飞书超级工具包 - 集成文件发送(含音频卡片)、日历、审批、多维表格、通讯录、考勤六大模块

openclaw-tool-executor

3891
from openclaw/skills

Use this skill whenever the user asks for information from, or wants to take an action in, a third-party tool or service. This includes — but is not limited to — searching the web, reading or writing documents, sending messages, querying databases, managing tasks, fetching data from APIs, or interacting with any connected SaaS product (e.g. "search Exa for...", "read my Notion page", "send a Slack message", "get my Google Sheet", "create a GitHub issue", "query Snowflake", "look up a HubSpot contact"). Trigger this skill any time the user's request involves an external service, integration, or data source — even if the provider is not explicitly named. Handles OAuth and non-OAuth (API Key, Bearer, Basic) connections, tool discovery, execution, and proxy fallback via Scalekit Connect. ## Provider Mapping Some services are accessed through a different provider name in Scalekit. Always use the mapped provider name below: | User asks about | Use provider | |---|---| | LinkedIn — profiles, jobs, companies, posts, people search, ads, groups | `HARVESTAPI` |

feishu-memory-recall

3891
from openclaw/skills

Cross-group memory, search, and event sharing for OpenClaw Feishu agents