Awaits every queued save, drains the queue, and returns failure diagnostics. Call at run/goal finalize.
Fires a step's "started" INSERT without awaiting (the caller continues immediately). The step's PK
must already be client-generated (NewRecord) so its id is valid before the INSERT lands.
OptionalparentStep: MJAIAgentRunStepEntityWhen provided, the INSERT is chained after the parent step's pending INSERT
to satisfy the self-referencing FK_AIAgentRunStep_ParentID constraint. Without this, a child
step whose fire-and-forget INSERT races the parent's INSERT can hit an FK violation.
Queues a fire-and-forget force-persisted UPDATE chained after the step's INSERT (and any prior
UPDATE). Pass applyMutation for any field change made after the INSERT was fired — it runs INSIDE
the post-INSERT task, so it can't be reverted by the INSERT's reload. Omitting it stays valid when
the fields are already set AND cannot race an in-flight INSERT.
OptionalapplyMutation: (step: MJAIAgentRunStepEntity) => void
Fire-and-forget save orchestration for agent-run steps — a thin, typed façade over the shared BaseEntitySaveQueue (
@memberjunction/core). Keeps step writes OFF the hot loop so a run that creates many steps (e.g. a goal-driven Computer Use loop with one prompt step per iteration) never pays N synchronous DB round-trips on its critical path, and inherits the queue's race-proofing:IgnoreDirtyState) after the step's INSERT. ItsapplyMutationruns INSIDE the post-INSERT task — afterfinalizeSave'sinit()+SetManyreload — so it can't be reverted (the "step stuck at Running / null TargetLogID" bug is structurally impossible). Mutating the shared entity before the INSERT resolves is the race this prevents.Failures are logged, never thrown — persistence is observability and must not break the run.