AIAgentLLMReadSession

Represents a session for interacting with a language model (LLM) in a read-only context within an AI agent setup.

JVM actual implementation of a read-only LLM session.

In addition to common suspend APIs, this class exposes Java-friendly wrappers that run session operations on the strategy dispatcher.

Represents a session for interacting with a language model (LLM) in a read-only context within an AI agent setup.

Constructors

Link copied to clipboard
actual constructor(tools: List<ERROR CLASS: Symbol not found for ToolDescriptor>, executor: ERROR CLASS: Symbol not found for PromptExecutor, prompt: ERROR CLASS: Symbol not found for Prompt, model: ERROR CLASS: Symbol not found for LLModel, responseProcessor: ERROR CLASS: Symbol not found for ResponseProcessor??, config: AIAgentConfig)
actual constructor(tools: List<ToolDescriptor>, executor: PromptExecutor, prompt: Prompt, model: LLModel, responseProcessor: ResponseProcessor?, config: AIAgentConfig)

Properties

Link copied to clipboard

Config of the agent running the session.

Config of the agent running the session.

Config of the agent running the session.

Link copied to clipboard

Represents the active language model used within the session.

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

Represents the active language model used within the session.

Represents the active language model used within the session.

Link copied to clipboard

Represents the current prompt associated with the LLM session. The prompt contains the input messages, model configuration, and parameters.

val prompt: ai/koog/prompt/dsl/Prompt

Represents the current prompt associated with the LLM session. The prompt contains the input messages, model configuration, and parameters.

Represents the current prompt associated with the LLM session. The prompt contains the input messages, model configuration, and parameters.

Link copied to clipboard

Represents the active response processor within the session.

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

Represents the active response processor within the session.

Represents the active response processor within the session.

Link copied to clipboard

Provides a list of available tools in the session.

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

Provides a list of available tools in the session.

Provides a list of available tools in the session.

Functions

Link copied to clipboard
open override fun close()
open override fun close()
open override fun close()
Link copied to clipboard

Executes a request for the provided prompt and tools and returns all response messages.

fun executeMultiple(prompt: ERROR CLASS: Symbol not found for Prompt, tools: List<ERROR CLASS: Symbol not found for ToolDescriptor>, executorService: ExecutorService? = null): List<ERROR CLASS: Symbol not found for Message.Response>

Executes multiple tasks or requests associated with the given Prompt and ToolDescriptor list.

suspend fun executeMultiple(prompt: ai/koog/prompt/dsl/Prompt, tools: List<ai/koog/agents/core/tools/ToolDescriptor>): List<ai/koog/prompt/message/Message.Response>

Executes a request for the provided prompt and tools and returns all response messages.

Executes a request for the provided prompt and tools and returns all response messages.

Link copied to clipboard

Executes a request for the provided prompt and tools and returns the first response.

fun executeSingle(prompt: ERROR CLASS: Symbol not found for Prompt, tools: List<ERROR CLASS: Symbol not found for ToolDescriptor>, executorService: ExecutorService? = null): ERROR CLASS: Symbol not found for Message.Response

Executes a single task or request associated with the given Prompt and ToolDescriptor list.

suspend fun executeSingle(prompt: ai/koog/prompt/dsl/Prompt, tools: List<ai/koog/agents/core/tools/ToolDescriptor>): ai/koog/prompt/message/Message.Response

Executes a request for the provided prompt and tools and returns the first response.

Executes a request for the provided prompt and tools and returns the first response.

Link copied to clipboard

Executes a streaming request for the provided prompt and tools.

fun executeStreaming(prompt: ai/koog/prompt/dsl/Prompt, tools: List<ai/koog/agents/core/tools/ToolDescriptor>): kotlinx/coroutines/flow/Flow<ai/koog/prompt/streaming/StreamFrame>

Executes a streaming request for the provided prompt and tools.

Executes a streaming request for the provided prompt and tools.

Link copied to clipboard

Parses a structured response from a language model message using the specified configuration.

fun <T> parseResponseToStructuredResponse(response: ERROR CLASS: Symbol not found for Message.Assistant, config: ERROR CLASS: Symbol not found for StructuredRequestConfig<T>, fixingParser: ERROR CLASS: Symbol not found for StructureFixingParser?? = null, executorService: ExecutorService? = null): ERROR CLASS: Symbol not found for StructuredResponse<T>

Parses an assistant response into a strongly typed StructuredResponse according to the given configuration.

suspend fun <T> parseResponseToStructuredResponse(response: ai/koog/prompt/message/Message.Assistant, config: ai/koog/prompt/structure/StructuredRequestConfig<T>, fixingParser: ai/koog/prompt/executor/model/StructureFixingParser?? = null): ai/koog/prompt/structure/StructuredResponse<T>

Parses a structured response from a language model message using the specified configuration.

Parses a structured response from a language model message using the specified configuration.

Link copied to clipboard

Sends a request to the underlying LLM and returns the first non-reasoning response.

fun requestLLM(executorService: ExecutorService? = null): ERROR CLASS: Symbol not found for Message.Response

Sends a request to the language model using the current session configuration and returns a single response.

suspend fun requestLLM(): ai/koog/prompt/message/Message.Response

Sends a request to the underlying LLM and returns the first non-reasoning response.

Sends a request to the underlying LLM and returns the first non-reasoning response.

Link copied to clipboard
suspend fun requestLLMForceOneTool(tool: Tool<*, *>): Message.Response

Sends a request to the language model while enforcing the use of a specific tool.

fun requestLLMForceOneTool(tool: ERROR CLASS: Symbol not found for Tool<*, *>, executorService: ExecutorService? = null): ERROR CLASS: Symbol not found for Message.Response

Sends a request to the language model and forces it to use exactly one specific tool instance.

fun requestLLMForceOneTool(tool: ERROR CLASS: Symbol not found for ToolDescriptor, executorService: ExecutorService? = null): ERROR CLASS: Symbol not found for Message.Response

Sends a request to the language model and forces it to use exactly one specific tool, identified by a ToolDescriptor.

suspend fun requestLLMForceOneTool(tool: ai/koog/agents/core/tools/Tool<*, *>): ai/koog/prompt/message/Message.Response
suspend fun requestLLMForceOneTool(tool: ai/koog/agents/core/tools/ToolDescriptor): ai/koog/prompt/message/Message.Response

Sends a request to the language model while enforcing the use of a specific tool.

suspend fun requestLLMForceOneTool(tool: Tool<*, *>): Message.Response

Sends a request to the language model while enforcing the use of a specific tool.

Link copied to clipboard

Sends a request to the language model and returns all response messages.

fun requestLLMMultiple(executorService: ExecutorService? = null): List<ERROR CLASS: Symbol not found for Message.Response>

Sends a request to the language model and returns multiple responses.

suspend fun requestLLMMultiple(): List<ai/koog/prompt/message/Message.Response>

Sends a request to the language model and returns all response messages.

Sends a request to the language model and returns all response messages.

Link copied to clipboard

Sends a request to the language model and returns all available response choices.

fun requestLLMMultipleChoices(executorService: ExecutorService? = null): List<ERROR CLASS: Symbol not found for LLMChoice>

Sends a request to the language model and returns multiple choice alternatives.

suspend fun requestLLMMultipleChoices(): List<List<ai/koog/prompt/message/Message.Response>>

Sends a request to the language model and returns all available response choices.

Sends a request to the language model and returns all available response choices.

Link copied to clipboard

Sends a request to the language model that enforces the usage of tools and retrieves all responses.

fun requestLLMMultipleOnlyCallingTools(executorService: ExecutorService? = null): List<ERROR CLASS: Symbol not found for Message.Response>
suspend fun requestLLMMultipleOnlyCallingTools(): List<ai/koog/prompt/message/Message.Response>

Sends a request to the language model that enforces the usage of tools and retrieves all responses.

Sends a request to the language model that enforces the usage of tools and retrieves all responses.

Link copied to clipboard

Sends a request to the language model without utilizing any tools and returns multiple responses.

fun requestLLMMultipleWithoutTools(executorService: ExecutorService? = null): List<ERROR CLASS: Symbol not found for Message.Response>
suspend fun requestLLMMultipleWithoutTools(): List<ai/koog/prompt/message/Message.Response>

Sends a request to the language model without utilizing any tools and returns multiple responses.

Sends a request to the language model without utilizing any tools and returns multiple responses.

Link copied to clipboard

Sends a request to the language model that enforces the usage of tools and retrieves the response.

fun requestLLMOnlyCallingTools(executorService: ExecutorService? = null): ERROR CLASS: Symbol not found for Message.Response

Sends a request to the language model that is allowed to only perform tool calls without generating a regular text response.

suspend fun requestLLMOnlyCallingTools(): ai/koog/prompt/message/Message.Response

Sends a request to the language model that enforces the usage of tools and retrieves the response.

Sends a request to the language model that enforces the usage of tools and retrieves the response.

Link copied to clipboard

Sends a streaming request to the underlying LLM and returns the streamed response.

fun requestLLMStreaming(executorService: ExecutorService? = null): Flow.Publisher<ERROR CLASS: Symbol not found for StreamFrame>

Sends a request to the language model and returns a streaming response as a Flow of StreamFrame.

suspend fun requestLLMStreaming(): kotlinx/coroutines/flow/Flow<ai/koog/prompt/streaming/StreamFrame>

Sends a streaming request to the underlying LLM and returns the streamed response.

Sends a streaming request to the underlying LLM and returns the streamed response.

Link copied to clipboard
suspend fun <T> requestLLMStructured(serializer: KSerializer<T>, examples: List<T> = emptyList(), fixingParser: StructureFixingParser? = null): Result<StructuredResponse<T>>

Sends a request to LLM and gets a structured response.

inline suspend fun <T> requestLLMStructured(examples: List<T> = emptyList(), fixingParser: StructureFixingParser? = null): Result<StructuredResponse<T>>

Requests a structured response from the language model using a reified serializer.

fun <T> requestLLMStructured(config: ERROR CLASS: Symbol not found for StructuredRequestConfig<T>, fixingParser: ERROR CLASS: Symbol not found for StructureFixingParser?? = null, executorService: ExecutorService? = null): ERROR CLASS: Symbol not found for Result<ERROR CLASS: Symbol not found for StructuredResponse<T>>

Sends a structured request to the language model using a StructuredRequestConfig.

fun <T> requestLLMStructured(serializer: ERROR CLASS: Symbol not found for KSerializer<T>, examples: List<T> = emptyList(), fixingParser: ERROR CLASS: Symbol not found for StructureFixingParser?? = null, executorService: ExecutorService? = null): ERROR CLASS: Symbol not found for Result<ERROR CLASS: Symbol not found for StructuredResponse<T>>

Sends a structured request to the language model using an explicit serializer and example values.

suspend fun <T> requestLLMStructured(config: ai/koog/prompt/structure/StructuredRequestConfig<T>, fixingParser: ai/koog/prompt/executor/model/StructureFixingParser?? = null): kotlin/Result<ai/koog/prompt/structure/StructuredResponse<T>>
suspend fun <T> requestLLMStructured(serializer: kotlinx/serialization/KSerializer<T>, examples: List<T> = emptyList(), fixingParser: ai/koog/prompt/executor/model/StructureFixingParser?? = null): kotlin/Result<ai/koog/prompt/structure/StructuredResponse<T>>

Sends a request to LLM and gets a structured response.

inline suspend fun <T> requestLLMStructured(examples: List<T> = emptyList(), fixingParser: ai/koog/prompt/executor/model/StructureFixingParser?? = null): kotlin/Result<ai/koog/prompt/structure/StructuredResponse<T>>

Requests a structured response from the language model using a reified serializer.

suspend fun <T> requestLLMStructured(serializer: KSerializer<T>, examples: List<T> = emptyList(), fixingParser: StructureFixingParser? = null): Result<StructuredResponse<T>>

Sends a request to LLM and gets a structured response.

inline suspend fun <T> requestLLMStructured(examples: List<T> = emptyList(), fixingParser: StructureFixingParser? = null): Result<StructuredResponse<T>>

Requests a structured response from the language model using a reified serializer.

Link copied to clipboard

Sends a request to the language model without utilizing any tools and returns the response.

fun requestLLMWithoutTools(executorService: ExecutorService? = null): ERROR CLASS: Symbol not found for Message.Response

Sends a request to the language model without utilizing any tools and returns a single response.

suspend fun requestLLMWithoutTools(): ai/koog/prompt/message/Message.Response

Sends a request to the language model without utilizing any tools and returns the response.

Sends a request to the language model without utilizing any tools and returns the response.

Link copied to clipboard
suspend fun requestModeration(moderatingModel: LLModel? = null): ModerationResult

Sends a moderation request to the specified or default model.

fun requestModeration(moderatingModel: ERROR CLASS: Symbol not found for LLModel?? = null, executorService: ExecutorService? = null): ERROR CLASS: Symbol not found for ModerationResult

Sends a moderation request to the moderation model.

suspend fun requestModeration(moderatingModel: ai/koog/prompt/llm/LLModel?? = null): ai/koog/prompt/dsl/ModerationResult

Sends a moderation request to the specified or default model.

suspend fun requestModeration(moderatingModel: LLModel? = null): ModerationResult

Sends a moderation request to the specified or default model.