Skip to content
Go To Dashboard

Setting Up Rules

Rules define the boundaries within which your agents operate. Set them up before deploying to production to prevent unexpected costs and usage patterns.

Cap how much your agents can spend within a given time period or operation:

ScopeDescriptionUse Case
Per RunMaximum spend for a single agent executionPrevent infinite loops from draining your budget
DailyMaximum spend per 24-hour periodSet a daily budget ceiling
WeeklyMaximum spend per 7-day periodAlign with budget review cycles
MonthlyMaximum spend per calendar monthMatch billing periods

Control how many operations your agents can perform:

ScopeDescriptionUse Case
API CallsMaximum number of requests to a servicePrevent excessive polling or retry loops
TokensMaximum tokens consumed (for LLM services)Control model usage costs
Per ServiceLimits scoped to a specific capabilityDifferent limits for verification vs. search

Navigate to Rules in the Sapiom dashboard and click Create Rule. Choose from Spend Limit, Usage Limit, or Rate Limit types, then set the amount and period.

Set up Rules

  1. Click Create Rule
  2. Select the rule type (spend or usage)
  3. Configure the scope and limit
  4. Choose which agents the rule applies to (all agents, specific agents, or agent groups)
  5. Save the rule

Rules take effect immediately. Existing transactions are not affected, but new transactions will be evaluated against the rule.

When a transaction would exceed a rule’s limit:

  1. Transaction is blocked — The service call does not proceed
  2. Agent receives an error — A clear error message indicates which limit was exceeded
  3. Event is logged — The blocked transaction appears in your dashboard with rule details

Rule Enforcement

Your agent code should handle limit errors gracefully:

try {
const result = await client.get('/service-endpoint');
} catch (error) {
if (error.code === 'LIMIT_EXCEEDED') {
// Handle limit gracefully - log, notify, or fallback
console.log(`Limit exceeded: ${error.rule}`);
}
}
  • Start conservative — Set lower limits initially and raise them as you understand usage patterns
  • Use per-run limits in development — Catch infinite loops before they become expensive
  • Layer your limits — Combine per-run, daily, and monthly limits for comprehensive protection
  • Monitor before restricting — Use the dashboard to understand baseline usage before setting limits
  • Set alerts below limits — Get notified at 80% of a limit so you can adjust before blocking