Skip to content

Commit 58b3a14

Browse files
committed
JBAI-13757. Update the tracing feature with handling new events in an agent from the EventHandler class
- Update logic to set JSON config for remote writers in agent features to correctly process with dependencies; - Add new events from the EventHandler class; - Update all tests.
1 parent 92a3a86 commit 58b3a14

File tree

41 files changed

+838
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+838
-240
lines changed

agents/agents-core/src/commonMain/kotlin/ai/grazie/code/agents/core/agent/AIAgentBase.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import ai.grazie.code.agents.core.environment.AgentEnvironmentUtils.mapToToolRes
88
import ai.grazie.code.agents.core.environment.ReceivedToolResult
99
import ai.grazie.code.agents.core.environment.TerminationTool
1010
import ai.grazie.code.agents.core.exception.AgentEngineException
11-
import ai.grazie.code.agents.core.feature.AIAgentPipeline
11+
import ai.grazie.code.agents.core.feature.AgentPipeline
1212
import ai.grazie.code.agents.core.feature.KotlinAIAgentFeature
1313
import ai.grazie.code.agents.core.model.AgentServiceError
1414
import ai.grazie.code.agents.core.model.AgentServiceErrorType
@@ -81,7 +81,7 @@ open class AIAgentBase(
8181

8282
private val agentResultDeferred: CompletableDeferred<String?> = CompletableDeferred()
8383

84-
private val pipeline = AIAgentPipeline()
84+
private val pipeline = AgentPipeline()
8585

8686
init {
8787
cs.launch(context = Dispatchers.SuitableForIO, start = CoroutineStart.UNDISPATCHED) {
@@ -138,7 +138,7 @@ open class AIAgentBase(
138138

139139
override suspend fun executeTools(toolCalls: List<Message.Tool.Call>): List<ReceivedToolResult> {
140140
logger.info { formatLog("Executing tools '$toolCalls'") }
141-
pipeline.onBeforeToolCalls(toolCalls)
141+
pipeline.onBeforeToolCalls(tools = toolCalls)
142142

143143
val message = AgentToolCallsToEnvironmentMessage(
144144
sessionUuid = sessionUuid ?: throw IllegalStateException("Session UUID is null"),
@@ -153,7 +153,7 @@ open class AIAgentBase(
153153
)
154154

155155
val results = processToolCallMultiple(message).mapToToolResult()
156-
pipeline.onAfterToolCalls(results)
156+
pipeline.onAfterToolCalls(tools = toolCalls, results)
157157
return results
158158
}
159159

@@ -239,7 +239,7 @@ open class AIAgentBase(
239239
}
240240
catch (e: ToolException) {
241241

242-
pipeline.onToolValidationError(stage = stage, tool = tool, toolArgs = toolArgs, value = e.message)
242+
pipeline.onToolValidationError(stage = stage, tool = tool, toolArgs = toolArgs, error = e.message)
243243

244244
return toolResult(
245245
message = e.message,

agents/agents-core/src/commonMain/kotlin/ai/grazie/code/agents/core/agent/entity/LocalAgentStrategy.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ai.grazie.code.agents.core.dsl.builder.forwardTo
1515
import ai.grazie.code.agents.core.dsl.extension.clearHistory
1616
import ai.grazie.code.agents.core.dsl.extension.nodeLLMCompressHistory
1717
import ai.grazie.code.agents.core.environment.AgentEnvironment
18-
import ai.grazie.code.agents.core.feature.AIAgentPipeline
18+
import ai.grazie.code.agents.core.feature.AgentPipeline
1919
import ai.grazie.code.agents.core.feature.PromptExecutorProxy
2020
import ai.grazie.utils.mpp.UUID
2121
import ai.jetbrains.code.prompt.executor.model.PromptExecutor
@@ -166,7 +166,7 @@ class LocalAgentStrategy(
166166
promptExecutor: PromptExecutor,
167167
environment: AgentEnvironment,
168168
config: LocalAgentConfig,
169-
pipeline: AIAgentPipeline,
169+
pipeline: AgentPipeline,
170170
) {
171171
val stateManager = LocalAgentStateManager()
172172
val storage = LocalAgentStorage()

agents/agents-core/src/commonMain/kotlin/ai/grazie/code/agents/core/agent/entity/stage/LocalAgentStageContext.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import ai.grazie.code.agents.core.agent.entity.LocalAgentStorageKey
99
import ai.grazie.code.agents.core.annotation.InternalAgentsApi
1010
import ai.grazie.code.agents.core.environment.AgentEnvironment
1111
import ai.grazie.code.agents.core.environment.SafeTool
12-
import ai.grazie.code.agents.core.feature.AIAgentPipeline
12+
import ai.grazie.code.agents.core.feature.AgentPipeline
1313
import ai.grazie.code.agents.core.feature.KotlinAIAgentFeature
1414
import ai.grazie.code.agents.core.tools.Tool
1515
import ai.grazie.code.agents.core.tools.ToolDescriptor
@@ -134,7 +134,7 @@ interface LocalAgentStageContext {
134134
* it is subject to changes or alterations in future releases.
135135
*/
136136
@InternalAgentsApi
137-
val pipeline: AIAgentPipeline
137+
val pipeline: AgentPipeline
138138

139139
/**
140140
* Retrieves a feature from the local agent's storage using the specified key.
@@ -191,7 +191,7 @@ interface LocalAgentStageContext {
191191
sessionUuid: UUID? = null,
192192
strategyId: String? = null,
193193
stageName: String? = null,
194-
pipeline: AIAgentPipeline? = null,
194+
pipeline: AgentPipeline? = null,
195195
): LocalAgentStageContext
196196
}
197197

@@ -223,7 +223,7 @@ class LocalAgentStageContextImpl constructor(
223223
override val sessionUuid: UUID,
224224
override val strategyId: String,
225225
override val stageName: String,
226-
override val pipeline: AIAgentPipeline,
226+
override val pipeline: AgentPipeline,
227227
) : LocalAgentStageContext {
228228
/**
229229
* A map storing features associated with the current stage context.
@@ -291,7 +291,7 @@ class LocalAgentStageContextImpl constructor(
291291
sessionUuid: UUID?,
292292
strategyId: String?,
293293
stageName: String?,
294-
pipeline: AIAgentPipeline?,
294+
pipeline: AgentPipeline?,
295295
) = LocalAgentStageContextImpl(
296296
environment = environment ?: this.environment,
297297
stageInput = stageInput ?: this.stageInput,

0 commit comments

Comments
 (0)