Renderers¶
Format-specific renderer implementations for message analytics display.
Quick Example¶
from mamba_agents.agent.display import RichRenderer, PlainTextRenderer, HtmlRenderer
from mamba_agents.agent.display import DETAILED
renderer = RichRenderer()
output = renderer.render_stats(stats, DETAILED)
# Plain text for logs
plain = PlainTextRenderer()
output = plain.render_stats(stats, DETAILED)
# HTML for Jupyter notebooks
html = HtmlRenderer()
output = html.render_stats(stats, DETAILED)
Renderer Comparison¶
| Renderer | Output | Use Case |
|---|---|---|
RichRenderer |
Rich Console tables and panels | Terminal display |
PlainTextRenderer |
ASCII text with aligned columns | Log files, CI output |
HtmlRenderer |
Semantic HTML tables and sections | Jupyter notebooks |
API Reference¶
MessageRenderer (ABC)¶
MessageRenderer
¶
Bases: ABC
Abstract base class for message display renderers.
Implementations produce formatted string output for three data types:
message statistics, conversation timeline, and tool call summaries.
Each method receives the data and a DisplayPreset that controls
how much detail to include.
Concrete implementations include RichRenderer, PlainTextRenderer,
and HtmlRenderer.
render_stats
abstractmethod
¶
render_stats(
stats: MessageStats, preset: DisplayPreset
) -> str
Render message statistics as a formatted string.
| PARAMETER | DESCRIPTION |
|---|---|
stats
|
Token and message count statistics to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Formatted string representation of the statistics. |
Source code in src/mamba_agents/agent/display/renderer.py
render_timeline
abstractmethod
¶
render_timeline(
turns: list[Turn], preset: DisplayPreset
) -> str
Render a conversation timeline as a formatted string.
| PARAMETER | DESCRIPTION |
|---|---|
turns
|
List of conversation turns to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Formatted string representation of the timeline. |
Source code in src/mamba_agents/agent/display/renderer.py
render_tools
abstractmethod
¶
render_tools(
tools: list[ToolCallInfo], preset: DisplayPreset
) -> str
Render a tool usage summary as a formatted string.
| PARAMETER | DESCRIPTION |
|---|---|
tools
|
List of tool call summaries to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Formatted string representation of the tool summary. |
Source code in src/mamba_agents/agent/display/renderer.py
RichRenderer¶
RichRenderer
¶
Bases: MessageRenderer
Rich Console renderer for message analytics data.
Produces formatted Rich Console output with tables, panels, and styled
text for message statistics, conversation timelines, and tool call
summaries. Output detail is controlled by a DisplayPreset.
Each render method accepts an optional console parameter. When
provided, the method prints to that console and captures the output.
When omitted, a new Console(record=True) is created internally.
Example::
from mamba_agents.agent.display.rich_renderer import RichRenderer
from mamba_agents.agent.display.presets import DETAILED
renderer = RichRenderer()
output = renderer.render_stats(stats, DETAILED)
print(output) # already printed to console; string also returned
render_stats
¶
render_stats(
stats: MessageStats,
preset: DisplayPreset,
*,
console: Console | None = None,
) -> str
Render message statistics as a Rich table.
Produces a table with columns for Role, Messages, and Tokens (when
preset.show_tokens is True). Includes a totals row and an
average tokens-per-message summary line beneath the table.
Token numbers are formatted with thousands separators (e.g.,
1,234).
| PARAMETER | DESCRIPTION |
|---|---|
stats
|
Token and message count statistics to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
console
|
Optional Rich Console instance. When provided, output is printed to this console. When omitted, a new recording console is created.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The rendered string captured from the console. |
Source code in src/mamba_agents/agent/display/rich_renderer.py
render_timeline
¶
render_timeline(
turns: list[Turn],
preset: DisplayPreset,
*,
console: Console | None = None,
) -> str
Render a conversation timeline as Rich panels.
Each turn is rendered as a Rich Panel containing role-labelled
content sections. Tool interactions are shown as a nested summary
(tool name and call count). Content is truncated according to the
preset's max_content_length unless expand is True or
max_content_length is None.
| PARAMETER | DESCRIPTION |
|---|---|
turns
|
List of conversation turns to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
console
|
Optional Rich Console instance.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The rendered string captured from the console. |
Source code in src/mamba_agents/agent/display/rich_renderer.py
render_tools
¶
render_tools(
tools: list[ToolCallInfo],
preset: DisplayPreset,
*,
console: Console | None = None,
) -> str
Render a tool usage summary as a Rich table.
Default (collapsed) view shows tool name and call count only.
When preset.show_tool_details is True, expanded rows show
arguments and results per call.
| PARAMETER | DESCRIPTION |
|---|---|
tools
|
List of tool call summaries to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
console
|
Optional Rich Console instance.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The rendered string captured from the console. |
Source code in src/mamba_agents/agent/display/rich_renderer.py
render_stats_renderables
¶
render_stats_renderables(
stats: MessageStats, preset: DisplayPreset
) -> list[Table | Panel | Text]
Build Rich renderable objects for message statistics.
Used by MessageStats.__rich_console__ to yield Rich objects
directly to the console without creating an intermediate recording
console.
| PARAMETER | DESCRIPTION |
|---|---|
stats
|
Token and message count statistics to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Table | Panel | Text]
|
A list of Rich renderable objects (Table, Panel, or Text). |
Source code in src/mamba_agents/agent/display/rich_renderer.py
render_tools_renderables
¶
render_tools_renderables(
tools: list[ToolCallInfo], preset: DisplayPreset
) -> list[Table | Panel]
Build Rich renderable objects for a tool usage summary.
Used by ToolCallInfo.__rich_console__ to yield Rich objects
directly to the console.
| PARAMETER | DESCRIPTION |
|---|---|
tools
|
List of tool call summaries to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Table | Panel]
|
A list of Rich renderable objects (Table or Panel). |
Source code in src/mamba_agents/agent/display/rich_renderer.py
render_turn_renderable
¶
render_turn_renderable(
turn: Turn, preset: DisplayPreset
) -> Panel
Build a Rich Panel for a single conversation turn.
Used by Turn.__rich_console__ to yield a Panel directly to
the console.
| PARAMETER | DESCRIPTION |
|---|---|
turn
|
A
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Panel
|
A Rich Panel containing the formatted turn display. |
Source code in src/mamba_agents/agent/display/rich_renderer.py
PlainTextRenderer¶
PlainTextRenderer
¶
Bases: MessageRenderer
Plain text renderer for message analytics data.
Produces formatted ASCII text output with aligned columns for message
statistics, conversation timelines, and tool call summaries. Output
detail is controlled by a DisplayPreset.
Each render method prints to stdout and returns the output as a string.
An optional file parameter can redirect output to a different stream.
Example::
from mamba_agents.agent.display.plain_renderer import PlainTextRenderer
from mamba_agents.agent.display.presets import DETAILED
renderer = PlainTextRenderer()
output = renderer.render_stats(stats, DETAILED)
# Output has already been printed to stdout; string also returned.
render_stats
¶
render_stats(
stats: MessageStats,
preset: DisplayPreset,
*,
file: Any | None = None,
) -> str
Render message statistics as an ASCII table.
Produces a table with columns for Role, Messages, and Tokens (when
preset.show_tokens is True). Includes a totals row and an
average tokens-per-message summary line beneath the table.
Token numbers are formatted with thousands separators (e.g.,
1,234).
| PARAMETER | DESCRIPTION |
|---|---|
stats
|
Token and message count statistics to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
file
|
Optional output stream. Defaults to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The rendered string. |
Source code in src/mamba_agents/agent/display/plain_renderer.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
render_timeline
¶
render_timeline(
turns: list[Turn],
preset: DisplayPreset,
*,
file: Any | None = None,
) -> str
Render a conversation timeline as formatted text.
Each turn is rendered with role-labelled content sections and
separators. Tool interactions are shown as a summary (tool name
and call count). Content is truncated according to the preset's
max_content_length unless expand is True or
max_content_length is None.
| PARAMETER | DESCRIPTION |
|---|---|
turns
|
List of conversation turns to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
file
|
Optional output stream. Defaults to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The rendered string. |
Source code in src/mamba_agents/agent/display/plain_renderer.py
render_tools
¶
render_tools(
tools: list[ToolCallInfo],
preset: DisplayPreset,
*,
file: Any | None = None,
) -> str
Render a tool usage summary as an ASCII table.
Default (collapsed) view shows tool name and call count only.
When preset.show_tool_details is True, expanded rows show
arguments and results per call.
| PARAMETER | DESCRIPTION |
|---|---|
tools
|
List of tool call summaries to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
file
|
Optional output stream. Defaults to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The rendered string. |
Source code in src/mamba_agents/agent/display/plain_renderer.py
HtmlRenderer¶
HtmlRenderer
¶
Bases: MessageRenderer
HTML renderer for message analytics data.
Produces self-contained HTML string output with semantic markup
(<table>, <th>, <td>, <caption>) for message statistics,
conversation timelines, and tool call summaries. Output detail is
controlled by a DisplayPreset.
The generated HTML uses no external CSS or JavaScript dependencies and
is designed to render cleanly in Jupyter notebooks via
IPython.display.HTML.
Example::
from mamba_agents.agent.display.html_renderer import HtmlRenderer
from mamba_agents.agent.display.presets import DETAILED
renderer = HtmlRenderer()
html_str = renderer.render_stats(stats, DETAILED)
# In Jupyter: IPython.display.HTML(html_str)
render_stats
¶
render_stats(
stats: MessageStats, preset: DisplayPreset
) -> str
Render message statistics as an HTML table.
Produces a <table> with columns for Role, Messages, and Tokens
(when preset.show_tokens is True). Includes a totals row and
an average tokens-per-message summary paragraph beneath the table.
Token numbers are formatted with thousands separators (e.g.,
1,234).
| PARAMETER | DESCRIPTION |
|---|---|
stats
|
Token and message count statistics to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A self-contained HTML string. |
Source code in src/mamba_agents/agent/display/html_renderer.py
render_timeline
¶
render_timeline(
turns: list[Turn], preset: DisplayPreset
) -> str
Render a conversation timeline as HTML sections.
Each turn is rendered as a <section> containing role-labelled
content. Tool interactions are shown as nested summaries.
Content is truncated according to the preset's
max_content_length unless expand is True or
max_content_length is None.
| PARAMETER | DESCRIPTION |
|---|---|
turns
|
List of conversation turns to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A self-contained HTML string. |
Source code in src/mamba_agents/agent/display/html_renderer.py
render_tools
¶
render_tools(
tools: list[ToolCallInfo], preset: DisplayPreset
) -> str
Render a tool usage summary as an HTML table.
Default (collapsed) view shows tool name and call count only.
When preset.show_tool_details is True, a third Details column
shows arguments and results per call.
| PARAMETER | DESCRIPTION |
|---|---|
tools
|
List of tool call summaries to render.
TYPE:
|
preset
|
Display configuration controlling detail level.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
A self-contained HTML string. |