EarlyTermination event published before status is set to TERMINATED (inconsistent with other terminal events)
Problem
In AbstractAgentProcess.identifyEarlyTermination(), the termination event is dispatched to listeners before the process status is updated:
// AbstractAgentProcess.kt:407-409 and 433-435
platformServices.eventListener.onProcessEvent(signalTermination)
_failureInfo = signalTermination
setStatus(AgentProcessStatusCode.TERMINATED)
Any listener that reads event.getAgentProcess().getStatus() in response therefore observes the previous status (RUNNING) instead of TERMINATED.
This is inconsistent with every other terminal/lifecycle transition (COMPLETED, FAILED, WAITING, PAUSED, STUCK, KILLED), where the status is set before the corresponding event is published. Listeners reacting to a termination event see a stale, contradictory state.
Expected
When a termination event is delivered, agentProcess.getStatus() already reflects TERMINATED, matching the behaviour of all other lifecycle events.
Fix
Set the status before publishing the event at both sites in identifyEarlyTermination():
_failureInfo = signalTermination
setStatus(AgentProcessStatusCode.TERMINATED)
platformServices.eventListener.onProcessEvent(signalTermination)
@azanux - good catch. Would you be able to make it for 0.5.0?
@igordayen I will add the fix in the observability migration if is ok
. still doing some tests on the migration observability almost finish
fix in #1718