AsyncAggregatorAgent

abstract class AsyncAggregatorAgent(eventTypesNeeded: List<KClass<out Event>>) : Agent

Buffers events by Event.correlationId until every event-type in eventTypesNeeded has been observed, then hands the collected list to processEvents.

Useful when an agent must wait for fan-out work to complete before acting (for example, gathering responses from multiple parallel sub-agents that share a correlation id).

Mirrors the Python reference's AsyncAggregatorAgent.

Constructors

Link copied to clipboard
constructor(eventTypesNeeded: List<KClass<out Event>>)

Functions

Link copied to clipboard
open suspend fun processEvents(events: List<Event>): List<Event>

Override to act on the assembled event list. Default returns no follow-up events.

Link copied to clipboard
open suspend override fun receiveEvent(event: Event): List<Event>
Link copied to clipboard
suspend fun waitForEvents(correlationId: String, timeoutMs: Long? = null): List<Event>

Suspend until every needed event-type arrives for correlationId, or until timeoutMs elapses. Returns the captured events on success, or whatever has been captured so far on timeout.