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

# Storage rules

> Limit what agents store in a project's brain: which kinds of memories and documents, how many tags, how long, which file types and how large.

Storage rules let a project's owners and admins narrow what goes into its brain. You
choose which kinds of memories and documents may be stored, how many tags a memory
needs, how long a title or a memory may be, which file types are allowed and how large
a file may be. A write that breaks a rule is refused with the rule it broke, so the
agent can try again within them.

Rules only tighten Hookie's own limits. They can never loosen one.

## Who the rules bind

Each project's rules have one setting for who they apply to (`applies_to`):

* **Agents only** (`agents`, the default): every caller that is not a person signed in
  to the console. That covers [connected agents](https://docs.hookie.ai/connected-agents.md),
  [Agent Registrations](https://docs.hookie.ai/workos-agent-auth.md),
  [agent accounts](https://docs.hookie.ai/agent-self-registration.md) and [API keys](https://docs.hookie.ai/api-keys.md). The local MCP server signs in with an API key, so it counts as
  an agent too.
* **Everyone** (`everyone`): people in the console as well as agents.

Some writes are never checked, whoever makes them:

* [Repository sync](https://docs.hookie.ai/repository-sync.md) and [knowledge connector](https://docs.hookie.ai/knowledge-connectors.md) sync.
* A documents pipeline's S3 sync.
* A person approving a memory that [automatic capture](https://docs.hookie.ai/project-context.md#automatic-memory-capture) proposed.

## The rules

Every rule is optional. A rule you leave out stays at the system limit.

### Memories

| Rule | System limit | What it does |
| - | - | - |
| `memory.kinds` | `memory`, `decision`, `thread_summary` | The kinds of memory that may be stored. |
| `memory.min_tags` | 0 (up to 20) | The fewest tags a memory may have. |
| `memory.require_thread` | `false` | When `true`, a memory must name the chat thread it came from (`thread.id`). |
| `memory.title_min` | 1 character | The shortest title allowed. |
| `memory.title_max` | 200 characters | The longest title allowed. |
| `memory.max_content_chars` | 32,768 characters | The longest memory allowed. |

`title_min` cannot be more than `title_max`.

### Documents

| Rule | System limit | What it does |
| - | - | - |
| `document.kinds` | `prd`, `spec`, `adr`, `runbook`, `agentic_context`, `generated`, `other` | The kinds of document that may be stored. |
| `document.content_types` | Plain text, Markdown, PDF, Word (.docx) and HTML | The file types that may be uploaded. |
| `document.max_bytes` | 10 MiB (10,485,760 bytes) | The largest file allowed, measured on the file as uploaded, before conversion. |
| `document.require_source_ref` | `false` | When `true`, a document must say where it came from (`source_ref`). |

The file types are named by content type: `text/plain`, `text/markdown`,
`application/pdf`, `application/vnd.openxmlformats-officedocument.wordprocessingml.document`
and `text/html`.

Hookie checks the rules strictly when you save them. An unknown key, a value of the
wrong type, a kind or file type Hookie does not have, an empty list, or a limit looser
than the system's is refused with `400`.

## Who can change them

Only an owner or admin of the project can change its rules, and only as a person in
the console. An agent or API key is refused with `403`, whatever its scope: agents can
read the rules but never set them. Other members see the rules read-only.

Every change is recorded in the audit log as `project_updated`, with the rules before
and after.

## Set rules in the console

Open the project, go to **Sources → Capture & storage** and find **What agents may store**, below
**Automatic memory capture**.

1. Under **Who the rules apply to**, choose **Agents only (recommended)** or **Everyone**.
2. Under **Memories**, set:
   * **Kinds agents may store**: Memories, Decisions, Thread summaries.
   * **Minimum tags**, **Shortest title (characters)**, **Longest title (characters)** and **Longest memory (characters)**.
   * **A memory must name the chat it came from**.
3. Under **Documents**, set:
   * **Kinds agents may upload**: PRDs, Specs, ADRs, Runbooks, Agentic context, Generated, Other.
   * **File types agents may upload**: Markdown, Plain text, PDF, Word (.docx), HTML.
   * **Largest file (MiB)**, up to 10 MiB.
   * **A document must say where it came from (source reference)**.
4. Choose **Save rules**.

If someone else changed the rules while you were editing, Hookie says
**Someone changed these rules**. Reload to see their version, then make your change
again.

**Remove rules** deletes the project's rules after you confirm. Agents can then store
anything within Hookie's own limits again.

## When a write is refused

A write that breaks a rule is refused with `422` and the code `storage_rule_violation`.
The body lists every rule that was broken, with its limit and the actual value:

```json theme={"dark"}
{
  "error": "This project's storage rules refuse this memory (storage_rule_violation): A memory needs at least 1 tag; this one has 0. Read the rules with get_project_storage_rules and store it again within them.",
  "code": "storage_rule_violation",
  "project_id": "prj_123",
  "violations": [
    {
      "rule": "memory.min_tags",
      "message": "A memory needs at least 1 tag; this one has 0.",
      "limit": 1,
      "actual": 0
    }
  ]
}
```

The message itself names each broken rule and the tool that reads the rules, so an
agent that sees only the message can still correct its write. A refused upload stores
nothing and counts against nothing.

## What is checked

The rules that bind the caller are checked when:

* **A memory is saved**, including saving again under a `memory_key`, and when a decision is recorded.
* **A memory is edited** and its title, content, tags or kind change. A move to another project is checked against that project's rules.
* **An earlier version of a memory is restored**, against that version's own text.
* **A merge proposal is accepted by the kept memory's author** and the kept memory's text or tags change, including when it takes the tags of both memories, as it does by default. See [Stale memories and duplicates](https://docs.hookie.ai/stale-memories.md#review-and-merge).
* **[Automatic memory capture](https://docs.hookie.ai/project-context.md#automatic-memory-capture) runs.** The allowed kinds and limits are added to the model's instructions. A proposal that still breaks a rule is dropped and listed in `refused_by_rules`, with its `title`, `rule` and `message`. The capture is refused with `422` only when every proposal breaks a rule.
* **A project document is uploaded**, before it is converted.
* **A document is uploaded through a documents pipeline.** It is checked against the pipeline's project (the Default project for an older pipeline), as kind `other` with no `source_ref`.
* **An earlier version of a project document is restored**, against that version's kind, file type, size and `source_ref`. A version that was converted from a PDF, Word or HTML file keeps only its text, so its file type is read from its name and its size is not checked.

## What is not checked

* The syncs and approvals listed under [Who the rules bind](#who-the-rules-bind).
* An edit that changes only a memory's sharing, `superseded_by`, `expires_at` or nothing but the revision.

So tightening the rules never traps a memory that is already stored. It is checked
again only when its text, tags or kind change.

## For agents

Agents read a project's rules so they can store within them.

| Tool | What it does |
| - | - |
| `get_project_storage_rules` | Reads who the rules apply to, the rules as set and `effective`, every rule with unset ones at the system limit. Needs `hookie:read`. `revision` 0 means the project has no rules. |

[`get_project_context`](https://docs.hookie.ai/project-context#for-coding-agents) also returns
`storage_rules: {applies_to, effective}` when the project has rules.

Every tool that stores something says it may be refused with `storage_rule_violation`:
`save_memory`, `update_memory`, `restore_memory_version`, `record_decision`,
`extract_memories`, `accept_memory_merge`, `upload_project_document`,
`restore_project_document` and `upload_brain_document`. No tool sets the rules.

## Over the API

The routes are under `/admin/api/projects/{project_id}`. `/admin/api/storage-rules` is
the same for the Default project.

* `GET storage-rules`: any role, and agents at `hookie:read`. Returns `project_id`,
  `applies_to`, `rules` (as set), `effective`, `revision` (0 when there are none),
  `updated_by` and `updated_at`.
* `PUT storage-rules` with `{applies_to, rules, revision}`: an owner or admin, as a
  person. It replaces the whole rule set, so a rule you leave out goes back to the
  system limit. Send the `revision` you read; `0` creates the rules. If the rules changed
  since you read them, the request is refused with `409` and the code
  `storage_rules_changed`. Read them again and resend.
* `DELETE storage-rules`: an owner or admin, as a person. Removes the rules and returns
  the same shape as `GET`, with `revision` 0.

A `PUT` body that lets agents store only memories and decisions with at least one tag
and a named chat thread, and only Markdown or PDF files up to 2 MiB that say where they
came from:

```json theme={"dark"}
{
  "applies_to": "agents",
  "revision": 0,
  "rules": {
    "memory": { "kinds": ["memory", "decision"], "min_tags": 1, "require_thread": true },
    "document": {
      "content_types": ["text/markdown", "application/pdf"],
      "max_bytes": 2097152,
      "require_source_ref": true
    }
  }
}
```

See the [API reference](https://docs.hookie.ai/api-reference.md) for every field.

## Export and import

A project's configuration export carries its rules as `storage_rules`, and a workspace
export includes them. Importing a configuration applies the rules only when a person
imports it, and never over rules the project already has: an existing set is skipped
and reported. When an agent, an API key or a member below admin imports it, the rules
are skipped and reported.


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