portable • AI Agent SDK
Move a durable run between processes.
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 that `DurableRunContext` replays from, so a second representation would be a second thing to keep correct.
Import
from praisonaiagents.runtime import portableClasses
Functions
Everything needed to resume `run_id` in another process.
`export_run` as a JSON string, ready for a queue or a form field.
Write an exported run into `journal` and return its run id.
`import_run` from a JSON string.
Constants
| Name | Value |
|---|---|
PORTABLE_RUN_VERSION | 1 |