- 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.
Requires local file system write access for offloading. The loop-guard helper script requires manual execution to enforce hard process termination.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by 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 scan
Security scan passed 2 months ago