AIAgentLLMContextCommon

Common AIAgentLLMContext implementation shared across platforms.

Inheritors

Properties

Link copied to clipboard
@get:JvmName(name = "clock")
val clock: KoogClock

Represents the clock instance used for time-related operations and scheduling within the context.

Link copied to clipboard
@get:JvmName(name = "config")
val config: AIAgentConfig

Provides access to the configuration settings for an AI agent within the LLM context.

Link copied to clipboard
@get:JvmName(name = "environment")
val environment: AIAgentEnvironment

Represents the execution environment associated with an AI agent within the context of the LLM (Large Language Model) framework.

Link copied to clipboard

LLM currently associated with this context.

Link copied to clipboard
@get:JvmName(name = "prompt")
var prompt: Prompt

The current prompt used within the AIAgentLLMContext.

Link copied to clipboard

The PromptExecutor responsible for performing operations on the current prompt.

Link copied to clipboard

Response processor currently associated with this context.

Link copied to clipboard
@get:JvmName(name = "toolRegistry")
val toolRegistry: ToolRegistry

A ToolRegistry that contains metadata about available tools.

Link copied to clipboard

List of current tools associated with this agent context.

Functions

Link copied to clipboard
open fun copy(tools: List<ToolDescriptor> = this.tools, prompt: Prompt = this.prompt, model: LLModel = this.model, responseProcessor: ResponseProcessor? = this.responseProcessor, promptExecutor: PromptExecutor = this.promptExecutor, environment: AIAgentEnvironment = this.environment, config: AIAgentConfig = this.config, clock: KoogClock = this.clock): AIAgentLLMContext

Creates a non-suspending copy of this LLM context with the given overrides. Unlike the suspending copy overload, this variant does not acquire the internal read lock and therefore does not guarantee a consistent snapshot if another coroutine is concurrently mutating this context.

open suspend fun copy(tools: List<ToolDescriptor> = this.tools, toolRegistry: ToolRegistry = this.toolRegistry, prompt: Prompt = this.prompt, model: LLModel = this.model, responseProcessor: ResponseProcessor? = this.responseProcessor, promptExecutor: PromptExecutor = this.promptExecutor, environment: AIAgentEnvironment = this.environment, config: AIAgentConfig = this.config, clock: KoogClock = this.clock): AIAgentLLMContext

Creates a copy of this LLM context, taking a consistent snapshot of its mutable fields under the internal read lock. Multiple concurrent copy / readSession calls may proceed in parallel, but any concurrent writeSession / withPrompt will serialize against them.

Link copied to clipboard
open suspend fun <T> readSession(block: suspend AIAgentLLMReadSession.() -> T): T

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

Link copied to clipboard
open suspend fun withPrompt(block: Prompt.() -> Prompt)

Atomically replaces prompt with the result of applying block to the current prompt while holding the internal write lock. Callers waiting for read or write access will be suspended until the transformation completes.

Link copied to clipboard
open suspend fun <T> writeSession(block: suspend AIAgentLLMWriteSession.() -> T): T

Executes a write session on the AIAgentLLMContext, suspending until all other active write and read sessions on this context complete, then running block under exclusive access. At the end of the session, prompt, tools and model are overwritten with the values mutated inside the session.