Wrap an Agent as a FlowsafeDurableAgent and register its loop workflow
on the runtime — the same runtime.register path init()'s boundCreateWorkflow
uses.
Registration is IDEMPOTENT by id: every durable agent compiles to the ONE
shared 'durable-agentic-loop' workflow (the agentId in each run's input
routes to the right agent via the per-run registry), so a second
createFlowsafeDurableAgent on a shared runtime must not throw 'duplicate
workflow id'. Like init()'s createWorkflow, register() also throws once runs
have started (the Mastra instance is frozen) — call this at host setup, before
any run.
Multi-agent caveat: the shared loop bakes in the FIRST registrant's maxSteps
(it is compiled into the isTaskComplete step) as the DEFAULT — a per-call
stream(msg, { maxSteps }) still overrides it, so this only bites a
second-plus agent that relies on its CONSTRUCTOR budget. Agents needing
distinct default step budgets take separate runtimes.
Wrap an Agent as a FlowsafeDurableAgent and register its loop workflow on the runtime — the same
runtime.registerpath init()'s boundCreateWorkflow uses.Registration is IDEMPOTENT by id: every durable agent compiles to the ONE shared 'durable-agentic-loop' workflow (the
agentIdin each run's input routes to the right agent via the per-run registry), so a second createFlowsafeDurableAgent on a shared runtime must not throw 'duplicate workflow id'. Like init()'s createWorkflow, register() also throws once runs have started (the Mastra instance is frozen) — call this at host setup, before any run.Multi-agent caveat: the shared loop bakes in the FIRST registrant's
maxSteps(it is compiled into the isTaskComplete step) as the DEFAULT — a per-callstream(msg, { maxSteps })still overrides it, so this only bites a second-plus agent that relies on its CONSTRUCTOR budget. Agents needing distinct default step budgets take separate runtimes.