portable
AI Agent Move a durable run between processes. Durable execution is real and thorough —agent/durable.py replays a run
from a journal — but the journal is a local SQLite file, so a run could only
resume where it started. Pausing on a web worker, putting the state in a queue
and resuming it somewhere that shares no disk was not possible.
This exports a run’s journal (its metadata and every event) as a plain dict,
and imports it into another journal:
blob = export_run(journal, run_id) # -> JSON-safe dict
redis.set(key, export_run_json(journal, run_id))
elsewhere, no shared disk
run_id = import_run(other_journal, blob)resume as usual: the replay index is rebuilt from these events
Deliberately a JOURNAL export rather than a new state format: the journal is already the single source of truth thatDurableRunContext replays from, so
a second representation would be a second thing to keep correct.
Import
Classes
PortableRunError
Raised when a run cannot be exported or imported.
Functions
export_run()
Everything needed to resume
run_id in another process.export_run_json()
export_run as a JSON string, ready for a queue or a form field.import_run()
Write an exported run into
journal and return its run id.import_run_json()
import_run from a JSON string.
