Skip to contents

A lightweight, file-based checkpointer that uses R's native saveRDS and readRDS functions. Each thread is saved as an individual .rds file in a specified directory.

Value

An RDSSaver object.

Super class

HydraR::Checkpointer -> RDSSaver

Public fields

dir

String. Directory to store .rds checkpoint files.

Methods


Method new()

Initialize RDSSaver

Usage

RDSSaver$new(dir = "checkpoints")

Arguments

dir

String. Directory path for checkpoint files.


Method put()

Persist state to an .rds file.

Usage

RDSSaver$put(thread_id, state)

Arguments

thread_id

String.

state

AgentState object.


Method get()

Load state from an .rds file.

Usage

RDSSaver$get(thread_id)

Arguments

thread_id

String.

Returns

AgentState object or NULL.


Method clone()

The objects of this class are cloneable with this method.

Usage

RDSSaver$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (FALSE) { # \dontrun{
# 1. Persistent checkpointing to a local directory
saver <- RDSSaver$new(dir = "vault/checkpoints")

# 2. Create a DAG and run it with a specific thread ID
dag <- dag_create(checkpointer = saver)
dag$run(thread_id = "agent_session_alpha")

# 3. Later, resume the same session - HydraR will load the RDS file
dag$run(thread_id = "agent_session_alpha")
} # }