Policies
Policies are the rules an agent must obey. They are enforced by the smart account itself, not by your code. You cannot bypass a policy by writing different application logic — every transaction the agent attempts must satisfy the active policy bundle or it reverts at the wallet level.
Policy types
| Type | Limits | Example |
|---|---|---|
spend | Token, amount, period | { type: "spend", token: "USDC", amount: 50, period: "weekly" } |
contract | Whitelist of contract names or addresses | { type: "contract", whitelist: ["uniswap.eth"] } |
expires | Hard expiry timestamp | { type: "expires", at: "2026-08-01" } |
rate | Max transactions per window | { type: "rate", count: 10, period: "hourly" } |
Composition
Policies compose with AND. Every transaction must satisfy every active policy.
import { createAgent } from "@agensai/sdk";
await createAgent({
name: "my-agent",
policies: [
{ type: "spend", token: "USDC", amount: 50, period: "weekly" },
{ type: "contract", whitelist: ["uniswap.eth"] },
{ type: "expires", at: "2026-08-01" },
{ type: "rate", count: 5, period: "hourly" },
],
});A swap on Uniswap of 30 USDC at 9am Tuesday: passes. The same swap on Sushiswap: rejected (contract not in whitelist). The same swap, tenth time within the hour: rejected (rate cap).
Adding a policy later
agensai policy add my-agent.agensai.eth \
--type rate --count 5 --period hourlyawait agent.addPolicy({ type: "rate", count: 5, period: "hourly" });Policy additions are onchain.
Revocation
agensai revoke <agent> (CLI) or agent.revoke() (SDK) cancels every policy at once. Revocation is permanent and verifiable in any block explorer.
Why onchain
Off-chain policies are guidelines. Onchain policies are guarantees. AGENSAI agents inherit ERC-7715 from the JAW smart account stack, which means the rules live in the wallet contract — your application code, your LLM, even a compromised server cannot exceed them.