Skip to content

Commit 978414b

Browse files
deprecate companion invokes on multiple classes, add proper factory methods
1 parent e40dc81 commit 978414b

23 files changed

Lines changed: 645 additions & 536 deletions

File tree

agents/agents-core/src/commonMain/kotlin/ai/koog/agents/core/agent/AIAgent.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import kotlin.uuid.ExperimentalUuidApi
2121
/**
2222
* Represents a basic interface for AI agent.
2323
*/
24-
public expect abstract class AIAgent<Input, Output> constructor() : Closeable {
24+
public expect abstract class AIAgent<Input, Output>() : Closeable {
2525

2626
/**
2727
* Represents the unique identifier for the AI agent.
@@ -53,14 +53,13 @@ public expect abstract class AIAgent<Input, Output> constructor() : Closeable {
5353
public abstract fun createSession(sessionId: String? = null): AIAgentRunSession<Input, Output, out AIAgentContext>
5454

5555
/**
56-
* The companion object for the AIAgent class, providing functionality to instantiate an AI agent
57-
* with a flexible configuration, input/output types, and execution strategy.
56+
* Companion object with builder for [AIAgent]
5857
*/
5958
public companion object {
6059
/**
6160
* Creates and returns a new instance of the [AIAgentBuilder] class to configure and construct an AI agent.
6261
*
63-
* @return An instance of `Builder` for configuring an AI agent.
62+
* @return An instance of [AIAgentBuilder] for configuring an AI agent.
6463
*/
6564
@JvmStatic
6665
public fun builder(): AIAgentBuilder
@@ -81,6 +80,7 @@ public expect abstract class AIAgent<Input, Output> constructor() : Closeable {
8180
* @return An instance of an AI agent configured with the specified parameters and capable of executing its logic.
8281
*/
8382
@OptIn(ExperimentalUuidApi::class)
83+
@Deprecated("Use AIAgent(...)")
8484
public inline operator fun <reified Input, reified Output> invoke(
8585
promptExecutor: PromptExecutor,
8686
agentConfig: AIAgentConfig,
@@ -103,6 +103,7 @@ public expect abstract class AIAgent<Input, Output> constructor() : Closeable {
103103
* @return An instance of AIAgent configured with the graph strategy.
104104
*/
105105
@OptIn(ExperimentalUuidApi::class)
106+
@Deprecated("Use AIAgent(...)")
106107
public operator fun invoke(
107108
promptExecutor: PromptExecutor,
108109
agentConfig: AIAgentConfig,
@@ -127,6 +128,7 @@ public expect abstract class AIAgent<Input, Output> constructor() : Closeable {
127128
* @return A `FunctionalAIAgent` instance configured with the provided parameters and execution strategy.
128129
*/
129130
@OptIn(ExperimentalUuidApi::class)
131+
@Deprecated("Use AIAgent(...)")
130132
public operator fun <Input, Output> invoke(
131133
promptExecutor: PromptExecutor,
132134
agentConfig: AIAgentConfig,
@@ -154,6 +156,7 @@ public expect abstract class AIAgent<Input, Output> constructor() : Closeable {
154156
* @return An instance of [AIAgent] configured with the provided parameters.
155157
*/
156158
@OptIn(ExperimentalUuidApi::class)
159+
@Deprecated("Use AIAgent(...)")
157160
public operator fun invoke(
158161
promptExecutor: PromptExecutor,
159162
llmModel: LLModel,
@@ -188,6 +191,7 @@ public expect abstract class AIAgent<Input, Output> constructor() : Closeable {
188191
* @return A configured [AIAgent] instance that can process inputs and generate outputs using the specified strategy and model.
189192
*/
190193
@OptIn(ExperimentalUuidApi::class)
194+
@Deprecated("Use AIAgent(...)")
191195
public inline operator fun <reified Input, reified Output> invoke(
192196
promptExecutor: PromptExecutor,
193197
llmModel: LLModel,
@@ -222,6 +226,7 @@ public expect abstract class AIAgent<Input, Output> constructor() : Closeable {
222226
* @param installFeatures A lambda to configure and install features in the agent's context.
223227
* @return An AI agent instance configured with the provided parameters and ready to execute the specified strategy.
224228
*/
229+
@Deprecated("Use AIAgent(...)")
225230
public operator fun <Input, Output> invoke(
226231
promptExecutor: PromptExecutor,
227232
llmModel: LLModel,
@@ -252,6 +257,7 @@ public expect abstract class AIAgent<Input, Output> constructor() : Closeable {
252257
* @param installFeatures A lambda for configuring additional features in the agent.
253258
* @return An AI agent instance configured with the provided parameters.
254259
*/
260+
@Deprecated("Use AIAgent(...)")
255261
public operator fun <Input, Output> invoke(
256262
promptExecutor: PromptExecutor,
257263
llmModel: LLModel,
@@ -278,6 +284,7 @@ public expect abstract class AIAgent<Input, Output> constructor() : Closeable {
278284
* @param installFeatures A lambda function used to install additional features into the agent's feature context.
279285
* @return An instance of an AI agent configured with the provided parameters that maps a world state to another world state.
280286
*/
287+
@Deprecated("Use AIAgent(...)")
281288
public operator fun <Input, Output> invoke(
282289
promptExecutor: PromptExecutor,
283290
agentConfig: AIAgentConfig,

0 commit comments

Comments
 (0)