token-bucket
Shared token bucket: many agents, one upstream rate limit — One rate limiter shared by every agent in your fleet. take(cost) atomically spends tokens if available and returns allowed plus remaining, or refuses with retryAfterMs until enough tokens refill. capacity and refillPerSecond are fixed when the bucket is first used; a call with different settings is refused so two fleets cannot silently disagree. Use a requestId so a retried take is not charged twi
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"op": "<op>",
"bucket": "<bucket>",
"capacity": "<capacity>",
"refillPerSecond": "<refillPerSecond>"
},
"name": "token-bucket"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| op | Yes | ||
| cost | No | Tokens to spend; default 1. | |
| bucket | Yes | Bucket name, e.g. openai:org-123:rpm. | |
| capacity | Yes | ||
| tenantId | No | Required for API-key callers (namespaced as key:<tenantId>; keep it unguessable). Ignored when a wallet paid: the payer address is the tenant. | |
| requestId | No | Caller-chosen id for this mutation. A retry with the same id and same input returns the stored response (24 h) instead of applying twice; the same id with different input is rejected. Send one on every mutation you may retry: without it a retry is applied again (fleet-memory record appends a duplicate; a repeated spend-ledger commit or release answers NO_HOLD because the first call already took effect). | |
| refillPerSecond | Yes |