Message and part types exchanged between the agent and a model.
It leans into Elixir's native discriminated unions: every part/message is a
struct, and the __struct__ field is the discriminator you pattern-match on
(case part do %Part.ToolCall{} -> ...).
Two top-level messages:
Request— sent to the model (system/user prompts, tool returns, retry prompts).Response— returned by the model (text, tool calls, thinking).
All structs @derive Jason.Encoder so a whole history can be serialised to
JSON for persistence or for talking to providers.
Summary
Functions
Parse a JSON binary back into a message history.
Build a request from a list of parts.
Build a response from a list of parts.
Flatten a message history into its constituent parts (mostly for tests).
Serialize a message history to a JSON binary for persistence.
Types
@type t() :: ExAgent.Message.Request.t() | ExAgent.Message.Response.t()
Functions
Parse a JSON binary back into a message history.
@spec new_request( [ExAgent.Message.Request.part()], keyword() ) :: ExAgent.Message.Request.t()
Build a request from a list of parts.
@spec new_response( [ExAgent.Message.Response.part()], keyword() ) :: ExAgent.Message.Response.t()
Build a response from a list of parts.
Flatten a message history into its constituent parts (mostly for tests).
Serialize a message history to a JSON binary for persistence.