Add AgentTaskFinishedEvent emitted when AgentProcess completes#333
Merged
Conversation
…inish-check logic - Create AgentTaskFinishedEvent record with agentProcessId, AgentProcessStatusCode, and finishedAt - Add AGENT_TASK_FINISHED_TYPE constant to AgenticAggregateRuntime interface - Add onAgentTaskFinished handler that removes the task from TaskAwareState - Update handleBuiltInEvent dispatch to route AgentTaskFinishedEvent - Register AGENT_TASK_FINISHED_TYPE in AgenticAggregateRuntimeFactory - Check agentProcess.getFinished() after each tick in resumeNextAgentTask - Add comprehensive unit tests for event-sourcing and finish detection Agent-Logs-Url: https://github.com/elasticsoftwarefoundation/akces-framework/sessions/e33a93e3-5553-4c53-a248-d6cf99a70840 Co-authored-by: jwijgerd <914840+jwijgerd@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
jwijgerd
April 11, 2026 10:47
View session
jwijgerd
marked this pull request as ready for review
April 11, 2026 10:47
Contributor
There was a problem hiding this comment.
Pull request overview
Adds agent-task lifecycle completion tracking to the agentic runtime by emitting a new built-in AgentTaskFinishedEvent when an AgentProcess finishes, and applying a built-in event-sourcing handler to remove the corresponding AssignedTask from TaskAwareState.
Changes:
- Introduces
AgentTaskFinishedEvent(includes process status + finish timestamp). - Updates
KafkaAgenticAggregateRuntimeto emit the finished event after a tick whenAgentProcess.getFinished()istrue, and to handle the event via built-in dispatch. - Registers the new domain event type + built-in event-sourcing handler in
AgenticAggregateRuntimeFactory, and adds/updates unit tests around handler dispatch + resume behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| main/agentic/src/main/java/org/elasticsoftware/akces/agentic/events/AgentTaskFinishedEvent.java | Adds new built-in domain event for agent task completion. |
| main/agentic/src/main/java/org/elasticsoftware/akces/agentic/AgenticAggregateRuntime.java | Adds AGENT_TASK_FINISHED_TYPE constant for runtime registration. |
| main/agentic/src/main/java/org/elasticsoftware/akces/agentic/runtime/KafkaAgenticAggregateRuntime.java | Emits finished events post-tick and applies them via built-in event-sourcing handler. |
| main/agentic/src/main/java/org/elasticsoftware/akces/agentic/beans/AgenticAggregateRuntimeFactory.java | Registers finished event type and handler with the runtime builder. |
| main/agentic/src/test/java/org/elasticsoftware/akces/agentic/runtime/TaskEventSourcingTest.java | Adds tests for applying/dispatching AgentTaskFinishedEvent and assign→finish reconstruction. |
| main/agentic/src/test/java/org/elasticsoftware/akces/agentic/runtime/ResumeNextAgentTaskTest.java | Adds tests ensuring resumeNextAgentTask emits (or doesn’t emit) AgentTaskFinishedEvent. |
| main/agentic/src/test/java/org/elasticsoftware/akces/agentic/runtime/AssignTaskTypeConstantsTest.java | Verifies the new AGENT_TASK_FINISHED_TYPE constant configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Agent tasks need lifecycle completion tracking. After each tick in the idle-poll cycle, the runtime now checks
AgentProcess.getFinished()and emits anAgentTaskFinishedEventcarrying theAgentProcessStatusCode(COMPLETED, FAILED, TERMINATED, KILLED, STUCK). A built-in event-sourcing handler clears the task fromTaskAwareState.Changes
AgentTaskFinishedEvent— record withagentProcessId,AgentProcessStatusCode status,finishedAtAgenticAggregateRuntime— addAGENT_TASK_FINISHED_TYPEconstantKafkaAgenticAggregateRuntimeonAgentTaskFinished()handler callsTaskAwareState.withoutAssignedTask()handleBuiltInEvent()dispatch updated for new event typeresumeNextAgentTask()checksagentProcess.getFinished()post-tick, appends finished event to streamAgenticAggregateRuntimeFactory— registersAGENT_TASK_FINISHED_TYPEwith built-in event-sourcing handlerTick + finish detection in
resumeNextAgentTask