---
title: "chDB Durable Layer for agent memory"
description: "chDB Durable Layer wraps the embedded chDB (ClickHouse) OLAP engine so a local MergeTree working copy can be published to object storage you own (S3, GCS, Azure) and recovered on another host."
url: "https://swe.quest/articles/chdb-durable-layer-for-agent-memory-f44e23c2b52592d1"
canonical: "https://clickhouse.com/blog/chdb-durable-layer-for-agent-memory"
source: "ClickHouse"
published: "2026-09-28"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 14
tags: ["ai-agents","analytics","storage-systems","replication","python"]
---

# chDB Durable Layer for agent memory

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2026-09-28, 14 min read, Deep dive. Original: [https://clickhouse.com/blog/chdb-durable-layer-for-agent-memory](https://clickhouse.com/blog/chdb-durable-layer-for-agent-memory)

## Summary

chDB Durable Layer wraps the embedded chDB (ClickHouse) OLAP engine so a local MergeTree working copy can be published to object storage you own (S3, GCS, Azure) and recovered on another host. Writes stay local until an explicit flush(), checkpoint() folds the statement WAL into a new base snapshot, and a head.json record updated with conditional writes provides a single-writer lease with fencing. It targets agent memory, keeping recall as an in-process query (local was 58x faster than remote in their benchmark) while making state survive ephemeral sandboxes and CI. Recommended practices include append-only versioned memory tables, ZSTD-compressed cold evidence with blobs stored outside the table, flushing at task boundaries, and moving to a server database when multiple writers are needed.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Storage systems](https://swe.quest/tags/storage-systems.md) (Infrastructure)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- ClickHouse MergeTree basics ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- object storage conditional writes ([easy posts on Storage systems](https://swe.quest/tags/storage-systems.md?difficulty=easy))
- write-ahead logging ([easy posts on Observability](https://swe.quest/tags/observability.md?difficulty=easy))

## Keywords

chDB, ClickHouse, MergeTree, S3, ClickMem, SQLite, Litestream, Cloudflare Durable Objects

## Related posts

- [chDB as the Agent's Local Data Engine](https://swe.quest/articles/chdb-as-the-agent-s-local-data-engine-cfbf1f486cb2ca71.md): ClickHouse · 2026-07-07 · Medium · 16 min read · AI agents, Analytics & OLAP, Resilience, Vector search, Serverless
  Embedding chDB, the in-process ClickHouse engine, inside an agent keeps hot data local, so tool-call latency is bounded by CPU instead of network round trips, jitter and retries.
- [No more disks: the architecture behind stateless compute in ClickHouse Cloud](https://swe.quest/articles/no-more-disks-the-architecture-behind-stateless-compute-in-clickhouse-cloud-196ae85c7a09008f.md): ClickHouse · 2025-07-09 · Hard · 18 min read · Analytics & OLAP, Distributed databases, Storage engines, Caching, Cloud platforms
  ClickHouse Cloud compute nodes are now fully stateless and diskless.
- [Welcome, chDB](https://swe.quest/articles/welcome-chdb-80fea87c647d8ab8.md): ClickHouse · 2023-08-31 · Medium · 7 min read · Analytics & OLAP, Python, Databases, Open source
  chDB is a community-built embedded SQL OLAP engine that packages ClickHouse as an in-process Python module, similar in spirit to DuckDB, for local analytics, ETL and exploration without running a server.
- [How does Turso Cloud keep your data durable and safe?](https://swe.quest/articles/how-does-turso-cloud-keep-your-data-durable-and-safe-676876baa112a2af.md): Turso · 2025-05-20 · Medium · 4 min read · SQLite, Storage engines, Storage systems, Multi-tenancy, Cloud platforms
  Turso Cloud makes every SQLite database durable on S3 and S3 Express, treating local server disk purely as a cache.
- [ClickHouse Release 24.10](https://swe.quest/articles/clickhouse-release-24-10-7f9e82db64624418.md): ClickHouse · 2024-11-06 · Medium · 14 min read · Analytics & OLAP, Databases, Caching
  ClickHouse 24.10 adds a \`--copy\` mode and an \`--implicit-select\` calculator mode to clickhouse-local, a CLONE AS clause, real-time query metrics in the client, and a filesystem cache for S3 and Azure files.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
