SagentsLiveDebugger.Live.Components.MessageComponents (Sagents LiveDebugger v0.4.0-rc.2)

Copy Markdown

Shared components for rendering messages and tools.

These components are used by both the main AgentListLive and SubagentsTab to provide consistent message and tool rendering with expandable/collapsible UI.

Summary

Functions

Renders a single content part (text, thinking, image, etc.).

Build the display payload for a middleware's config section.

Inspect values for debug display.

Renders a single message item with role emoji, content, tool calls/results, and metadata.

Renders the middleware config display, dispatching on the shape of the payload returned by display_config/1.

Renders a single config entry within middleware.

Renders a single middleware item with expandable configuration. Expects a MiddlewareEntry struct with id and config fields.

Renders a model configuration within middleware.

Renders a middleware section with a list of middleware entries. Expects an agent struct with a middleware field containing MiddlewareEntry structs.

Renders message content, handling both binary and multimodal content.

Renders a tool call item.

Renders a tool item with expandable description and parameters. Expects a tool struct or map with name, description, parameters, and async fields.

Renders a tool result item.

Functions

content_part(assigns)

Renders a single content part (text, thinking, image, etc.).

Attributes

  • part (:map) (required)
  • prefix (:string) - Defaults to "".

display_config(arg)

Build the display payload for a middleware's config section.

Returns:

  • {:map, map} — render as a key/value config table
  • {:string, text} — render as a single highlighted code block

Prefers the middleware module's own Sagents.Middleware.debug_summary/1 callback when exported. The callback owns the decision of what's useful to surface; falling back to the raw config is the safe default for middleware that hasn't opted in.

format_config_key(key)

format_config_value(value)

format_module_name(module)

format_tool_arguments(arguments)

format_tool_result(content)

get_model_name(model)

inspect_for_display(value)

Inspect values for debug display.

Uses bounded :limit and :printable_limit so that an unexpectedly large middleware config (or any other value) cannot dominate render time and DOM size. Middleware modules that hold large structures should implement Sagents.Middleware.debug_summary/1 to provide a curated view; this function is the safety net for everything else.

message_item(assigns)

Renders a single message item with role emoji, content, tool calls/results, and metadata.

Attributes

  • message (:map) (required)
  • index (:integer) - Defaults to nil.

message_role_emoji(_)

middleware_config_display(assigns)

Renders the middleware config display, dispatching on the shape of the payload returned by display_config/1.

Multi-clause function components let us pick the template at compile time via pattern matching, instead of a runtime case inside HEEx.

Attributes

  • display (:any) (required)

middleware_config_entry(assigns)

Renders a single config entry within middleware.

Attributes

  • key (:any) (required)
  • value (:any) (required)

middleware_item(assigns)

Renders a single middleware item with expandable configuration. Expects a MiddlewareEntry struct with id and config fields.

The prefix attribute is used to create unique DOM IDs when the same middleware is displayed in multiple contexts (e.g., main agent vs sub-agent views).

Attributes

  • entry (:map) (required)
  • prefix (:string) - Defaults to "".

middleware_model_config(assigns)

Renders a model configuration within middleware.

Attributes

  • model (:map) (required)
  • entry_id (:any) (required)
  • prefix (:string) - Defaults to "".

middleware_section(assigns)

Renders a middleware section with a list of middleware entries. Expects an agent struct with a middleware field containing MiddlewareEntry structs.

The prefix attribute is used to create unique DOM IDs when middleware is displayed in multiple contexts (e.g., main agent vs sub-agent views).

Attributes

  • agent (:map) (required)
  • prefix (:string) - Defaults to "".

render_message_content(message)

Renders message content, handling both binary and multimodal content.

tool_call_item(assigns)

Renders a tool call item.

Attributes

  • tool_call (:map) (required)

tool_item(assigns)

Renders a tool item with expandable description and parameters. Expects a tool struct or map with name, description, parameters, and async fields.

The prefix attribute is used to create unique DOM IDs when the same tool is displayed in multiple contexts (e.g., main agent vs sub-agent views).

Attributes

  • tool (:map) (required)
  • prefix (:string) - Defaults to "".

tool_result_item(assigns)

Renders a tool result item.

Attributes

  • tool_result (:map) (required)