Class MultiAgentObserver
java.lang.Object
com.tnsai.coordination.observability.MultiAgentObserver
Observes an AgentGroup's event bus and records all inter-agent interactions.
The observer subscribes to all events published on a GroupEventBus
and builds an InteractionGraph that represents the communication
topology between agents. It also maintains a full event log for later analysis.
Usage Example
MultiAgentObserver observer = new MultiAgentObserver("group-1");
observer.observe(group.getEventBus());
// ... agents interact ...
InteractionGraph graph = observer.getInteractionGraph();
ObservationSummary summary = observer.getSummary();
observer.detach(group.getEventBus());
Thread-safe: uses CopyOnWriteArrayList for the event log.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordSummary statistics for an observation session. -
Constructor Summary
ConstructorsConstructorDescriptionMultiAgentObserver(String groupId) Creates an observer for the specified group. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all recorded data (event log and interaction graph).voiddetach(com.tnsai.agents.groups.GroupEventBus eventBus) Detaches this observer from the event bus.List<com.tnsai.agents.groups.GroupEvent> Returns all observed events in order.List<com.tnsai.agents.groups.GroupEvent> getEvents(com.tnsai.agents.groups.GroupEvent.Type type) Returns events of a specific type.List<com.tnsai.agents.groups.GroupEvent> getEventsForAgent(String agentId) Returns events involving a specific agent (as source or target).Returns the interaction graph built from observed events.Returns summary statistics of the observation.voidobserve(com.tnsai.agents.groups.GroupEventBus eventBus) Attaches this observer to a group event bus, subscribing to all events.
-
Constructor Details
-
MultiAgentObserver
Creates an observer for the specified group.- Parameters:
groupId- group identifier to observe
-
-
Method Details
-
observe
public void observe(com.tnsai.agents.groups.GroupEventBus eventBus) Attaches this observer to a group event bus, subscribing to all events.If already attached, detaches from the previous bus first.
- Parameters:
eventBus- event bus to observe
-
detach
public void detach(com.tnsai.agents.groups.GroupEventBus eventBus) Detaches this observer from the event bus.- Parameters:
eventBus- event bus to detach from
-
getInteractionGraph
Returns the interaction graph built from observed events.- Returns:
- the interaction graph
-
getEventLog
Returns all observed events in order.- Returns:
- unmodifiable list of events
-
getEvents
public List<com.tnsai.agents.groups.GroupEvent> getEvents(com.tnsai.agents.groups.GroupEvent.Type type) Returns events of a specific type.- Parameters:
type- event type to filter by- Returns:
- list of matching events
-
getEventsForAgent
Returns events involving a specific agent (as source or target).- Parameters:
agentId- agent identifier- Returns:
- list of events involving the agent
-
clear
public void clear()Clears all recorded data (event log and interaction graph). -
getSummary
Returns summary statistics of the observation.- Returns:
- observation summary
-