replace
Atomically replaces the stateful fields of this context with those of context, under the write lock of mutableAIAgentContext.
Concurrency caveats:
mutableAIAgentContext's lock is not reentrant; do not call replace from inside another operation that already holds it (e.g. from within a transformation running under MutableAIAgentContext.copy).
Consumers that read fields directly (e.g.
ctx.llm,ctx.storage) without going through the MutableAIAgentContext lock may observe a non-atomic mix of old and new values while a concurrent replace is in progress.