Skip to main content

AgentLogger

A pluggable base class that powers listeners by defining the logging behaviour itself.
class AgentLogger(ABC):

    local_id: int | None
    parent_local_id: int | None

    @abstractmethod
    def on_spawn(self) -> None: ...

    @abstractmethod
    def on_call_enter(self, user_prompt: str, parent_local_id: int | None = None) -> None: ...

    @abstractmethod
    def on_call_exit(self, result: object) -> None: ...

    @abstractmethod
    async def on_chunk(self, chunk: Chunk) -> None: ...
Abstract methods that must be implemented:
  • on_spawn - Called when an agent is spawned
  • on_call_enter - Called when an agent receives a prompt
  • on_call_exit - Called when an agent returns a result
  • on_chunk - Called when a streaming chunk is received