- Home
- Skills
- Agents & Orchestration
- Token-Guard — Caching & Autonomy Optimizer
Token-Guard — Caching & Autonomy Optimizer
Cut agent input-token cost up to 80% and hard-stop runaway loops with cache-aware compaction, non-destructive offload, and deterministic loop guards.
$39
Works with the AI Agents you already use
Token-Guard — Caching & Autonomy Optimizer
Example session with this skill installed
I'm starting a large refactor. Initialize Token-Guard to manage this session. Set a budget of 50 iterations and offload any tool outputs larger than 2KB.
- Read your context and instructions
- Compiled the token-guard
I have initialized the Token-Guard control layer for this refactoring session. I will monitor the execution budget and apply cache-aware compaction as the context grows. Tool outputs exceeding 2KB will be offloaded to local storage with pointer references maintained in the active window.
Session Optimization Plan
| Component | Policy / Limit | Strategy |
|---|---|---|
| Loop Guard | 50 Iterations | Hard-stop at iteration 45 for manual review. |
| Token Budget | 200k Input Tokens | Monitor via scripts/token_guard.py. |
| Offload Trigger | > 2,048 Bytes | Move to logs/offload_[timestamp].jsonl. |
| Compaction | Every 5 turns | Preserve system prefix; emit delta summaries. |
Initial Budget Ledger
{
"max_iterations": 50,
"token_budget": 200000,
"used": 450,
"halted": false,
"session_start": "2023-10-27T10:00:00Z"
}
Next steps
- Run
python scripts/token_guard.py --limit 50in a separate terminal to enable external process monitoring. - Approve the creation of the
./logsdirectory for artifact offloading. - Proceed with the first step of the refactor; I will alert you before any destructive compaction occurs.
Connects securely to your tools. The creator never sees your data.
About this skill
Token-Guard keeps long-horizon coding-agent sessions cheap and bounded. It's a bundled control layer of three cooperating SKILL.md sub-skills:
- Cache-aware compaction — protects a byte-stable system+early prefix and emits incremental delta summaries, so prompt-cache hits stay near 90% (no cache-miss spikes from naive rewrites).
- Non-destructive offload — moves verbose tool output and documents to local JSONL/temp files with a searchable pointer, so nothing is deleted and the agent can re-read on demand.
- Deterministic loop guards — enforce hard max-iteration, step-wise token-budget, and retry caps the model cannot override, stopping Infinite Agentic Loops that otherwise burn $50/day.
What you get: a root SKILL.md orchestrator + 3 sub-skills (compaction, offload, loop-guard), an MIT-licensed helper script, and worked examples. Net effect: up to ~80% lower input-token cost on long sessions, and a hard stop on runaway loops.
Human-in-the-Loop by design: before any destructive compaction or offload, Token-Guard presents a plan and waits for your explicit approval. It never invents metrics or silently drops your code.
Works with Claude Code, Cursor, Gemini CLI, Codex CLI, and any agent that loads SKILL.md.
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scanned
Verified clean 1 month ago
- Passed all security checks, Safe to install