Interface AutonomousAgentClient
AutonomousAgent.
Not for user extension or instantiation, returned by the SDK component client.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidassignTasks(String... taskIds) Assign one or more previously created tasks to this agent.CompletionStage<akka.Done> assignTasksAsync(String... taskIds) Async variant ofassignTasks(java.lang.String...).default AgentStategetState()Get the current state of this agent instance.Async variant ofgetState().akka.stream.javadsl.Source<Notification, akka.NotUsed> Subscribe to lifecycle notifications for this agent instance.default voidresume()Resume a previously suspended agent.CompletionStage<akka.Done> Async variant ofresume().default StringrunSingleTask(Task<?> task) Create a task, assign it to a fresh agent instance, and automatically stop the agent when done.runSingleTaskAsync(Task<?> task) Async variant ofrunSingleTask(akka.javasdk.agent.task.Task<?>).default MessageAcknowledgementsendMessage(AgentMessage message) Send a message to this agent instance while it works on its tasks.sendMessageAsync(AgentMessage message) Async variant ofsendMessage(akka.javasdk.agent.autonomous.AgentMessage).default voidsetup(AgentSetup setup) Apply per-instance configuration to this agent.CompletionStage<akka.Done> setupAsync(AgentSetup setup) Async variant ofsetup(akka.javasdk.agent.autonomous.AgentSetup).default voidsuspend()Suspend the agent.default voidSuspend the agent with a reason.default CompletionStage<akka.Done> Async variant ofsuspend().CompletionStage<akka.Done> suspendAsync(String reason) Async variant ofsuspend(String).default voidTerminate the agent.default voidTerminate the agent with a reason.default CompletionStage<akka.Done> Async variant ofterminate().CompletionStage<akka.Done> terminateAsync(String reason) Async variant ofterminate(String).
-
Method Details
-
runSingleTask
Create a task, assign it to a fresh agent instance, and automatically stop the agent when done. Each call starts an independent agent instance. Returns the task ID for later status checks viaTaskClient.- Parameters:
task- the task to execute- Returns:
- the task ID
-
runSingleTaskAsync
Async variant ofrunSingleTask(akka.javasdk.agent.task.Task<?>).- Parameters:
task- the task to execute- Returns:
- a CompletionStage with the task ID
-
assignTasks
Assign one or more previously created tasks to this agent. Tasks are queued if the agent is busy.- Parameters:
taskIds- IDs of previously created tasks
-
assignTasksAsync
Async variant ofassignTasks(java.lang.String...).- Parameters:
taskIds- IDs of previously created tasks
-
setup
Apply per-instance configuration to this agent. The instructions override the static instructions from the agent's definition, and capabilities extend the static capabilities.Call this once per instance, before any operation that triggers iteration, such as
runSingleTask(akka.javasdk.agent.task.Task<?>)orassignTasks(java.lang.String...). A repeated call with the same instructions and the same capabilities in the same order succeeds. A retry is therefore safe. A call with a different setup throws an exception, and the agent keeps the setup it has.The comparison also covers values that the capabilities take from the deployed components and from configuration: the descriptions, accepted tasks and request schemas of other agents, the result schemas of tasks, and default limits. A retry after a deployment that changed one of these values fails.
- Parameters:
setup- the per-instance configuration
-
setupAsync
Async variant ofsetup(akka.javasdk.agent.autonomous.AgentSetup). The returned stage fails when the agent already has a different setup.- Parameters:
setup- the per-instance configuration
-
getState
Get the current state of this agent instance.- Returns:
- a summary of the agent's current state
-
getStateAsync
CompletionStage<AgentState> getStateAsync()Async variant ofgetState(). -
sendMessage
Send a message to this agent instance while it works on its tasks. The message is for the task set withAgentMessage.taskId(String), or else for the current task, or for the next task that starts when no task runs. The model sees it in its next request for that task, at the start of an iteration or after the tool calls of a round. While a tool call runs, for example a delegation that waits for its workers, the message waits for it.The acknowledgement says where the message went, or why the agent rejected it. The agent does not store a rejected message. The agent drops a message whose task ends before the agent consumes it, see
MessageStatus.Consumed.getState()and theNotification.MessagesConsumedandNotification.MessagesDroppednotifications report what happened to it.Set
AgentMessage.messageId(String)to make a retry safe. 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.Fails when the agent instance does not exist or is stopped. An instance exists after its first setup or task.
- Parameters:
message- the message- Returns:
- where the message went
-
sendMessageAsync
Async variant ofsendMessage(akka.javasdk.agent.autonomous.AgentMessage).- Parameters:
message- the message- Returns:
- a CompletionStage with where the message went
-
suspend
default void suspend()Suspend the agent. A suspended agent stops iterating until resumed. -
suspend
Suspend the agent with a reason. A suspended agent stops iterating until resumed.- Parameters:
reason- a description of why the agent is being suspended
-
suspendAsync
Async variant ofsuspend(). -
suspendAsync
Async variant ofsuspend(String). -
resume
default void resume()Resume a previously suspended agent. -
resumeAsync
CompletionStage<akka.Done> resumeAsync()Async variant ofresume(). -
terminate
default void terminate()Terminate the agent. -
terminate
Terminate the agent with a reason.- Parameters:
reason- a description of why the agent is being terminated
-
terminateAsync
Async variant ofterminate(). -
terminateAsync
Async variant ofterminate(String). -
notificationStream
akka.stream.javadsl.Source<Notification,akka.NotUsed> notificationStream()Subscribe to lifecycle notifications for this agent instance. Notifications are published by the runtime as the agent progresses through its execution loop.The returned source emits events such as
Notification.Activated,Notification.IterationStarted,Notification.IterationCompleted, andNotification.Stopped.- Returns:
- a source of notification events
-