Daita Agents ยท Guide
Let the agent change rows in named PostgreSQL tables, one approved statement at a time, with a receipt and a recovery path.
By default Daita only reads. You can separately allow it to insert, update or delete rows in named PostgreSQL tables. The agent proposes one SQL statement with data_write. Daita shows exactly what it will change. You approve, and Daita applies it once and records a receipt.
PostgreSQL is the only source that can be written. SQLite, files and folders cannot.
Receipts are evidence, not a backup. Before you enable writes on a database you care about, verify that you can restore it.
One statement on one table:
INSERT with a column list, including INSERT ... SELECT and ON CONFLICT (columns) DO UPDATE or DO NOTHINGUPDATE, including UPDATE ... FROMDELETE, including DELETE ... USINGA batch upsert is INSERT ... VALUES ... ON CONFLICT with $1, $2, ... parameters: at most 1,000 rows and 64 KiB. A statement cannot contain RETURNING. Daita adds its own, so read generated values with data_query afterwards.
Daita refuses anything else: DDL, TRUNCATE, COPY, MERGE, two statements, a data-changing CTE, an INSERT with no column list, a table with no write scope, a view, a statement over 64 KiB or over the scope's row limit, and any statement PostgreSQL cannot preview.
A write needs all of these.
The model cannot enable permissions or approve its own write.
Use a dedicated role that you manage in PostgreSQL. It must not be a superuser or owner, and must not have BYPASSRLS, role creation, database creation or replication.
CREATE ROLE daita_writer LOGIN
NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOREPLICATION NOBYPASSRLS;
GRANT CONNECT ON DATABASE application_db TO daita_writer;
GRANT USAGE ON SCHEMA support TO daita_writer;
GRANT SELECT ON TABLE support.tickets TO daita_writer;
GRANT UPDATE (priority) ON TABLE support.tickets TO daita_writer;The role needs SELECT because Daita previews and rechecks rows. Daita refuses views, partitioned and inherited tables, and tables with row-level security or rewrite rules. Triggers and cascading foreign keys are allowed, and the approval card names them.
Attaching a source grants no write access. In the terminal app, open /source permissions, choose the source and the maximum rows per call, then Edit table write access. Pick a table, its operations and its columns. Review the before and after, then apply. Applying runs no write.
From Python, pass relational_write_scopes:
preview = await agent.preview_source_permissions(
source_id=source.id,
read_mode="all",
read_resource_ids=(),
relational_write_scopes={"public.companies": {
"allowed_operations": ("insert", "update"),
"allowed_insert_columns": ("domain", "name", "evidence_url"),
"allowed_update_columns": ("name", "evidence_url"),
"max_rows": 100,
}},
)
await agent.apply_source_permissions(
source_id=source.id,
confirmation_fingerprint=preview.confirmation_fingerprint,
)max_rows is 1 to 10,000. Insert columns go with insert and update columns with update. Editing one table keeps the others. Replacing the source connection clears every scope.
To disable a table, apply a scope with no operations. This does not revoke PostgreSQL grants. In an incident, remove the Daita scope first, then revoke or rotate the credential in PostgreSQL.
Check a table without changing anything:
readiness = await agent.relational_write_readiness(source.id, "public.companies")
print(readiness.ready_for_preview, readiness.rejection_codes)daita relational-write-readiness atlas <source-id> public.companiesReadiness never proves that a future write will succeed.
By default data_write previews, asks for approval and writes. mode=preview shows the same facts and changes nothing.
Daita asks PostgreSQL what the statement targets, then runs a derived SELECT in a read-only transaction. No trigger fires and no row lock is taken. The approval card shows:
WHERE, time or randomness, or triggers| Verification | Meaning |
|---|---|
rows | The touched rows are compared before commit. Used for DELETE, and for tables with a usable primary or unique not-null key |
count | Only the row count is compared. Used for tables without such a key |
Approving is for that exact SQL, parameters, table structure and rows, and cannot be reused. A statement that changes nothing cannot be approved. A statement over the scope's max_rows is refused. Denying writes nothing.
Daita opens one transaction, re-reads the table, locks the target rows and reruns the preview. If anything changed, it refuses with write_state_changed. Otherwise it runs the statement once and compares what PostgreSQL reports with the locked rows. A mismatch rolls back with write_affected_rows_mismatch.
A write is never retried or replayed.
| Outcome | Meaning |
|---|---|
committed | PostgreSQL acknowledged the commit and the rows matched the card |
| Refused before commit | Nothing was applied. Fix the cause and ask again for a new preview |
write_outcome_unknown | A commit was attempted and the result is unknown. This does not mean zero rows changed |
For an unknown outcome: remove write access for the table, keep the receipt ID, do not retry, read the rows and compare them with what you intended, review PostgreSQL logs, then record your decision as described below.
Daita reserves a receipt before it dispatches a PostgreSQL write or an approved MCP action. The receipt binds the run, the call and the normalized operation, so an uncertain result can be investigated without repeating the action.
| Status | Meaning |
|---|---|
SUCCEEDED / ADAPTER_VERIFIED | A native transaction was verified, as with data_write |
SUCCEEDED / SERVER_REPORTED | A remote MCP tool returned normally. Downstream completion is not verified |
NOT_APPLIED | Positive evidence of rollback or that nothing was sent |
UNCERTAIN | The effect may have happened. A lost response is never proof of failure |
A receipt left started by an interruption becomes UNCERTAIN when the agent reopens. Unresolved receipts survive clearing a conversation and block new foreground effects. Reading and inspecting stay available. An uncertain routine pauses. An uncertain job moves to Needs you on the Work board.
from daita import EffectResolutionDecision
pending = await agent.list_effects(unresolved_only=True, limit=20, offset=0)
receipt = await agent.inspect_effect(pending[0].receipt_id)
await agent.resolve_effect(
receipt.receipt_id,
expected_digest=receipt.receipt_digest,
decision=EffectResolutionDecision.ALLOW_FUTURE_WORK,
note="Checked the remote system and accept possible duplication.",
)daita effects list atlas --unresolved --limit 20 --offset 0
daita effects inspect atlas <receipt-id>
daita effects resolve atlas <receipt-id> \
--expected-digest <receipt-digest> \
--decision close_without_retry \
--note "Investigated; close without repeating."resolve_effect records a human decision and does nothing else. It never retries, never proves success or failure, and the original uncertain observation stays on the receipt. A person approves the exact decision first. Denial or a changed digest leaves the receipt untouched. The CLI has no --yes shortcut.
| Decision | Result |
|---|---|
close_without_retry | Disables the routine that produced the effect |
allow_future_work | Leaves the routine paused. You still resume it and approve its next write |
Repeat --evidence <id> to cite exact receipts or artifacts of this agent. Models and scheduled instructions cannot resolve a receipt. A corrective write needs its own preview and approval.
A routine or job run writes the same way as a chat. It pauses, the host shows the card naming the routine or job and sends a notification, and you approve or deny. There is no standing permission to write without asking. If nobody answers in 24 hours the run is interrupted and shows as Needs you. A run with no approval path refuses the write.
The request's sensitivity must fit the source's classification. Related: Data Sources, Routines, Jobs.