AgentLogger
A pluggable base class that powers listeners by defining the logging behaviour itself.
Subclass this and implement the abstract methods to create a custom logger.
Can be used as a context manager to set a contextual logger for the current scope.
Parameters
The local identifier for this logger instance.
The local identifier of the parent logger, if any.
on_spawn
Called when an agent is spawned.
Implementations should initialise any logging state needed for a new agent.
on_call_enter
Called when an agent receives a prompt.
Parameters
The task or prompt provided to the agent for this invocation.
The local identifier of the parent invocation, if this is a nested call.
on_call_exit
Called when an agent returns a result.
Parameters
The result returned by the agent invocation.
on_chunk
Called when a streaming chunk is received.
Parameters
A single piece of streamed content from an agent invocation.
Chunk
A single piece of streamed content from an agent invocation.
Parameters
The role of the message sender (‘agent’, ‘user’, or ‘system’).
The text content of the chunk.
The kind of streamed content:
- ‘reasoning’ — internal reasoning / chain-of-thought
- ‘output_text’ — final output text
- ‘code’ — code being executed in the REPL
- ‘usage’ — token usage statistics
- ‘invocation_exit’ — signals the end of an invocation
- None — untyped chunk