Module: Pikuri::Agent::Message
- Defined in:
- lib/pikuri/agent/message.rb
Overview
Sealed value-object hierarchy describing a single event in the Agent‘s normalized stream. Listeners (Terminal renderer, in-memory recorder, future web sink) receive these through one Listener::MessageListener#on_message entry point and dispatch on the variant’s class.
Each variant is a Data.define with the minimal fields it needs; value equality and pattern-matching support come for free.
Where each variant comes from
-
User — synthesized by #run_loop before forwarding the turn to Chat#ask. Never appears in ruby_llm’s listener stream.
-
Thinking / Assistant — extracted from a Chat#after_message payload when the role is
:assistant. Emptythinking.textand emptycontentare filtered out at the dispatch site so listeners never see vacuous events. -
ToolCall — emitted on Chat#before_tool_call, carrying the tool’s name and the LLM-supplied argument hash.
-
ToolResult — emitted on Chat#after_tool_result, carrying the observation string the tool produced.
Provider-reported token usage is not a Message variant — it’s metadata about an exchange, not an event in it. See Tokens and Listener::MessageListener#on_tokens.
Defined Under Namespace
Classes: Assistant, FallbackNotice, Thinking, ToolCall, ToolResult, User