Skip to content

API Reference parrot.bots.flows.core.checkpoint.store.redis

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.bots.flows.core.checkpoint.store.redis

View source

RedisCheckpointStore — ephemeral tier (FEAT-399, TASK-2049).

Per-flow latest pointer, ormsgpack-encoded checkpoint bodies, a bounded history zset, and a resume lease — all under a flowckpt:{flow_id}:* key namespace. Every write refreshes the TTL on the flow's data keys (latest/cp/history); the lease key has its own independent PX TTL.

Connection pattern copied from RedisResultStorage (core/storage/backends/redis.py, FEAT-147): AsyncDB redis driver, lazy _ensure(), idempotent close().

Note: the AsyncDB redis driver connects with decode_responses=True (redis-py decodes every reply as UTF-8 text), so the binary ormsgpack payload from FlowStateSerializer is base64-encoded to a UTF-8-safe string before SET and base64-decoded after GET — storing raw ormsgpack bytes directly would raise UnicodeDecodeError on read.

Alias CheckpointStore

Re-exported from parrot.bots.flows.core.checkpoint.store.base.CheckpointStore.

Alias FLOW_CHECKPOINT_HISTORY

Re-exported from parrot.conf.FLOW_CHECKPOINT_HISTORY.

Alias FLOW_CHECKPOINT_REDIS_TTL

Re-exported from parrot.conf.FLOW_CHECKPOINT_REDIS_TTL.

Alias FlowCheckpoint

Re-exported from parrot.bots.flows.core.checkpoint.model.FlowCheckpoint.

Alias FlowStateSerializer

Re-exported from parrot.bots.flows.core.checkpoint.serializer.FlowStateSerializer.

Alias REDIS_URL

Re-exported from parrot.conf.REDIS_URL.

Class RedisCheckpointStore

Ephemeral checkpoint tier: Redis with per-flow TTL + bounded history.

Parameter Type Default Description
dsn str | None None Redis DSN; defaults to REDIS_URL.
ttl int | None None Retention TTL in seconds for a flow's data keys; defaults to FLOW_CHECKPOINT_REDIS_TTL (86400s / 24h).
history int | None None Maximum retained checkpoints per flow; defaults to FLOW_CHECKPOINT_HISTORY (10).

Method RedisCheckpointStore.put

Persist a checkpoint and refresh TTL on the flow's data keys.

put(checkpoint: FlowCheckpoint) -> None

Parameter Type Default Description
checkpoint FlowCheckpoint

Method RedisCheckpointStore.latest

Return the most recent checkpoint for a flow, if any.

latest(flow_id: str) -> FlowCheckpoint | None

Parameter Type Default Description
flow_id str

Returns: FlowCheckpoint | None

Method RedisCheckpointStore.get

Return a specific checkpoint by id.

get(flow_id: str, checkpoint_id: int) -> FlowCheckpoint | None

Parameter Type Default Description
flow_id str
checkpoint_id int

Returns: FlowCheckpoint | None

Method RedisCheckpointStore.history

Return the retained checkpoint history for a flow, newest first.

history(flow_id: str, limit: int = 10) -> list[FlowCheckpoint]

Parameter Type Default Description
flow_id str
limit int 10

Returns: list[FlowCheckpoint]

Method RedisCheckpointStore.list_flows

List known flows (via SCAN over flowckpt:*:latest), optionally filtered by status.

list_flows(status: str | None = None) -> list[dict[str, Any]]

Parameter Type Default Description
status str | None None

Returns: list[dict[str, Any]]

Method RedisCheckpointStore.delete_flow

Delete every flowckpt:{flow_id}:* key for a flow.

delete_flow(flow_id: str) -> None

Parameter Type Default Description
flow_id str

Method RedisCheckpointStore.acquire_lease

Acquire the resume lease via SET key holder NX PX ttl*1000.

acquire_lease(flow_id: str, holder: str, ttl: int = 60) -> bool

Parameter Type Default Description
flow_id str
holder str
ttl int 60

Returns: bool

Method RedisCheckpointStore.renew_lease

Renew the resume lease; only succeeds if holder currently owns it.

Note: the ownership check and the renewal SET are two round-trips (not atomic via Lua) — acceptable for v1 per spec §7 ("Redis lease is advisory... acceptable for v1, matches at-least-once semantics").

renew_lease(flow_id: str, holder: str, ttl: int = 60) -> bool

Parameter Type Default Description
flow_id str
holder str
ttl int 60

Returns: bool

Method RedisCheckpointStore.release_lease

Release the resume lease; a no-op (logged) if not owned by holder.

release_lease(flow_id: str, holder: str) -> None

Parameter Type Default Description
flow_id str
holder str

Method RedisCheckpointStore.close

Release the Redis connection. Safe to call multiple times.

close() -> None

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally