跳到正文
OpenClaw:Blog·AI 评分58

OpenClaw v2026.11.5 支持 Gateway 运行在 PostgreSQL 上

OpenClaw can now run on Postgres, should you make the switch?

AI 导读

OpenClaw v2026.11.5 首次支持 Gateway 使用 PostgreSQL 替代 SQLite,面向容器化部署和已有托管 Postgres 集群的公司,单机场景仍默认 SQLite。

正文 · 原文

OpenClaw v2026.11.5 is the first release where your Gateway can run on PostgreSQL instead of SQLite.

PostgreSQL will generally be slower than SQLite for local database operations. SQLite reads and writes files directly on the Gateway’s machine; PostgreSQL adds communication with a separate database server, often over a network. The reason to use it is to keep your data on infrastructure you can manage independently of the Gateway. SQLite remains the default for a laptop or a single machine with a disk you trust.

So why did we spend the fall introducing a famously local-first lobster to the world’s favorite enterprise elephant?

The short answer is that plenty of people are no longer running OpenClaw on a single machine under their desk. They are running Gateways inside containers that get torn down and redeployed, or inside companies that already have a database team, a managed Postgres cluster, and very strong opinions about where production state is allowed to live. This release is for them.

How we got here

This wasn’t originally a PostgreSQL project. It started back in July as a cleanup of how OpenClaw handled transcripts.

Up until then, every session transcript was a loose JSONL file on disk. Appending to a file was simple enough, and everything else was miserable. Compaction rewrote huge files, two processes touching the same session needed a custom lock controller, and damaged files meant carrying around thousands of lines of repair logic. In July, we replaced the file-era transcript runtime with a single SQLite storage layer. That change deleted about 9,400 lines of file repair, rotation, and locking code. It also created one owner, one schema, and one transaction model for every store in the Gateway.

Once that layer existed, supporting another database stopped being a multi-year rewrite. Jumping straight from JSONL files to PostgreSQL would have meant inventing a relational schema, a file migration, and a network database backend all at once with nothing working to compare it against. Coming from SQLite, most of the hard design work was already done.

Rather than maintaining two separate schemas by hand and watching them drift apart, we kept the SQLite schema as the source of truth and generate the PostgreSQL schema from it. Anything that does not translate cleanly, like SQLite triggers or full-text virtual tables, gets flagged by the generator so we deal with it on purpose. From there, we moved engine selection, anchors, and transaction handling into shared adapters.

The nastiest surprise along the way was memory. Early on, PostgreSQL I/O ran inside dedicated workers, which meant an installation with a bunch of idle agents spawned hundreds of them. Sharing I/O services across agents reduced that overhead. An idle agent shouldn’t cost you a chunk of RAM just for existing.

Since v2026.11.5 was cut, follow-up work has landed on main, including holding Gateway ownership in PostgreSQL and fixing GitHub publication on PostgreSQL stores.

When to use it, and when to skip it

PostgreSQL is for deployments that need network-accessible storage outside the machine running the Gateway. This suits replaceable containers and companies with an existing managed database service.

If you run OpenClaw in ephemeral containers, replacing a Gateway container shouldn’t mean scrambling to rescue a local database file. Microsoft Autopilot is a good example of this shape. As Omar Shahine shared in his architecture post on November 18, Autopilot runs OpenClaw as a stable Gateway image inside a container instance, keeping workspace, state, and memory in durable storage outside the container. With v2026.11.5, any OpenClaw deployment can follow that same pattern. If your company already runs managed Postgres on RDS, Azure, or Cloud SQL, your database team can handle backups, role grants, sizing, and monitoring under the policies they already use.

You also don’t have to move everything at once. OpenClaw splits storage into five families: state, agent, workboard, logbook, and team-reports. Between them they cover sessions, transcripts, memory, search indexes, and plugin data. Each family can pick its own engine, so you can put shared state on PostgreSQL and leave individual agent stores on SQLite if that makes more sense for your setup.

On the other hand, stay on SQLite if you run OpenClaw on one machine and don’t want a database server to babysit. The macOS app is still experimental on PostgreSQL, and iOS and iPad aren’t supported yet. Adding Postgres adds a real database to operate, and if you don’t need separate storage management, SQLite keeps storage local without another service to operate.

The tradeoffs worth knowing before you switch

Keep PostgreSQL close to your Gateway, ideally in the same region. Each database round trip adds network latency, so the distance between them matters.

Memory search can also behave a little differently after a move. PostgreSQL uses its own full-text scoring and runs approximate vector search with exact reranking, while SQLite runs exact vector search. The same memory query can come back in a slightly different order than you’re used to.

There are also three operational details that will bite you if you assume Postgres replaces everything on local disk.

First, a connection string alone will not bring a dead Gateway back to life. Even on PostgreSQL, each store keeps a small local SQLite anchor file at its usual path recording the store’s identity and server namespace. Credentials, safety journals, device caches, Logbook frame images, and cold transcript blobs also stay on local disk so recovery doesn’t depend on the database server being reachable. The anchor and the server data are a matched pair. Never delete an anchor file to try to change engines, and if you’re deploying in containers, put the Gateway’s state directory on a persistent volume alongside your database.

Second, one live Gateway still owns each store. There is no active-active mode and no automatic failover in this release, so don’t mount one state directory onto two Gateways trying to build your own high availability. Independent Gateways can safely share one PostgreSQL server as long as they use separate databases or distinct schemaPrefix values.

Third, OpenClaw fails closed on PostgreSQL. If the server is unreachable or a schema check fails, the store refuses to open and exec approvals fail closed. It will never silently fall back to SQLite and split your history across two places. If a connection drops right in the middle of a commit, OpenClaw reports the outcome as unknown, so double-check whether an action went through before retrying anything that sends a message.

How to turn it on

This is a beta feature, so treat it like one. You’ll need PostgreSQL 16, 17, or 18 with a UTF8 database, plus the unaccent, pg_trgm, and vector extensions installed by an administrator. The runtime role only needs to connect, create schemas, and own what it creates. It doesn’t need superuser privileges. Connection strings are supplied through a SecretRef (env, file, or exec) and never written directly into your config file. TLS with verify-full is supported.

For a fresh installation, add this to your config before the Gateway creates its first stores:

JSON

{
  database: {
    engine: "postgres",
    postgres: {
      connection: { source: "env", provider: "default", id: "OPENCLAW_DATABASE_DSN" },
      schemaPrefix: "openclaw",
    },
  },
}

If you want a mixed setup that keeps agents local and moves shared state to Postgres, configure it per family instead:

JSON

{
  database: {
    engine: "sqlite",
    families: { state: { engine: "postgres" } },
    postgres: {
      connection: { source: "env", provider: "default", id: "OPENCLAW_DATABASE_DSN" },
    },
  },
}

Once your config is in place, run openclaw doctor and make sure each Postgres family reports effective=postgres (configured).

If you’re migrating an existing SQLite installation, stop the Gateway and anything else touching its state directory, then run:

Bash

openclaw doctor --fix
openclaw database port --to postgres --dry-run
openclaw database port --to postgres

doctor –fix finishes any pending legacy migrations first, which the port command won’t skip. The dry run checks your source stores and Postgres prerequisites without writing anything. During the real port, OpenClaw snapshots your source stores and config, migrates and verifies the copy privately, rebuilds memory indexes offline using your cached embeddings, and flips your config last. If something gets interrupted midway, you can resume or roll back cleanly. Just wait until the command finishes before starting the Gateway again. One current limitation: the port command doesn’t run on native Windows yet, so on Windows you’ll need to start fresh on Postgres or run the port on Linux or macOS.

You can also go back the other way. Running openclaw database port –to sqlite moves everything back to SQLite and brings along every write made while you were on Postgres. On a mixed setup, port one family at a time, like openclaw database port –family workboard –to sqlite.

Backups work a little differently

Because local anchors, config, and local files live beside the data in Postgres, a raw pg_dump won’t cover a full OpenClaw installation on its own, and neither will copying your local state folder by itself. To take a complete backup, stop the Gateway and run:

Bash

openclaw backup create --output ~/Backups/openclaw --verify

That archive bundles the PostgreSQL data for every store along with the matching local state. When you need it, openclaw backup restore imports each store into a fresh namespace without touching your originals. Since the connection string isn’t saved in the archive, you pass it in separately and point it at whatever recovery server you’re using. Replication, point-in-time recovery, and synchronous_commit settings remain yours to manage on the Postgres side.

Try it out

PostgreSQL support is ready for operators to start using in the supported deployments described above. If you need storage outside your Gateway, try it with your workload and keep the platform limits and recovery requirements in mind. We welcome pull requests, fixes and feedback as we scale this out. If SQLite already suits your single-machine setup, there’s no need to switch.

来源:OpenClaw:Blog · openclaw.ai

所属事件

查看完整事件
OpenClaw 发布 11.5/11.6 并新增 PostgreSQL 支持