Skip to main content
AIDiveForge AIDiveForge
🛑

Tool-Call Budget Guard

Agents & Workflows · by AIDiveForge · Apr 20, 2026 · Intermediate

Plan and enforce explicit limits around a tool-calling workflow.

Get a budget ledger, stopping condition and graceful partial-result plan.

Free · 2 KB · SKILL.md, instructions and example files. Provide tool names, per-call cost assumptions and the allowed total budget.

A worked example

A small example to try before using your own data.

Input

{
  "unit": "calls",
  "limit": 3,
  "used": 2,
  "requested_calls": 2
}

Expected result

{
  "decision": "deny batch",
  "remaining": 1,
  "alternative": "Run at most one authorized call, or return the current partial result. Do not increase the cap."
}

What to check: No more than one additional call may run. A batch must be reserved before dispatch, not checked after it spends the budget.

Limits: This recipe is an integration contract, not a built-in billing control. An actual tool dispatcher must enforce the ledger atomically.

Worked example included. Model-specific performance and vendor compatibility have not been benchmarked.

Installation options and other formats

Install this skill

An agent skill starts with SKILL.md. The ZIP also includes its examples and any helper scripts. Drop the file into your tool of choice — or pick a different format if you use Cursor, Windsurf, Copilot, or something else.

Download SKILL.md
python3 - <<'ADF_SKILL_INSTALL'
import hashlib, io, os, stat, tempfile, urllib.request, zipfile
from pathlib import Path, PurePosixPath
folder = "tool-call-budget-guard"
root = Path(os.environ.get('ADF_SKILL_ROOT', str(Path.home() / '.claude' / 'skills'))).expanduser()
destination = root / folder
if destination.exists() or destination.is_symlink():
    raise SystemExit('An installation already exists. Back it up and merge the ZIP deliberately.')
root.mkdir(parents=True, exist_ok=True)
request = urllib.request.Request("https://aidiveforge.com/skill/tool-call-budget-guard.zip", headers={'User-Agent': 'AIDiveForge-Resource-Installer/1.0 (+https://aidiveforge.com/skills/)'})
with urllib.request.urlopen(request, timeout=30) as response:
    data = response.read(8 * 1024 * 1024 + 1)
if len(data) > 8 * 1024 * 1024 or hashlib.sha256(data).hexdigest() != "376946b7eaac4e4247817f1080f27791b99f08dbbf157e35c3a8dd31c5930c86":
    raise SystemExit('The download did not match this reviewed bundle. No files were installed.')
with zipfile.ZipFile(io.BytesIO(data)) as archive, tempfile.TemporaryDirectory(prefix='.adf-skill-', dir=root) as temporary:
    members = archive.infolist()
    if len(members) > 100 or sum(m.file_size for m in members) > 16 * 1024 * 1024:
        raise SystemExit('Unexpected archive size')
    for member in members:
        name = PurePosixPath(member.filename)
        if name.is_absolute() or '..' in name.parts or not name.parts or name.parts[0] != folder or '\\' in member.filename or stat.S_ISLNK(member.external_attr >> 16):
            raise SystemExit('Unsafe archive entry; nothing was installed')
        target = Path(temporary).joinpath(*name.parts)
        if member.is_dir():
            target.mkdir(parents=True, exist_ok=True)
        else:
            target.parent.mkdir(parents=True, exist_ok=True)
            with target.open('xb') as stream:
                stream.write(archive.read(member))
    staged = Path(temporary) / folder
    if not (staged / 'SKILL.md').is_file() or destination.exists() or destination.is_symlink():
        raise SystemExit('The skill could not be installed without replacing existing data')
    os.rename(staged, destination)
print('Installed the complete skill folder:', destination)
ADF_SKILL_INSTALL

Claude Code: ~/.claude/skills/tool-call-budget-guard/SKILL.md. Codex: ~/.codex/skills/tool-call-budget-guard/SKILL.md. Keep the complete ZIP folder when helper scripts are included.

🧠 Why it works

No more than one additional call may run. A batch must be reserved before dispatch, not checked after it spends the budget.

⚙️ How it works

  1. Represent budget units explicitly: calls, tokens, money or elapsed time are not interchangeable.
  1. Reserve budget for the next operation before dispatch and deny operations that exceed the remaining allowance.
  1. Reconcile known actual cost after the call and keep failed/unknown-cost calls visible.
  1. Define the useful partial result to return when a limit is reached; never silently raise the cap.
  1. Test the boundary case where remaining budget equals one call and the case where it is insufficient.

Description

Get a budget ledger, stopping condition and graceful partial-result plan.

Provide tool names, per-call cost assumptions and the allowed total budget.

Limits: This recipe is an integration contract, not a built-in billing control. An actual tool dispatcher must enforce the ledger atomically.

Recommended Use

Tools and workflow packs this skill pairs well with. Forge picks are auto-generated from category + capability signals; Community picks are added by people who've used the pairing.

No matches yet. Be the first to suggest a pairing, or the Forge will populate suggestions as signals align.