Skip to content

Commit 1a20d15

Browse files
author
ygyg70
committed
fix: resolving default parameter value as random UUID breaks native build
PR review - add a comment, also handle another similar usage in the same file
1 parent cca5bb4 commit 1a20d15

File tree

1 file changed

+4
-2
lines changed
  • agents/agents-core/src/commonMain/kotlin/ai/koog/agents/core/agent

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public open class AIAgent<Input, Output>(
133133

134134
private val pipeline = AIAgentPipeline()
135135

136+
// Uuid.random is using secure random, therefore, must be initialized at runtime when performing a native build
137+
// More about Java secure random and GrallVM: https://www.graalvm.org/jdk24/reference-manual/native-image/dynamic-features/JCASecurityServices/
136138
override val id: String by lazy { id ?: Uuid.random().toString() }
137139

138140
init {
@@ -459,7 +461,7 @@ public inline fun <reified Input, reified Output> AIAgent(
459461
promptExecutor: PromptExecutor,
460462
strategy: AIAgentStrategy<Input, Output>,
461463
agentConfig: AIAgentConfigBase,
462-
id: String = Uuid.random().toString(),
464+
id: String? = null,
463465
toolRegistry: ToolRegistry = ToolRegistry.EMPTY,
464466
clock: Clock = Clock.System,
465467
noinline installFeatures: FeatureContext.() -> Unit = {},
@@ -493,7 +495,7 @@ public inline fun <reified Input, reified Output> AIAgent(
493495
public fun AIAgent(
494496
executor: PromptExecutor,
495497
llmModel: LLModel,
496-
id: String = Uuid.random().toString(),
498+
id: String? = null,
497499
strategy: AIAgentStrategy<String, String> = singleRunStrategy(),
498500
systemPrompt: String = "",
499501
temperature: Double = 1.0,

0 commit comments

Comments
 (0)