Class MultiAgentObserver

java.lang.Object
com.tnsai.coordination.observability.MultiAgentObserver

public class MultiAgentObserver extends Object
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 Classes
    Modifier and Type
    Class
    Description
    static final record 
    Summary statistics for an observation session.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an observer for the specified group.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears all recorded data (event log and interaction graph).
    void
    detach(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>
    Returns events involving a specific agent (as source or target).
    Returns the interaction graph built from observed events.
    Returns summary statistics of the observation.
    void
    observe(com.tnsai.agents.groups.GroupEventBus eventBus)
    Attaches this observer to a group event bus, subscribing to all events.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MultiAgentObserver

      public MultiAgentObserver(String groupId)
      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

      public InteractionGraph getInteractionGraph()
      Returns the interaction graph built from observed events.
      Returns:
      the interaction graph
    • getEventLog

      public List<com.tnsai.agents.groups.GroupEvent> 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

      public List<com.tnsai.agents.groups.GroupEvent> getEventsForAgent(String agentId)
      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