The Agent to wrap with durable, runtime-driven execution.
OptionalcacheResumable-stream cache — see createDurableAgent's cache.
OptionalidOptional id override (defaults to agent.id).
OptionalmaxMax steps for the agentic loop (bakes into the shared loop's isTaskComplete step).
OptionalnameOptional name override (defaults to agent.name).
OptionalpubsubStream and agent-level pub/sub. Uses pubsub ?? runtime.pubsub, or the
wrapper's stream bus when both are absent. Thread state, signal delivery,
and the run's drain share this identity. Construction refuses a wrapped
agent with a different pub/sub of its own. The wrapped agent's pub/sub
follows the last wrapper constructed over it.
The RunnerRuntime through which the loop is driven. Required because
this is the whole point of the flowsafe wrapper: executeWorkflow() calls
runtime.start('durable-agentic-loop', ...) instead of the base
createRun + start, so host-owned run IDs, the per-leg grant context, and
persisted snapshot provenance apply to agent legs. The loop workflow is registered on this runtime
by the factory (idempotently — one shared id serves every durable agent).
OptionalthreadPublic Mastra thread runtime (mastra.agentThreadStreamRuntime). Core
registers started runs itself. When present, a run resumed through
resumeViaRuntime() registers on the agent's pub/sub so active-thread
signals join it. Without it, resumed runs are absent from thread state and
signals sent while they run are not delivered into them.
Options for createFlowsafeDurableAgent.