> ## Documentation Index
> Fetch the complete documentation index at: https://docs.biconomy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Session Policies Overview

> Control what your agent can do with fine-grained policies

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

<CardGroup cols={2}>
  <Card title="Sudo Policy" icon="crown" href="/agents-automation/policies/sudo">
    Full access to specific functions. Simple but powerful.
  </Card>

  <Card title="Universal Action Policy" icon="sliders" href="/agents-automation/policies/universal-action">
    Fine-grained parameter-level control with spending limits.
  </Card>

  <Card title="Timeframe Policy" icon="clock" href="/agents-automation/policies/time-range">
    Restrict when the agent can act.
  </Card>

  <Card title="Usage Limit Policy" icon="gauge" href="/agents-automation/policies/usage-limit">
    Cap the total number of actions.
  </Card>
</CardGroup>

## 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:

```typescript theme={null}
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 Needs | Use This Policy |
| - | - |
| Full access to trusted protocol | Sudo |
| Spending limits per action | Universal Action |
| Total spending caps | Universal Action (with `isLimited: true`) |
| Recipient whitelisting | Universal Action |
| Time-limited access | Timeframe |
| Max number of actions | Usage Limit |
| Scheduled execution windows | Timeframe |

## 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:

| Layer | Control | Example |
| - | - | - |
| **Contract** | Which contracts can be called | Only Uniswap, Morpho |
| **Function** | Which functions are allowed | Only `swap()`, not `approve()` |
| **Parameter** | Rules on arguments | Max \$500 per trade |
| **Time** | When agent can act | Next 7 days only |
| **Usage** | How many times | Max 50 trades |
| **Gas** | Max gas spend | \$20 USDC for gas |

## Next Steps

<CardGroup cols={2}>
  <Card title="Sudo Policy" icon="crown" href="/agents-automation/policies/sudo">
    Start here for simple agents
  </Card>

  <Card title="Universal Action" icon="sliders" href="/agents-automation/policies/universal-action">
    Start here for DeFi agents
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.