Package akka.javasdk.agent.autonomous
Class AgentMessage
Object
akka.javasdk.agent.autonomous.AgentMessage
A message from a client to a running autonomous agent: text with optional attachments, for one
task of the agent. Send it with
AutonomousAgentClient.sendMessage(AgentMessage).
Each method that sets a value returns a new instance and leaves this one unchanged.
-
Method Summary
Modifier and TypeMethodDescriptionattach(MessageContent... content) Return a new message with the given content attached.Content attached to this message (images, PDFs), or an empty list.The id of this message, if set.Return a new message with the given id.static AgentMessageCreate a message with the given text.taskId()The id of the task this message is for, if set.Return a new message for the task with the given id.text()The text of this message.
-
Method Details
-
of
Create a message with the given text.- Parameters:
text- the text for the model- Throws:
IllegalArgumentException- if the text is null
-
text
The text of this message. -
attachments
Content attached to this message (images, PDFs), or an empty list. -
attach
Return a new message with the given content attached. Reference images and PDFs by URI, withMessageContent.ImageUrlMessageContentorMessageContent.PdfUrlMessageContent.- Throws:
IllegalArgumentException- if a content item carries inline bytes
-
messageId
The id of this message, if set. -
messageId
Return a new message with the given id. While the first message is pending or amongAgentState.recentMessages(), a retry with the same id gets the status of the first message, and the agent stores nothing new. The agent does not store a rejected message, so a retry of it is a new message. Without an id, the runtime generates one, and a retry is a new message.- Throws:
IllegalArgumentException- if the id is null or empty
-
taskId
The id of the task this message is for, if set. -
taskId
Return a new message for the task with the given id. The agent accepts the message for its current task, a queued task, or a task that waits for its dependencies, and rejects it for any other task. Without a task id, the message is for the current task, or for the next task that starts when no task runs.- Throws:
IllegalArgumentException- if the id is null or empty
-