Skip to main content

What it does

manage_data_store lets an agent shape the schema of a data store (a structured knowledge base): create tables, add or alter columns, add indexes, create views, and inspect the current schema. Changes apply to the store’s own isolated Postgres database.
  • create_store creates a brand-new data store (name + optional description) — no knowledge_base_id needed. Use it when work deserves its own store rather than adding unrelated tables to an existing one. Creation only: delete a store in Control Hub. To rename it or change its description, use manage_knowledge_bases update.
For an overview of structured data stores — what they are and when to use one — see Data Stores.

Parameters

Key behaviors

  • A primary key is added for you. create_table adds an id primary key automatically unless you define your own.
  • Views give apps aggregation power. create_view stores an agent-authored SELECT that apps read like a table — the way to let an app show a rollup or join over a large table without pulling every row. Views run with the reading role’s privileges, so they stay safely scoped to the store.
  • Rules hold for every writer. A rule added with add_constraint or a unique index is enforced by the database itself, so it applies to agents, apps, and people editing rows alike, not just to the agent that set it up.
  • Rules check existing rows first. If rows already break a new rule, the call fails and says how many and which. Fix those rows, or pass not_valid: true to enforce the rule on new and changed rows only.
  • Destructive changes are gated. Every drop_* action requires confirm: true, because a published app may depend on what it removes.
  • Locked stores refuse structure changes. If the store’s creator has locked it, every operation except describe fails unless the requesting user is its creator or an org admin. Rows stay writable through write_data_store. manage_knowledge_bases list shows locked and canEdit for locked stores.
  • Every change is audited, and the store’s cached schema — which the agent sees in its context — refreshes automatically after each change.

Common use cases

Create a table

Number records automatically (TAR-0001, TAR-0002, …)

The database assigns the next number on every insert, so two writers can’t take the same one. pad is a minimum: after TAR-9999 comes TAR-10000. Use auto_id: {} for plain numbers. To switch an existing column over, call alter_column with auto_id; numbering continues after the highest ID already in the column.

Require every row to point at a real record

The referenced columns must be the other table’s primary key or have a unique index. Add on_delete: cascade or on_delete: set null to choose what happens to deals when their company is deleted. By default, the delete is refused.

Limit a column to a set of values or a range

Use min and max for ranges, such as { type: check, columns: [ownership_pct], min: 0, max: 1 }.

Allow only one primary contact per company

Create a view for an app to chart