Skip to content

@agent-os/backend-in-memory

In-memory backend instance for runtime contract tests and local backend parity checks.

Runtime Tags are the backend contract. The in-memory backend implements the same Ledger, Scheduler, Dispatch, Resources, Quota, Admission, LlmTransport, AttachedStreams, and MaterializedProjections Tag surface without importing Cloudflare or SQL substrate APIs.

The in-memory backend accepts only pure ReadonlyArray<AnyDurableTrigger> registrations. It does not accept backend-bound trigger factories and does not model custom app-owned SQL tables. Materialized projection declarations are backend-neutral and are mirrored here for contract tests and local product spikes.

For pure trigger parity tests, the in-memory backend mirrors durable trigger claim, cancel, and redrive semantics: expired claims become claimable again, cancelTrigger respects each trigger’s cancellation declaration, and claim-token checks prevent duplicate terminal facts. It does not model Cloudflare isolate eviction.

Create an in-memory runtime backend in tests.

import { createInMemoryRuntimeBackend } from "@agent-os/backend-in-memory";
Terminal window
cd packages/backends/in-memory
bun run test