An agent-side message with metadata.
Wraps Planck.AI.Message content parts with an id, timestamp, and metadata map.
Messages with a {:custom, atom()} role are UI-only and filtered out before the
context is sent to the LLM.
Summary
Functions
Estimate the token count for a list of messages using a character-based approximation (4 characters ≈ 1 token). Fast enough for real-time display and compaction threshold checks; not a substitute for model tokenization.
Build a new message with a generated id and current UTC timestamp.
Convert a list of agent messages to Planck.AI.Message structs.
Types
@type role() :: :user | :assistant | :tool_result | {:custom, atom()}
@type t() :: %Planck.Agent.Message{ content: [Planck.AI.Message.content_part()], id: non_neg_integer() | String.t(), metadata: map(), role: role(), timestamp: DateTime.t() }
Functions
@spec estimate_tokens([t()]) :: non_neg_integer()
Estimate the token count for a list of messages using a character-based approximation (4 characters ≈ 1 token). Fast enough for real-time display and compaction threshold checks; not a substitute for model tokenization.
@spec new(role(), [Planck.AI.Message.content_part()], map()) :: t()
Build a new message with a generated id and current UTC timestamp.
@spec to_ai_messages([t()]) :: [Planck.AI.Message.t()]
Convert a list of agent messages to Planck.AI.Message structs.
{:custom, :summary} messages are converted to :user so the LLM sees
compacted context. All other {:custom, _} messages are dropped.