anthropics / anthropics/claude-agent-sdk-typescript

Feature request: fully diskless operation with sessionStore (drop the mandatory local transcript write)

Open
#353 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Shell
Stars
1.8k
Forks
226
PR merge metrics
No merged PRs in 30d

Description

### Summary
Follow-up to #97 (which added the `sessionStore` adapter — thank you!). Even with a
custom `sessionStore`, the SDK still **mandatically writes session transcripts to the
local filesystem**: `persistSession: false` cannot be combined with `sessionStore`, and
resume always **materializes the loaded transcript to a temporary JSONL file** that the
subprocess reads from. This makes truly diskless / read-only-rootfs deployments impossible.
Requesting a supported way to run with `sessionStore` as the *sole* source of truth and
no required local writes.

### Current behavior (v0.2.141, from the type definitions)
`sessionStore` is a **mirror** on top of mandatory local writes:

> `sessionStore`: "the subprocess **still writes to CLAUDE_CONFIG_DIR** ... AND emits
> entries to this adapter via dual-write. **Cannot be used with persistSession: false --
> local writes are required** for the mirror to function (the mirror hook fires after
> local write success)."

> `SessionStore.load`: "Called once, in the SDK parent, before subprocess spawn. The
> result is **materialized to a temporary JSONL file**; the subprocess resumes from that file."

So local disk is always in the loop: dual-write on every turn, and a materialized temp
file on every resume.

### Why this matters
- **Read-only root filesystems / no writable volume** (hardened containers, some serverless
runtimes) — the SDK can't run at all without provisioning a writable path.
- **Compliance / data-at-rest** — teams that keep conversation state only in an encrypted DB
don't want plaintext transcripts written to node-local disk, even transiently.
- **Stateless pods** — `sessionStore` solves cross-pod *resume*, but the mandatory local
writes mean each pod still needs (and accumulates) local transcript files that must be
GC'd (`cleanupPeriodDays`) or capped.

`CLAUDE_CONFIG_DIR=/tmp` (ideally tmpfs) is a partial workaround, but it still requires a
writable mount and is per-pod scratch — it doesn't give a real "no local writes" guarantee.

### Proposed solutions (any one would help)
1. **Allow `persistSession: false` together with `sessionStore`** — when both are set, treat
the store as the source of truth: load from it, and skip durable local writes (keep at
most an in-process buffer).
2. **In-memory materialization on resume** — hydrate the transcript via an in-memory FS /
`memfd` / pipe instead of a temp JSONL file, so resume needs no writable path.
3. **At minimum, document** the officially-supported "no persistent disk" configuration
(e.g. `CLAUDE_CONFIG_DIR` on tmpfs) and its guarantees/limits.

### Environment
- `@anthropic-ai/claude-agent-sdk` 0.2.141 (Node 22), Kubernetes multi-replica behind LB.
- Using `sessionStore` (MySQL) for cross-pod resume; verified working, but local writes remain mandatory.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.