Skip to content

Commit 928fdc1

Browse files
committed
Introduced AIAgentStrategy-2
1 parent f6adae5 commit 928fdc1

File tree

4 files changed

+87
-4
lines changed

4 files changed

+87
-4
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package ai.koog.agents.core.agent
2+
3+
import ai.koog.agents.core.agent.config.AIAgentConfigBase
4+
import ai.koog.agents.core.agent.context.AIAgentContext
5+
import ai.koog.agents.core.agent.context.AIAgentLLMContext
6+
import ai.koog.agents.core.agent.entity.AIAgentStateManager
7+
import ai.koog.agents.core.agent.entity.AIAgentStorage
8+
import ai.koog.agents.core.agent.entity.AIAgentStorageKey
9+
import ai.koog.agents.core.environment.AIAgentEnvironment
10+
import ai.koog.agents.core.feature.AIAgentFeature
11+
import ai.koog.prompt.message.Message
12+
13+
public class AIAgentLoopContext(
14+
override val environment: AIAgentEnvironment,
15+
override val agentId: String,
16+
override val runId: String,
17+
override val agentInput: Any?,
18+
override val config: AIAgentConfigBase,
19+
override val llm: AIAgentLLMContext,
20+
override val stateManager: AIAgentStateManager,
21+
override val storage: AIAgentStorage,
22+
override val strategyName: String
23+
) : AIAgentContext {
24+
override fun store(key: AIAgentStorageKey<*>, value: Any) {
25+
TODO("Not yet implemented")
26+
}
27+
28+
override fun <T> get(key: AIAgentStorageKey<*>): T? {
29+
TODO("Not yet implemented")
30+
}
31+
32+
override fun remove(key: AIAgentStorageKey<*>): Boolean {
33+
TODO("Not yet implemented")
34+
}
35+
36+
override fun <Feature : Any> feature(key: AIAgentStorageKey<Feature>): Feature? {
37+
TODO("Not yet implemented")
38+
}
39+
40+
override fun <Feature : Any> feature(feature: AIAgentFeature<*, Feature>): Feature? {
41+
TODO("Not yet implemented")
42+
}
43+
44+
override suspend fun getHistory(): List<Message> {
45+
TODO("Not yet implemented")
46+
}
47+
48+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ai.koog.agents.core.agent
2+
3+
import ai.koog.agents.core.agent.entity.AIAgentStrategy
4+
5+
/**
6+
*
7+
* */
8+
public class AIAgentLoopStrategy<Input, Output>(
9+
override val name: String
10+
): AIAgentStrategy<Input, Output, AIAgentLoopContext> {
11+
12+
}
13+

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
@file:Suppress("MissingKDocForPublicAPI")
2+
13
package ai.koog.agents.core.agent.entity
24

5+
import ai.koog.agents.core.agent.context.AIAgentContext
36
import ai.koog.agents.core.agent.context.AIAgentGraphContextBase
47
import ai.koog.agents.core.annotation.InternalAgentsApi
58
import ai.koog.agents.core.utils.runCatchingCancellable
69
import kotlinx.serialization.json.Json
710
import kotlinx.serialization.json.JsonElement
811
import kotlinx.serialization.serializer
912

13+
1014
/**
1115
* Represents a strategy for managing and executing AI agent workflows built as subgraphs of interconnected nodes.
1216
*
@@ -22,13 +26,12 @@ public class AIAgentGraphStrategy<Input, Output>(
2226
public val nodeFinish: FinishNode<Output>,
2327
toolSelectionStrategy: ToolSelectionStrategy,
2428
private val serializer: Json = Json { prettyPrint = true }
25-
) : AIAgentSubgraph<Input, Output>(
29+
) : AIAgentStrategy<Input, Output, AIAgentGraphContextBase>, AIAgentSubgraph<Input, Output>(
2630
name,
2731
nodeStart,
2832
nodeFinish,
2933
toolSelectionStrategy
30-
),
31-
AIAgentStrategy {
34+
) {
3235
/**
3336
* Represents the metadata of the subgraph associated with the AI agent strategy.
3437
*

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ai.koog.agents.core.agent.entity
22

33
import ai.koog.agents.core.agent.context.AIAgentContext
4+
import ai.koog.agents.core.agent.context.AIAgentGraphContextBase
45

56
/**
67
* An interface representing the execution strategy of an AI agent.
@@ -14,7 +15,7 @@ import ai.koog.agents.core.agent.context.AIAgentContext
1415
* @param Output The type of output data that the strategy will generate.
1516
* @param TContext The type of context in which the strategy is executed, extending [AIAgentContext].
1617
*/
17-
public interface AIAgentStrategy {
18+
public interface AIAgentStrategy<Input, Output, TContext: AIAgentContext> {
1819
/**
1920
* The name of the AI agent strategy.
2021
*
@@ -23,4 +24,22 @@ public interface AIAgentStrategy {
2324
* multiple strategies within the system.
2425
*/
2526
public val name: String
27+
28+
/**
29+
* Executes the AI agent's strategy using the provided context and input.
30+
*
31+
* This method processes the given input data within the specified context, leveraging
32+
* the AI agent's internal logic and strategy to produce an output. The result of this
33+
* execution may depend on the graph-based execution pipeline, decision-making processes,
34+
* and other stateful operations defined in the context.
35+
*
36+
* @param context The execution context in which the AI agent operates. It provides access
37+
* to the agent's configuration, pipeline, environment, and other components required for
38+
* execution in a graph-based structure.
39+
* @param input The input data to be processed by the AI agent's strategy. The type of input
40+
* is defined by the strategy's implementation and is used to derive the resulting output.
41+
* @return The output produced by the AI agent's strategy, or null if no output is generated.
42+
* The output type is defined by the strategy's implementation.
43+
*/
44+
public suspend fun execute(context: AIAgentGraphContextBase, input: Input): Output?
2645
}

0 commit comments

Comments
 (0)