fork

open suspend override fun fork(): AIAgentGraphContextBase(source)

Creates an independent fork of this context, taking consistent snapshots of the LLM context, storage, state manager and execution info. Each copy() is performed under the corresponding lock of the source object, so the returned context is safe to mutate concurrently with the original.

Concurrency caveat: each downstream copy() acquires its own read lock (or equivalent); these locks are acquired sequentially, and the snapshot of the whole context is therefore not atomic across all four fields. Two fields may be observed at slightly different points in time if another coroutine is concurrently mutating this context.

Note also that the in-memory storeMap (populated via store) is not copied here — the returned context starts with an empty local store.