A local model is not a storage strategy. A run can retain prompts, retrieved text, tool responses, approvals, credentials, and output artifacts. Decide what must survive a restart, who may read it, and how to recover it before choosing a database. Running a model on your machine does not make its data private: network tools, synced folders, logs, backups, remote model fallbacks, and other accounts on that machine remain separate exposure paths.
First, draw the boundary around the data
List four classes: (1) durable run state such as task IDs, checkpoints and status; (2) short-lived tool output or retrieved material; (3) secrets such as API tokens; and (4) records belonging to a person or customer. Store only what the workflow needs, set retention/deletion rules, and keep secrets in a dedicated secret store rather than copying them into prompts or ordinary database rows. Treat retrieved text and tool responses as untrusted input, not instructions; OWASP recommends scoped tools, validation and human review for high-impact agent actions.[7]
Write down your trust boundary: one operator on one host, multiple workers on one host, or multiple users and machines. Define who can initiate a write, which fields an agent may alter, whether a human must approve external effects, and what happens if a run crashes halfway through. This is a design checklist, not evidence that any particular stack has been secured.
A disclosed editorial rubric, not a benchmark
Hard gates before scoring: If the chosen deployment cannot enforce your required access boundary, restore a useful backup, or meet your data-handling obligations, reject it regardless of score. Do not put a shared production database on an unsupported file share just to earn a simplicity point. For options that pass those gates, score each criterion 0 (poor fit), 1 (workable with explicit mitigation), or 2 (good fit); multiply by its weight and divide by two for a score out of 100. These weights and sample judgments are this article’s opinions, not measured performance or product ratings.
- Access isolation — 30 points: Can you give a worker only the data and actions it needs?
- Write pattern — 25 points: Can expected workers and write bursts coexist without a fragile queue?
- Recovery — 20 points: Can you back up while in use and rehearse a restore to a clean environment?
- Operations — 15 points: Can your team patch, monitor, migrate and troubleshoot it?
- Data location — 10 points: Do hosting, backups and integrations meet your location and disclosure requirements?
For example, a single-operator, one-host batch assistant with modest writes may give SQLite 2/2/2/2/2 if file permissions, backup and restoration are actually designed. That illustrative 100 is a fit judgment under stated assumptions, not a perfect security grade. A multi-tenant web app with independent workers on different hosts would fail SQLite’s access/concurrency gates in this simplified design; score a properly configured PostgreSQL deployment only after verifying roles, policies and restore behavior. Your scores change with your threat model and staffing.
Choose the smallest storage boundary that fits
One host, bounded writes: SQLite
SQLite is a good candidate for a personal or single-host agent’s run metadata and checkpoint tables: it keeps an application database in a file and avoids running a separate database server. Its own selection guide says it supports only one writer at a time per database file; many simultaneous writers that cannot queue are a reason to consider a client/server engine.[1] Separate approved writes from model suggestions in application code. A database file is not a permissions system for mutually untrusted users.
Write-ahead logging can allow readers alongside a writer, but it does not turn SQLite into a multi-host server: SQLite documents that WAL does not work over a network filesystem and requires processes using that database to be on the same host.[2] Do not copy a live database file as your only backup procedure; use SQLite’s online backup API or another documented consistent backup method, then test a restore.[3]
Multiple users, hosts, or distinct worker roles: PostgreSQL
PostgreSQL is a candidate when the application needs a client/server database with separately scoped roles and concurrent service access. Grant the agent worker only required operations on required objects; the PostgreSQL privilege model distinguishes SELECT, INSERT, UPDATE and DELETE, among other permissions.[4] A read-only analyst role and a narrowly writable checkpoint role are safer starting designs than one owner or superuser credential in every tool.
If customers share tables, investigate row-level security in addition to application authorization and role grants. PostgreSQL documents a default-deny result when row security is enabled with no applicable policy, but table owners normally bypass it, as do superusers and BYPASSRLS roles.[5] Test policies using the exact runtime role and negative cases; do not call an untested policy a tenant boundary. PostgreSQL offers SQL dumps, filesystem-level backup and continuous archiving as different approaches. Select one that matches your recovery target and verify a real restore, rather than treating “backup enabled” as proof.[6]
Managed or hosted PostgreSQL: an operations trade, not a default
A hosted service may take some patching and availability work off your plate, but it changes the data-location and third-party-access analysis. Review its documented backup and restore controls, region, network exposure, role separation, retention and export path before choosing it. This is not a Supabase endorsement or a claim that any vendor’s free tier, row-level policies or defaults satisfy your requirements. A managed database is still your responsibility to configure and test.
Keep model output outside the write authority
- Define tables and allowed transitions in ordinary code. A suggested checkpoint can be validated and written by a deterministic handler; do not let the model assemble arbitrary SQL or connect as the schema owner.
- Separate read and write credentials. Prefer a narrow, task-specific writer and a read-only retrieval path. Restrict tool inputs, row scope and response size; a prompt that says “do not delete” is not an access control.
- Make retries explicit. Give each run and proposed action a stable identifier; record attempt and result states in a transaction. If an external call succeeds but the process dies before recording it, reconcile the remote state before retrying. A unique database row does not guarantee one external effect.
- Keep approval tied to the actual artifact. For publishing, payments, email, or destructive changes, show a reviewer the frozen action payload and identifiers, then recheck approval and permissions before dispatch. If revocation arrives after dispatch, handle it as remediation rather than promising that a database rollback can unsend an effect.
- Practice failure. Restore to an isolated environment, check that a checkpoint can be resumed safely, confirm permissions with both allowed and denied requests, and inspect logs/backups for secrets. Record a recovery objective you can actually meet.
Decision in one line: Start with SQLite for one trusted host and controlled writes; move to PostgreSQL when separate users, hosts or permissions require a server; consider managed hosting only after accepting its data and operational trade-offs. A vector index, if you use one for retrieval, is not automatically the authoritative store for approvals, run state or audit records. This guide addresses persistence and safety; the site’s MCP and framework comparison addresses integration/orchestration, while the micro-SaaS stack article discusses a broader hosted product stack. Neither should be read as evidence that a local agent needs a particular hosted database.




