AIAgentLLMContext

Represents the context for an AI agent LLM, managing tools, prompt handling, and interaction with the environment and execution layers. It provides mechanisms for concurrent read and write operations through sessions, ensuring thread safety.

It inherits all shared behavior from AIAgentLLMContextCommon.

Constructs a new instance of AIAgentLLMContext with the provided parameters.

Parameters

tools

A list of tools described by ToolDescriptor that the agent can interact with.

toolRegistry

A registry of available tools, defaulting to an empty ToolRegistry.

prompt

The initial prompt used in the context, represented by a Prompt instance.

model

The language model used for processing prompts and generating responses.

responseProcessor

An optional ResponseProcessor for handling and processing model responses.

promptExecutor

Responsible for executing the logic for prompt processing in the context.

environment

The operational environment of the AI agent, represented by an AIAgentEnvironment.

config

Configuration settings for the AI agent, encapsulated in an AIAgentConfig.

clock

A clock instance for managing time-related operations within the context.

Represents the context for an AI agent LLM, managing tools, prompt handling, and interaction with the environment and execution layers. It provides mechanisms for concurrent read and write operations through sessions, ensuring thread safety.

It inherits all shared behavior from AIAgentLLMContextCommon.

Constructs a new instance of AIAgentLLMContext with the provided parameters.

Parameters

tools

A list of tools described by ToolDescriptor that the agent can interact with.

toolRegistry

A registry of available tools, defaulting to an empty ToolRegistry.

prompt

The initial prompt used in the context, represented by a Prompt instance.

model

The language model used for processing prompts and generating responses.

responseProcessor

An optional ResponseProcessor for handling and processing model responses.

promptExecutor

Responsible for executing the logic for prompt processing in the context.

environment

The operational environment of the AI agent, represented by an AIAgentEnvironment.

config

Configuration settings for the AI agent, encapsulated in an AIAgentConfig.

clock

A clock instance for managing time-related operations within the context.

Represents the context for an AI agent LLM, managing tools, prompt handling, and interaction with the environment and execution layers. It provides mechanisms for concurrent read and write operations through sessions, ensuring thread safety.

It inherits all shared behavior from AIAgentLLMContextCommon.

Constructs a new instance of AIAgentLLMContext with the provided parameters.

Parameters

tools

A list of tools described by ToolDescriptor that the agent can interact with.

toolRegistry

A registry of available tools, defaulting to an empty ToolRegistry.

prompt

The initial prompt used in the context, represented by a Prompt instance.

model

The language model used for processing prompts and generating responses.

responseProcessor

An optional ResponseProcessor for handling and processing model responses.

promptExecutor

Responsible for executing the logic for prompt processing in the context.

environment

The operational environment of the AI agent, represented by an AIAgentEnvironment.

config

Configuration settings for the AI agent, encapsulated in an AIAgentConfig.

clock

A clock instance for managing time-related operations within the context.

Constructors

Link copied to clipboard
expect constructor(tools: List<ToolDescriptor>, toolRegistry: ToolRegistry = ToolRegistry.EMPTY, prompt: Prompt, model: LLModel, responseProcessor: ResponseProcessor?, promptExecutor: PromptExecutor, environment: AIAgentEnvironment, config: AIAgentConfig, clock: KoogClock)
actual constructor(tools: List<ERROR CLASS: Symbol not found for ToolDescriptor>, toolRegistry: ERROR CLASS: Symbol not found for ToolRegistry, prompt: ERROR CLASS: Symbol not found for Prompt, model: ERROR CLASS: Symbol not found for LLModel, responseProcessor: ERROR CLASS: Symbol not found for ResponseProcessor??, promptExecutor: ERROR CLASS: Symbol not found for PromptExecutor, environment: AIAgentEnvironment, config: AIAgentConfig, clock: ERROR CLASS: Symbol not found for KoogClock)
actual constructor(tools: List<ToolDescriptor>, toolRegistry: ToolRegistry, prompt: Prompt, model: LLModel, responseProcessor: ResponseProcessor?, promptExecutor: PromptExecutor, environment: AIAgentEnvironment, config: AIAgentConfig, clock: KoogClock)

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.

val clock: ai/koog/utils/time/KoogClock

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

@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.

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

@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.

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

@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.

var model: ai/koog/prompt/llm/LLModel

LLM currently associated with this context.

LLM currently associated with this context.

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

The current prompt used within the AIAgentLLMContext.

var prompt: ai/koog/prompt/Prompt

The current prompt used within the AIAgentLLMContext.

@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.

val promptExecutor: ai/koog/prompt/executor/model/PromptExecutor

The PromptExecutor responsible for performing operations on the current prompt.

The PromptExecutor responsible for performing operations on the current prompt.

Link copied to clipboard

Response processor currently associated with this context.

var responseProcessor: ai/koog/prompt/processor/ResponseProcessor??

Response processor currently associated with this context.

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.

val toolRegistry: ai/koog/agents/core/tools/ToolRegistry

A ToolRegistry that contains metadata about available tools.

@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.

var tools: List<ai/koog/agents/core/tools/ToolDescriptor>

List of current tools associated with this agent context.

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.

open override fun copy(tools: List<ERROR CLASS: Symbol not found for ToolDescriptor>, prompt: ERROR CLASS: Symbol not found for Prompt, model: ERROR CLASS: Symbol not found for LLModel, responseProcessor: ERROR CLASS: Symbol not found for ResponseProcessor??, promptExecutor: ERROR CLASS: Symbol not found for PromptExecutor, environment: AIAgentEnvironment, config: AIAgentConfig, clock: ERROR CLASS: Symbol not found for KoogClock): AIAgentLLMContext
open suspend override fun copy(tools: List<ERROR CLASS: Symbol not found for ToolDescriptor>, toolRegistry: ERROR CLASS: Symbol not found for ToolRegistry, prompt: ERROR CLASS: Symbol not found for Prompt, model: ERROR CLASS: Symbol not found for LLModel, responseProcessor: ERROR CLASS: Symbol not found for ResponseProcessor??, promptExecutor: ERROR CLASS: Symbol not found for PromptExecutor, environment: AIAgentEnvironment, config: AIAgentConfig, clock: ERROR CLASS: Symbol not found for KoogClock): AIAgentLLMContext

open fun copy(tools: List<ai/koog/agents/core/tools/ToolDescriptor> = this.tools, prompt: ai/koog/prompt/Prompt = this.prompt, model: ai/koog/prompt/llm/LLModel = this.model, responseProcessor: ai/koog/prompt/processor/ResponseProcessor?? = this.responseProcessor, promptExecutor: ai/koog/prompt/executor/model/PromptExecutor = this.promptExecutor, environment: AIAgentEnvironment = this.environment, config: AIAgentConfig = this.config, clock: ai/koog/utils/time/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<ai/koog/agents/core/tools/ToolDescriptor> = this.tools, toolRegistry: ai/koog/agents/core/tools/ToolRegistry = this.toolRegistry, prompt: ai/koog/prompt/Prompt = this.prompt, model: ai/koog/prompt/llm/LLModel = this.model, responseProcessor: ai/koog/prompt/processor/ResponseProcessor?? = this.responseProcessor, promptExecutor: ai/koog/prompt/executor/model/PromptExecutor = this.promptExecutor, environment: AIAgentEnvironment = this.environment, config: AIAgentConfig = this.config, clock: ai/koog/utils/time/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.

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.

Executes a read-only session within the context of AIAgentLLMReadSession and returns the result of the provided block.

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.

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.

open suspend fun withPrompt(block: ai/koog/prompt/Prompt.() -> ai/koog/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.

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.

Executes a block of code within a write session for the AI Agent LLM context.

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.

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.