Skip to main content
Glama

budget_spend

Deduct tokens from the FederatedBudget for an agent's LLM call. Returns approval with spent and remaining, or denial when budget ceiling would be exceeded.

Instructions

Deduct tokens from the global FederatedBudget on behalf of an agent. Returns {ok:true, allowed:true, spent, remaining} when approved, or {ok:true, allowed:false, deniedReason, remaining} when the ceiling would be exceeded. Returns {ok:false, error:"..."} if tokens is not a positive integer. tokens represents the estimated cost of the upcoming LLM call — pass the expected usage before invoking the model; agent_id is tracked individually in the spend log and reported by budget_status. Call budget_status first to check remaining balance; never attempt an LLM call after receiving allowed:false.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idYesThe agent spending tokens
tokensYesNumber of tokens to spend (positive integer)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations; description covers three return shapes (success, ceiling exceeded, invalid input). Lacks mention of idempotency, authorization, or behavior for unknown agent_id, but adequately explains failure modes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four sentences, front-loaded with purpose, then return shapes, then usage notes. No redundant or unnecessary text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers all success/error returns and usage advice. Slightly lacking on idempotency and concurrency, but adequate for a straightforward deduction tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema descriptions exist for both params. Description adds that tokens is estimated LLM cost and agent_id is tracked in spend log, providing useful context beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Verb 'deduct' and resource 'global FederatedBudget' clearly state action. Distinct from siblings like budget_status (check balance) and budget_set_ceiling (set limit).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly advises calling budget_status first and never making an LLM call after receiving allowed:false. Also states to pass tokens before invoking model.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Jovancoding/network-ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server