Skip to main content
The @agenite/pretty-logger package provides a beautiful, structured console logging middleware for Agenite agents. It enhances the development experience by making agent interactions, tool usage, and execution flow easy to follow in the terminal.

What is Pretty Logger?

Pretty Logger is a middleware that intercepts the agent execution flow and produces formatted, colorful terminal output. It helps developers:
  • Track agent interactions and tool usage
  • Follow the streaming output from LLMs
  • Visualize nested agent hierarchies
  • Monitor token usage for LLM calls
Key features include:
  • Color-coded output for different message types
  • Boxed formatting for structured content
  • Clear separation between different agents in a workflow
  • Nested agent prefix display
  • Support for streaming LLM output
  • Token usage summary at the end of execution

Installation

Basic usage

To use the Pretty Logger with Agenite agents:

Output format

Pretty Logger produces console output with the following formatting:

User input

Agent thinking

Agent response

Tool usage

Token usage summary

Nested agent display

For workflows with multiple nested agents, Pretty Logger shows the hierarchy in the output:
The prefix indicates the agent hierarchy, with supervisor> researcher> showing that the researcher agent is nested under a supervisor agent.

API reference

prettyLogger

The main function that creates the logging middleware.

Usage

How it works

The Pretty Logger middleware:
  1. Intercepts execution events from the agent’s generator
  2. Formats and displays different message types with appropriate styling
  3. Tracks agent context to display nested agent relationships
  4. Manages streaming output for thinking and response text
  5. Creates structured boxes for input and output data
  6. Summarizes token usage at the end of execution

Integration with other middleware

Pretty Logger works well with other middleware. Place it early in the middleware chain for best results:

Example: multi-agent workflow

This example shows how Pretty Logger displays a workflow with multiple agents:
In this example, the Pretty Logger will show the hierarchy of agents with appropriate prefixes and format all interactions, including those between the supervisor and researcher agents.

Conclusion

The @agenite/pretty-logger package significantly improves the development experience when working with Agenite agents. By providing clear, structured, and colorful console output, it makes it easier to understand agent behavior, debug issues, and demonstrate agent capabilities. To see the Pretty Logger in action, check out the examples in the GitHub repository.