What it does
write_data_store changes rows in a data store (a
structured knowledge base). It supports single-row and multi-row writes, one-shot
keyed saves (upsert), and atomic multi-statement batch writes. All values are
parameterized, and the tool can never run schema changes — that’s
manage_data_store’s job.
For an overview of structured data stores, see Data Stores.
Parameters
Key behaviors
-
upsertis the way to save keyed rows — “save this user’s score for this deal” is one call, with no select-first and no race. It needs a unique index on the conflict keys. The result reports whether the row wasinsertedorupdated. -
Optimistic concurrency — pass
if_matchwith the version you last read (e.g. anupdated_at); if another writer changed the row first, the write is skipped and the current row is returned so you can reconcile. -
batchis atomic — several mutations in one transaction, all committed or none. Use it for coordinated multi-row changes. -
updateanddeleterequire at least one filter — a guard against accidentally rewriting a whole table. -
Errors carry the raw Postgres code (for example
23505for a unique violation) plus the constraint name, so callers can branch on the code rather than parse a message. -
bulk_loadis file transport — for rows the agent is moving (imports, daily syncs from an external system), not reasoning about. The agent writes JSONL to the sandbox withexecute_python, then onebulk_loadcall streams it server-side in a single transaction — the rows never pass through model context.mode: upsertwithconflict_keysmakes a daily refresh idempotent. More than 5 malformed lines aborts the whole load rather than half-loading a garbled file.
Common use cases
Insert rows
Upsert a keyed row
Related
- Manage Data Store — create tables, columns, views
- Query Data Store — read data with SQL
- Data Stores — the feature overview