Skip to main content
Glama

record_spend

Log actual token usage for an agent. On budget exceedance, attempt priority-weighted reallocation from donor agents and report donors or a structured budget_exceeded error.

Instructions

Record tokens actually consumed by a registered agent for a task, as raw input/output token counts (not dollar cost). If this pushes the agent over its remaining budget, the library automatically attempts priority-weighted reallocation to cover the shortfall from eligible donor agents before failing. The response reports whether reallocation was triggered and, if so, exactly which donor agents gave up how many tokens. Fails with a structured budget_exceeded error if no combination of donors can cover the shortfall - it never silently overspends.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskNoFree-text label for what this spend was for, e.g. the task name.
agent_idYesThe registered agent the spend belongs to.
confidenceNoOptional 0-1 confidence score for the result this spend produced. Feeds the agent's confidence gate for its next spend request.
input_tokensNoNumber of prompt/input tokens consumed by this call.
output_tokensNoNumber of completion/output tokens consumed by this call.

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure, and it does so thoroughly. It reveals automatic priority-weighted reallocation, donor agent involvement, response contents, structured budget_exceeded errors, and the guarantee that it never silently overspends.

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?

The description is front-loaded with the tool's core purpose and every sentence adds unique value: purpose, reallocation behavior, response shape, and failure mode. It is detailed enough to be actionable without being padded or redundant.

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

Completeness5/5

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

Despite having no output schema and no annotations, the description covers the operation, side effects, return behavior, and error semantics. An agent has everything it needs to decide when to call this tool and what to expect from the call.

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?

The input schema has 100% coverage, so the baseline is 3. The description adds meaningful semantic context by emphasizing that input_tokens and output_tokens are raw token counts rather than dollar costs, which prevents a common misinterpretation that the schema alone does not explicitly guard against.

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?

The description states the specific action ('record tokens actually consumed'), the resource (a registered agent for a task), and the exact unit (raw input/output token counts, not dollar cost). It clearly differentiates this from sibling tools like request_reallocation by explaining that record_spend is the recording action and reallocation happens automatically as a consequence.

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

Usage Guidelines4/5

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

The description makes it clear this is the tool to call when reporting actual token consumption for a completed task, and it explains the reallocation behavior that may follow. It does not explicitly mention when to use request_reallocation directly or what conditions would favor that sibling, so the guidance stops short of naming exclusions.

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

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/swaranshu-borgaonkar/tbc-mcp'

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