# Memory Rule Formation Resource

> Declares what a memory store accepts from completed agent turns: a selector, an event, and a handler.

# Memory Rule

> This page is auto-generated from the formations OpenAPI spec.
> Do not edit manually — run `pnpm generate-formations-resource-docs` to regenerate.

Declares what a memory store accepts from completed agent turns: a selector, an event, and a handler. With neither `agent_id` nor `tool_id` the built-in extractor runs, configurable through `prompt`, `ai_provider_id` and `model`. See the Memory Rules section of the Memories module docs.

## Syntax

```yaml
type: memory_rule
properties:
  memory_store_id: String
  on: String
  source_agent_ids: String[]
  agent_id: String
  tool_id: String
  action: String
  preset_parameters: Object
  prompt: String
  ai_provider_id: String
  model: String
  enabled: Boolean
```

## Output

The physical resource ID is the **public ID** of the created resource. Reference it from other resources with a `ref` expression:

```yaml
      some_field:
        ref: MyMemoryRule
```

## Properties

**`memory_store_id`**

Public ID of the destination memory store

_Required_: Yes
_Type_: String

---

**`on`**

`generations.completed` (once per completed turn, and the only event the built-in extractor may bind to) or `conversation_messages.generated` (per persisted assistant reply, custom handlers only).

_Required_: Yes
_Type_: String

---

**`source_agent_ids`**

Agents whose turns this rule reads; null is every agent in the project

_Required_: No
_Type_: Array of String
_Nullable_: Yes

---

**`agent_id`**

Handler agent ID (mutually exclusive with tool_id)

_Required_: No
_Type_: String
_Nullable_: Yes

---

**`tool_id`**

Handler tool ID (mutually exclusive with agent_id)

_Required_: No
_Type_: String
_Nullable_: Yes

---

**`action`**

Operation id, for a tool handler

_Required_: No
_Type_: String
_Nullable_: Yes

---

**`preset_parameters`**

Merged into a tool handler's input before invocation

_Required_: No
_Type_: Object
_Nullable_: Yes

---

**`prompt`**

Replaces the built-in extractor's task instructions (no handler only)

_Required_: No
_Type_: String
_Nullable_: Yes

---

**`ai_provider_id`**

Provider override for the built-in extractor (no handler only)

_Required_: No
_Type_: String
_Nullable_: Yes

---

**`model`**

Model override for the built-in extractor (no handler only)

_Required_: No
_Type_: String
_Nullable_: Yes

---

**`enabled`**

A disabled rule is kept and never fires

_Required_: No
_Type_: Boolean

---
