Skip to main content
Policies define the rules that govern what your agent can and cannot do. They’re enforced on-chain by smart contracts—not by trust.

Available Policies

Sudo Policy

Full access to specific functions. Simple but powerful.

Universal Action Policy

Fine-grained parameter-level control with spending limits.

Timeframe Policy

Restrict when the agent can act.

Usage Limit Policy

Cap the total number of actions.

How Policies Work

When your agent tries to execute an action:
Agent gets a session quote with instructions and submits it for execution

MEE broadcasts the transaction to blockchain

Smart contract checks:
  ✓ Is this contract/function allowed?
  ✓ Do parameters pass all policy rules?
  ✓ Is the session still valid (time)?
  ✓ Is usage limit not exceeded?

All checks pass → Execute
Any check fails → Revert

Combining Policies

Real agents typically combine multiple policies for defense in depth:
const functionSignature = toFunctionSelector(
  getAbiItem({ abi: UniswapRouterAbi, name: "exactInputSingle" })
);

const customActions = mcNexus.buildSessionAction({
  type: "custom",
  data: {
    chainIds: [8453, 10],
    contractAddress: UNISWAP_ROUTER,
    functionSignature,
    policies: [
      // Time limit
      {
        type: "timeframe",
        validAfter: now,
        validUntil: now + 7 * DAY,
      },
      // Usage limit
      {
        type: "usageLimit",
        limit: 5n
      },
      // Spending limits
      {
        type: "universal",
        rules: [
          {
            condition: "equal",
            calldataOffset: calldataArgument(2),
            // 10 USDC per tx
            comparisonValue: parseUnits("10", 6)
          }
        ],
      }
    ]
  }
});

Policy Selection Guide

Your Agent NeedsUse This Policy
Full access to trusted protocolSudo
Spending limits per actionUniversal Action
Total spending capsUniversal Action (with isLimited: true)
Recipient whitelistingUniversal Action
Time-limited accessTimeframe
Max number of actionsUsage Limit
Scheduled execution windowsTimeframe

Quick Decision Tree

Is the target contract fully trusted?
├─ Yes: Consider Timeframe + No other restrictive policy
└─ No: Use Universal Action

Does the agent handle user funds?
├─ Yes: Universal Action with spending limits
└─ No: Sudo may be acceptable

Need to limit total actions?
├─ Yes: Add Usage Limit
└─ No: Timeframe may suffice

Security Layers

Always think in layers:
LayerControlExample
ContractWhich contracts can be calledOnly Uniswap, Morpho
FunctionWhich functions are allowedOnly swap(), not approve()
ParameterRules on argumentsMax $500 per trade
TimeWhen agent can actNext 7 days only
UsageHow many timesMax 50 trades
GasMax gas spend$20 USDC for gas

Next Steps

Sudo Policy

Start here for simple agents

Universal Action

Start here for DeFi agents