# Send Token Guard to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "token-guard",
    "name": "Token Guard",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/edmonddantesj/token-guard",
    "canonicalUrl": "https://clawhub.ai/edmonddantesj/token-guard",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/token-guard",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=token-guard",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "SKILL.md",
      "scripts/token_guard.py"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "token-guard",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-10T01:31:45.445Z",
      "expiresAt": "2026-05-17T01:31:45.445Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=token-guard",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=token-guard",
        "contentDisposition": "attachment; filename=\"token-guard-1.5.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "token-guard"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/token-guard"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/token-guard",
    "downloadUrl": "https://openagent3.xyz/downloads/token-guard",
    "agentUrl": "https://openagent3.xyz/skills/token-guard/agent",
    "manifestUrl": "https://openagent3.xyz/skills/token-guard/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/token-guard/agent.md"
  }
}
```
## Documentation

### TokenGuard — LLM API 429 Prevention Engine

Version: 1.5.0
Author: Aoineco & Co.
License: MIT
Tags: rate-limit, 429, token-management, cost-optimization, llm-guard, high-performance

### Description

Prevents LLM API 429 (Rate Limit / Resource Exhausted) errors by intercepting requests before they're sent. Designed for users on free/low-cost API plans who need maximum intelligence per dollar.

Core philosophy: "Intelligence is measured not by how much you spend, but by how little you need."

### Problem

When using LLM APIs (especially Google Gemini Flash with 1M TPM limit):

Large documents (docx, PDFs) can consume the entire minute quota in one request
Failed requests still count toward token usage
Retry loops after 429 errors waste more tokens → death spiral
No built-in way to detect runaway/duplicate requests

### Features

FeatureDescriptionPre-flight Token EstimationEstimates token count before API call (CJK-aware, no tiktoken dependency)Real-time Quota TrackingTracks per-model per-minute token usage with sliding windowSmart ThrottleAuto-waits when quota > 80%, blocks at > 95%Duplicate DetectionBlocks identical requests within 60s window (3+ = runaway)Response CachingCaches successful responses for duplicate requestsAuto Model FallbackSwitches to cheaper/available model when primary is exhausted429 Error ParserExtracts exact retry delay from Google/Anthropic error responsesBatch vs Mistake DetectionDistinguishes intentional bulk processing from error loops

### Supported Models

Pre-configured quotas for:

gemini-3-flash (1M TPM)
gemini-3-pro (2M TPM)
claude-haiku (50K TPM)
claude-sonnet (200K TPM)
claude-opus (200K TPM)
gpt-4o (800K TPM)
deepseek (1M TPM)

Custom quotas can be added for any model.

### Usage

from token_guard import TokenGuard

guard = TokenGuard()

# Before every API call:
decision = guard.check(prompt_text, model="gemini-3-flash")

if decision.action == "proceed":
    response = call_your_api(prompt_text)
    guard.record_usage(decision.estimated_tokens, model="gemini-3-flash")
    guard.cache_response(prompt_text, response)

elif decision.action == "wait":
    time.sleep(decision.wait_seconds)
    # retry

elif decision.action == "fallback":
    response = call_your_api(prompt_text, model=decision.fallback_model)

elif decision.action == "block":
    print(f"Blocked: {decision.reason}")

# If you get a 429 error:
guard.record_429("gemini-3-flash", retry_delay=53.0)

### Integration with OpenClaw

Add to your agent's config or use as a middleware:

skills:
  - token-guard

The agent can invoke TokenGuard before any LLM API call to prevent quota exhaustion.

### File Structure

token-guard/
├── SKILL.md          # This file
└── scripts/
    └── token_guard.py  # Main engine (zero external dependencies)

### Status Output Example

{
  "models": {
    "gemini-3-flash": {
      "tpm_limit": 1000000,
      "used_this_minute": 750000,
      "remaining": 250000,
      "usage_pct": "75.0%",
      "status": "🟢 OK"
    }
  },
  "stats": {
    "total_checks": 42,
    "tokens_saved": 128000,
    "blocks": 3,
    "fallbacks": 2
  }
}

### Zero Dependencies

Pure Python 3.10+. No pip install needed. No tiktoken, no external API calls.
Designed for the $7 Bootstrap Protocol — every byte counts.
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: edmonddantesj
- Version: 1.5.0
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-05-10T01:31:45.445Z
- Expires at: 2026-05-17T01:31:45.445Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/token-guard)
- [Send to Agent page](https://openagent3.xyz/skills/token-guard/agent)
- [JSON manifest](https://openagent3.xyz/skills/token-guard/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/token-guard/agent.md)
- [Download page](https://openagent3.xyz/downloads/token-guard)