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
| Name | Required | Description | Default |
|---|---|---|---|
| task | No | Free-text label for what this spend was for, e.g. the task name. | |
| agent_id | Yes | The registered agent the spend belongs to. | |
| confidence | No | Optional 0-1 confidence score for the result this spend produced. Feeds the agent's confidence gate for its next spend request. | |
| input_tokens | No | Number of prompt/input tokens consumed by this call. | |
| output_tokens | No | Number of completion/output tokens consumed by this call. |