Koskamo

Enforce per-session spend limits in OpenClaw

Prevents excessive API costs by blocking tool calls and model turns when a session's estimated usage exceeds a defined ceiling, ensuring predictable spending per session.

How it works

Read-onlyOperations and infrastructure

The agent configures the AgentBill MCP server as a ClawHub plugin within the OpenClaw environment. It sets a specific ceiling (in tokens or calls) for each session. Before every tool call or model turn, the agent checks the current running total plus an estimate of the next step against this ceiling. If the limit would be exceeded, the agent refuses the action, returning a refusal message to OpenClaw's gate hook. This ensures that no further resources are consumed in that session until the ceiling is raised or a new session is started.

Prompt

Paste this into an agent that has the servers below connected. Adjust the names and dates to your own.

Prompt for Enforce per-session spend limits in OpenClaw
Configure the AgentBill plugin in OpenClaw to enforce a spend ceiling of 500,000 tokens per session. Ensure the 'allowConversationAccess' hook is enabled so that model turns are also checked against the limit, not just tool calls. Verify that the plugin correctly refuses calls with 'task_ceiling_exceeded' when the limit is reached.

MCP servers it needs

Source

The vendor page this playbook is drawn from, and the passage that supports it.

Before every tool call, and before every model turn on OpenClaw's embedded and CLI runners, the plugin asks AgentBill whether the session's running total plus an estimate of what comes next would pass it.
OpenClaw spend limit: one ceiling per session, as a ClawHub plugin · AgentBill

Each playbook is drawn from the vendor page it cites and reviewed by Koskamo before it is published. Koskamo does not run these servers or your agent: check what each tool will do before you let it act on your accounts.