# Token Budget Guard

> Monitors LLM token usage, applies configurable budgets, and alerts when limits are exceeded. Suggests cheaper models or prompt caching.

Token Budget Guard is a free AI agent skill on Agensi by Enrique Hernández, in LLM Ops. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Enrique Hernández](https://www.agensi.io/creators/enrique-hernandez)
- Category: [LLM Ops](https://www.agensi.io/skills/llm-ops)
- Version: 1.0
- Last updated: 2026-11-17
- Security: scan passed (2026-11-17); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/token-budget-guard
- Tags: cost-control, llm-ops, budgeting

## About this skill

You are the **Token Budget Guard**. You help teams monitor, control, and reduce
their LLM spending in the Agent Harness.

1. **Prices must be fresh.** Always fetch or validate prices before reporting.
2. **Never hardcode prices.** Use `references/pricing-sources.md` to know where prices come from.
3. **Budgets are user-defined.** Never assume a budget; ask if it's not provided.
4. **Save reports.** Every analysis must be saved to `.harness/token-budget-guard/reports/`.
5. **NEVER modify the scripts in this skill.** If a script fails, report the error to the user. Do not try to fix the code yourself.

**You MUST use the `bash` tool to run the scripts.** Do not try to calculate the tokens yourself.

1. Run: `bash("python .agents/skills/token-budget-guard/scripts/analyze_session.py --session <latest>")`
2. The script will output a JSON with the token breakdown.

## Requires

- Python 3
- httpx (Python package)
- Agent Harness
- Internet access (openrouter.ai)

Reads session files from .harness/sessions/ and writes reports and a pricing cache to .harness/token-budget-guard/.

## Known limitations

Post-hoc analysis only: it cannot stop LLM calls in real time. Depends on the usage_total field in .harness/sessions/<id>.json; if missing, costs show as $0.00. Pricing is fetched from OpenRouter and may differ from direct-provider prices. Token estimates (when usage is missing) can be off by up to 20%.</known_limitations>
<parameter name="permissions">{"tools": ["read_file", "bash"], "hosts": ["openrouter.ai"], "file_scopes": [".harness/sessions/", ".harness/token-budget-guard/"], "notes": "Fetches public model pricing from OpenRouter and caches it locally for 1 day. Writes markdown reports locally."}

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Token Budget Guard skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### What does Token Budget Guard do?

Monitors LLM token usage, applies configurable budgets, and alerts when limits are exceeded. Suggests cheaper models or prompt caching.

### Which AI agents support Token Budget Guard?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use Token Budget Guard?

Connect your AI agent to Agensi through MCP, then ask it to use Token Budget Guard on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
