Limit how fast an agent can act
Cap how many actions of a kind an agent may take per minute, hour or day. A limit on the shell counts every shell command together.
Works with: All four agents. Supported hosts has the detail for each agent.
Steps
1. Start from your current policy
isonapse hook policy export my-policy.luaThis writes your active policy to
my-policy.lua. Copy the rules you want from the example below into it. If the file already has a section of the same name, add the lines to that section.2. Check that it loads
isonapse hook policy check my-policy.luaThis loads the file the way Isonapse does and names any file or folder pattern that can never match. It changes nothing.
3. Make it active
isonapse hook policy activate my-policy.luaThe terminal shows the exact change, and one approval with your login password makes it active. Use a plain terminal window that runs no agent, such as macOS Terminal or Ghostty.
4. Undo it
isonapse hook policy revisionsisonapse hook policy rollback <revision>The first lists earlier policies; the second restores one, with one approval and the password you log in to this computer with. Use a plain terminal window that runs no agent, such as macOS Terminal or Ghostty.
What it does not do
- A limit counts how often, not what: pair it with a rule when the action itself is the problem.
- Counts are kept in memory for each agent session. A new session, a restart or a policy change starts every count again.
- The example's
cap:llm-invokelimit does not limit a coding agent's own model calls.
The policy
The whole example, 04-rate-limits.lua, from the examples Isonapse publishes.
-- 04-rate-limits.lua — per-capability sliding-window counters.
--
-- `rate_limits[<cap>]` declares a counter on the (agent, policy key) pair.
-- The key governs its whole capability subtree, so `tool:Bash` is ONE
-- shared budget across every sub-command (`tool:Bash:git`,
-- `tool:Bash:curl`, …) rather than a separate budget for each. Where a
-- broad and a narrow key both govern a call, both budgets are charged —
-- a narrow key tightens the broad one instead of escaping it.
--
-- Three independent sliding windows are tracked; you can use any
-- combination of the three.
--
-- per_minute — required. Resets after 60s of wall clock.
-- per_hour — optional. Resets after 3600s.
-- per_day — optional. Resets after 86400s.
--
-- Windows are independent: hitting any cap denies the call until that
-- window expires. The denial reason names which window was breached.
--
-- The engine attaches a `warnings` field to a PERMIT result when a
-- counter has 5 or fewer invocations remaining in the minute window —
-- visible in the dashboard / hook output, useful for spotting a
-- runaway-loop before it hits the wall.
--
-- These are hard counters, kept in memory for each agent session: a new
-- session, a restart of Isonapse or a policy reload starts every count
-- again. (Spend counters are different: they persist on disk; see
-- 07-llm-and-coherence.lua.)
--
-- Try it:
-- * 30 successive tool:Bash invocations -> all PERMIT
-- * the 31st -> DENY: "Rate limit exceeded for tool:Bash: 30/30 per minute"
-- * wait 60s, the counter rolls -> next call PERMIT again
return {
policy_version = "rate-limits-v1",
rate_limits = {
-- Shell calls: 30/min is generous for an interactive agent, but the
-- 200/hour cap stops a runaway loop from eating the day's budget in
-- 7 minutes.
["tool:Bash"] = {
per_minute = 30,
per_hour = 200,
per_day = 1000,
},
-- Web egress is the most expensive externally-visible action; lower
-- limit. Operators often pair this with allowed_domains (see
-- 03-domain-rules.lua) so the rate limit applies only to traffic
-- that's already been authorized.
["tool:WebFetch"] = {
per_minute = 10,
per_hour = 60,
},
-- LLM invocations: tight per-minute (sustained-rate protection) but
-- no daily cap — that's what the LLM budget field handles
-- (see 07-llm-and-coherence.lua), persistently and across restarts.
["cap:llm-invoke"] = {
per_minute = 20,
},
},
}
Stuck? Help finds the message you see.