AI agents are crossing from chat to action. In a recent note, Simon Willison outlines an “agent edit” pattern for Datasette—letting an AI propose database changes for a human to review and apply. It’s a pragmatic path to safe, auditable edits.
Read Willison’s post: Datasette: agent edit.
Why this matters
Teams want agents to handle real work—fix records, normalize fields, enrich rows, reconcile conflicts. But write access without guardrails risks silent data drift, compliance issues, and trust loss.
A practical guardrail checklist
- Least-privilege scopes: explicitly allow tables/columns; deny risky fields (PII, payments).
- Human-in-the-loop: agents propose edits; humans approve, batch, or reject.
- Diff previews: show before/after per row and aggregate counts before applying.
- Dry-run mode: validate changes and constraints without committing.
- Structured outputs: require JSON (with JSON Schema) for proposed edits and reasons.
- Hard constraints: enforce NOT NULL, CHECKs, unique keys, and custom validators.
- Transactional writes: apply changes atomically with rollback on any failure.
- Audit trail: log timestamp, actor (agent/human), prompt, rationale, SQL, before/after.
- Backups/snapshots: take point-in-time snapshots for fast undo.
- Rate limits and quotas: cap rows per batch and edits per hour per agent.
- Red-teaming: test against adversarial prompts and synthetic edge cases.
- Observability: metrics for proposed vs. approved edits, error rates, and drift.
Minimal viable “agent edit” pipeline
- Ingest: Agent proposes normalized, structured edits (JSON) with per-row rationale.
- Validate: Schema validation + business rules + foreign keys in a staging table.
- Preview: Render human-readable diffs with filters (table, column, confidence).
- Approve: Human selects, batches, and signs off on a set of changes.
- Commit: Execute inside a single transaction; write audit records.
- Monitor: Track approvals, reversals, and data quality metrics over time.
Gotchas to watch for
- Ambiguous intent: force the agent to include a reason and source for each change.
- Schema drift: lock versions; reject edits targeting unknown columns.
- Dedup hell: require deterministic matching logic and thresholds to merge rows.
- Idempotency: stamp operations so replays don’t re-apply the same edit.
- Privacy: mask sensitive data in prompts, logs, and diffs.
Further reading
- Simon Willison’s note: Datasette: agent edit
- Datasette docs: docs.datasette.io
- NIST AI Risk Management Framework: nist.gov
The takeaway
Let agents propose edits; let humans approve; log everything; make rollback trivial. That’s the fastest safe path to unlocking AI-driven data hygiene and enrichment.
Get smarter on AI—weekly
Enjoy practical AI playbooks like this? Subscribe to our free newsletter for weekly nuggets: theainuggets.com/newsletter.

