AIAgent

Represents a basic interface for AI agent.

Inheritors

Types

Link copied to clipboard
object Companion

The companion object for the AIAgent class, providing functionality to instantiate an AI agent with a flexible configuration, input/output types, and execution strategy.

Properties

Link copied to clipboard

The configuration for the AI agent.

Link copied to clipboard
abstract val id: String

Represents the unique identifier for the AI agent.

Functions

Link copied to clipboard
inline fun <Input, Output> AIAgent<Input, Output>.asTool(agentName: String, agentDescription: String, inputDescription: String? = null, inputSerializer: KSerializer<Input> = serializer(), outputSerializer: KSerializer<Output> = serializer(), json: Json = Json.Default): Tool<AIAgentTool.AgentToolArgs, AIAgentTool.AgentToolResult>

Converts the current AI agent into a tool to allow using it in other agents as a tool.

Link copied to clipboard
abstract suspend fun close()
Link copied to clipboard
abstract suspend fun getState(): AIAgent.Companion.State<Output>

Retrieves the current state of the AI agent during its lifecycle.

Link copied to clipboard
suspend fun AIAgent<*, *>.isFinished(): Boolean

Checks whether the AI agent has reached a finished state.

Link copied to clipboard
suspend fun AIAgent<*, *>.isRunning(): Boolean

Checks whether the AI agent is currently in a running state.

Link copied to clipboard
open suspend fun result(): Output

Retrieves the result of the operation if the current state is State.Finished. Throws an IllegalStateException if the operation is not in a finished state.

Link copied to clipboard
abstract suspend fun run(agentInput: Input): Output

Executes the AI agent with the given input and retrieves the resulting output.