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

# memanto policy apply

> Sweep the agent's memories and expire everything the policy matches.

# memanto policy apply

Run the expiry sweep. This is what actually moves memories from `active` to
`expired` — saving a policy on its own changes nothing.

The command always shows the policy in force and every matching memory **before**
asking to proceed, so `--dry-run` is only needed when you want to stop at the
preview.

```bash theme={null}
memanto policy apply [OPTIONS]
```

**Options:**

* `-a, --agent TEXT` - Agent identifier (defaults to active agent)
* `--dry-run` - Show what would be expired and stop
* `-n, --limit INTEGER` - Max matched memories to list (default: 20)
* `-y, --yes` - Skip the confirmation prompt

**Examples:**

```bash theme={null}
memanto policy apply --dry-run   # preview only
memanto policy apply             # preview, then confirm
memanto policy apply --yes       # no prompt (for scripts)
```

**Output:**

```
   … retention table and rules printed first …

       Matched by rule
┌───────────────────┬───────┐
│ Rule              │ Count │
├───────────────────┼───────┤
│ retention.context │     1 │
└───────────────────┴───────┘

                               Would be expired
┌───────────────────────┬─────────┬───────────────────┬───────────────────────┐
│ Title                 │ Type    │ Rule              │ Last updated          │
├───────────────────────┼─────────┼───────────────────┼───────────────────────┤
│ Current sprint is the │ context │ retention.context │ Aug 18, 2026 03:44 PM │
│ billing rewrite       │         │                   │                       │
└───────────────────────┴─────────┴───────────────────┴───────────────────────┘

1 of 5 memories will be expired. Expiring is reversible — content is kept and
'memanto memory restore <id>' undoes it.
Apply the policy? [y/N]: y

Expired 1 of 5 memories.
They remain recallable and labelled [EXPIRED].
```

When nothing matches:

```
Nothing to expire. 4 active memories scanned; none are past their retention window yet.
2 already expired (not rescanned; 'memanto policy purge' governs those).
```

<Note>
  A sweep only considers **active** memories, and never re-stamps one that is
  already expired. That second line exists because `apply` reporting 0 while
  [`policy purge`](/cli/policy/purge) reports matches is expected — the two act on
  different populations.
</Note>

**Notes:**

* Requires an active agent, and a policy. With no policy set the sweep is a no-op and says so.
* Every memory in a single sweep is stamped with the same `expired_at`, so a batch is consistent.
* Each expired memory records the rule that retired it as `expired_by`.
* The nightly [`memanto schedule enable`](/cli/schedule/enable) job runs this sweep automatically.
* Undo one with [`memanto memory restore`](/cli/data/restore).
* Backed by the [Apply Expiry Policy](/api-reference/policy/apply-policy) API endpoint.
* See the [Memory Lifecycle](/reference/memory-lifecycle) reference.
