readSession

open suspend fun <T> readSession(block: suspend AIAgentLLMReadSession.() -> T): T(source)

Executes a read session on the AIAgentLLMContext. Multiple read sessions may run concurrently, while any concurrent writeSession or withPrompt is serialized against them.

Concurrency caveats:

  • The underlying lock is not reentrant for writers: nested readSession calls from the same coroutine are safe, but calling writeSession or withPrompt from inside a readSession will deadlock (see RWLock).

  • Mutations performed on fields exposed through the session are not persisted back to this context (unlike writeSession).