Normandy.Coordination.AgentMessage
(normandy v2.2.0)
View Source
Message structure for agent-to-agent communication.
AgentMessage provides a standardized format for agents to communicate with each other, including metadata about the sender, message type, and payload.
Example
message = %AgentMessage{
from: "research_agent",
to: "writing_agent",
type: :request,
payload: %{query: "Find papers about AI"},
metadata: %{priority: :high}
}
Summary
Functions
Creates an error response message.
Creates a new agent message.
Creates a response message to an original message.
Types
Functions
@spec error( %Normandy.Coordination.AgentMessage{ from: term(), id: term(), metadata: term(), payload: term(), timestamp: term(), to: term(), type: term() }, String.t(), map() ) :: %Normandy.Coordination.AgentMessage{ from: term(), id: term(), metadata: term(), payload: term(), timestamp: term(), to: term(), type: term() }
Creates an error response message.
Example
error = AgentMessage.error(original_message, "Processing failed", %{code: 500})
@spec new(keyword()) :: %Normandy.Coordination.AgentMessage{ from: term(), id: term(), metadata: term(), payload: term(), timestamp: term(), to: term(), type: term() }
Creates a new agent message.
Options
:from- Required. The sender's id.:to- Required. The recipient's id.:type-:request,:response,:broadcastor:error(stored as a string). The default value is:request.:payload(term/0) - The message content. The default value is%{}.:metadata- Extra data about the message. The default value is%{}.
Example
message = AgentMessage.new(
from: "agent_1",
to: "agent_2",
type: :request,
payload: %{task: "analyze data"}
)
@spec reply( %Normandy.Coordination.AgentMessage{ from: term(), id: term(), metadata: term(), payload: term(), timestamp: term(), to: term(), type: term() }, map() ) :: %Normandy.Coordination.AgentMessage{ from: term(), id: term(), metadata: term(), payload: term(), timestamp: term(), to: term(), type: term() }
Creates a response message to an original message.
Example
response = AgentMessage.reply(original_message, %{result: "success"})