Manages the recording of event invocations and provides simple event routing functionality. There is one EventService instance in every agent-environment loop, provided by the AgentEnvironmentContext.

Within the environment the richer routing functionality provided by PubSub should be utilized, rather than directly interacting with this class.

class TopicInfo(interface_class: Type[T], scope:, proxy: T)

internal class to keep track of the topic state, including the collected events


Notify this service about the start of a new step. This should only be called by the AgentEnvironmentContext.

Clears all collected events and notifies all registered scopes.


Clears the events collected by pubsub

create_event_topic(interface_class: Type[T], scope: = None) → T

Create a proxy instance of the event interface, which can be used conveniently to publish events. Returns an existing proxy, if it has been created before.

  • interface_class – The class object of an abstract interface that defines the events as methods.

  • scope – Every event topic can be bound to a single scope, e.g. a certain PubSub instance, to ensure that all events of the topic interface_class will be received by this PubSub instance.


A proxy object, dynamically derived from the passed interface_class, that can be used to trigger events.

iterate_event_records() → Generator[, None, None]

A generator to iterate all collected events


Notify the event service about a new event. This is invoked by the event topic proxies.

:param event The event to be added.