Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Stores

Stores are typed collections the agent reads and writes during sessions. Each file in amodal/stores/*.json defines one store, and the runtime generates its tools.

Store Definition

{
  "name": "research-notes",
  "entity": {
    "name": "ResearchNote",
    "key": "{company_id}:{topic}",
    "schema": {
      "company_id": { "type": "string" },
      "topic": { "type": "string" },
      "summary": { "type": "string" },
      "confidence": { "type": "number", "min": 0, "max": 1 },
      "updated_at": { "type": "datetime" },
      "tags": { "type": "array", "item": { "type": "string" } },
      "metadata": {
        "type": "object",
        "fields": {
          "source": { "type": "string" },
          "analyst": { "type": "string", "nullable": true }
        }
      }
    }
  },
  "history": { "versions": 3 }
}
FieldDescription
nameLowercase letters, digits, -, and _, starting with a letter. Defaults to the file name; a different name is a load error.
entity.nameEntity type name.
entity.keyKey template built from document fields, such as {company_id}:{topic}.
entity.schemaField definitions. A flat key and schema at the top level are also accepted in place of entity.
history.versionsNumber of previous versions kept per document.
ttlExpiry in seconds, or { "default": 86400, "override": [{ "condition": "status = 'done'", "ttl": 3600 }] }. Conditions support field = 'v', field != 'v', and field IN ['a', 'b'].
deletabletrue registers the remove tool. Default false.
sharedtrue makes one collection readable by every scope. See Scoped vs. Shared Stores.
toolsOnlytrue limits the store to custom tool code and operators. See Tools-Only Stores.

The loader also accepts indexed, failure, and trace, which have no runtime effect.

Field Types

TypeExtra fields
stringnullable
numbermin, max, nullable
booleannullable
datetimenullable
enumvalues (required)
arrayitem (required)
objectfields (required)
refstore (required)

Every type accepts nullable.

Generated Tools

For a store named research-notes, the runtime registers store__research_notes__get, __set, __query, __list, and, with "deletable": true, __remove. Hyphens in the store name become underscores. See Built-in Tools.

Reading and Writing from Custom Tools

Custom tools use the same scope as the session's store tools, so a shared store reads from its one collection:

MemberDescription
ctx.store(name, payload)Write a document. The key is resolved from the payload's key template. Resolves to { key }.
ctx.storeGet(name, key)Read one document's payload by key. Resolves to null when the key does not exist.
ctx.storeQuery(name, options?)Read payloads that match every field in where. Resolves to { rows, total, hasMore }.

ctx.storeQuery takes where, sort, limit, and offset. Without sort, the most recently updated documents come first; sort names a payload field, with a - prefix for descending order. limit defaults to 100 and is capped at 500. To read every row, raise offset by the page size while hasMore is true:

const rows: Record<string, unknown>[] = [];
for (let offset = 0; ; offset += 500) {
  const page = await ctx.storeQuery('ledger', { where: { status: 'open' }, limit: 500, offset });
  rows.push(...page.rows);
  if (!page.hasMore) break;
}

The reads return payloads only. A durable tool cannot call ctx.store, ctx.storeGet, or ctx.storeQuery; it reads and writes stores through a child tool with ctx.callTool. A scheduled or directly invoked tool that only needs stores can be inline and call them itself.

Per-Agent Access

A named agent lists the stores its sessions can use, with "read" or "rw" access:

// agents/research/agent.json
{
  "name": "Research",
  "stores": {
    "company-profiles": "read",
    "research-notes": "rw"
  }
}

read grants get, query, and list. rw adds set and remove.

An agent cannot list a store marked "toolsOnly": true. The bundle fails to load if one does.

Storage Backend

Hosted deployments supply the backing database. amodal dev uses an in-memory store, so local data is lost when the dev server restarts.

Scoped vs. Shared Stores

An authenticated end user whose token pins no scope uses their own user ID as the scope. Chats, memory, store tools and the direct store API all use that scope, so one employee cannot read another employee's private records. A token that pins a scope, including the empty scope, uses that scope. Company-wide data belongs in a store marked "shared": true, which every scope reads and end users cannot write through the direct store API. For shared reads combined with personal, approved changes in an external system, use personal MCP accounts.

Store data is partitioned by the request's scope_id; the hosted runtime does not require one (see Scope). "shared": true makes one collection that every scope reads:

{
  "name": "company-profiles",
  "shared": true,
  "entity": {
    "name": "CompanyProfile",
    "key": "{company_id}",
    "schema": {
      "company_id": { "type": "string" },
      "name": { "type": "string" }
    }
  }
}

The runtime rejects writes and deletions to a shared store, including when an agent declares "rw". Populate reference catalogs outside the agent, and use scoped stores for records the agent updates.

Tools-Only Stores

A store marked "toolsOnly": true holds data that only custom tool code reads and writes, such as a ledger the tools keep for every user:

{
  "name": "ledger",
  "toolsOnly": true,
  "entity": {
    "name": "LedgerEntry",
    "key": "{entry_id}",
    "schema": {
      "entry_id": { "type": "string" },
      "amount": { "type": "number" }
    }
  }
}

For a tools-only store:

  • Custom tools read and write it with ctx.store, ctx.storeGet, and ctx.storeQuery.
  • The model gets no store__<name>__* tools for it, and the system prompt does not describe it.
  • An end user's call to GET /api/stores omits it. GET /api/stores/<name>, GET /api/stores/<name>/<key>, and POST /api/stores/<name> return 404, the same response as for a store that does not exist. The React store hooks receive the same 404.
  • Operators, such as API keys, the admin UI, and local amodal dev, read and write it through the direct store API as usual.
  • No agent can list it under stores in agent.json.

toolsOnly does not filter rows. Every tool call in a scope reads every document in that scope, so a tool that returns rows to the model decides which rows a user sees.