Interface AutonomousAgentClient


@DoNotInherit public interface AutonomousAgentClient
Client for interacting with an AutonomousAgent.

Not for user extension or instantiation, returned by the SDK component client.

  • Method Details

    • runSingleTask

      default String runSingleTask(Task<?> task)
      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 via TaskClient.
      Parameters:
      task - the task to execute
      Returns:
      the task ID
    • runSingleTaskAsync

      CompletionStage<String> runSingleTaskAsync(Task<?> task)
      Parameters:
      task - the task to execute
      Returns:
      a CompletionStage with the task ID
    • assignTasks

      default void assignTasks(String... taskIds)
      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

      CompletionStage<akka.Done> assignTasksAsync(String... taskIds)
      Parameters:
      taskIds - IDs of previously created tasks
    • setup

      default void setup(AgentSetup 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<?>) or assignTasks(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

      CompletionStage<akka.Done> setupAsync(AgentSetup setup)
      Async variant of setup(akka.javasdk.agent.autonomous.AgentSetup). The returned stage fails when the agent already has a different setup.
      Parameters:
      setup - the per-instance configuration
    • getState

      default AgentState getState()
      Get the current state of this agent instance.
      Returns:
      a summary of the agent's current state
    • getStateAsync

      CompletionStage<AgentState> getStateAsync()
      Async variant of getState().
    • suspend

      default void suspend()
      Suspend the agent. A suspended agent stops iterating until resumed.
    • suspend

      default void suspend(String reason)
      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

      default CompletionStage<akka.Done> suspendAsync()
      Async variant of suspend().
    • suspendAsync

      CompletionStage<akka.Done> suspendAsync(String reason)
      Async variant of suspend(String).
    • resume

      default void resume()
      Resume a previously suspended agent.
    • resumeAsync

      CompletionStage<akka.Done> resumeAsync()
      Async variant of resume().
    • terminate

      default void terminate()
      Terminate the agent.
    • terminate

      default void terminate(String reason)
      Terminate the agent with a reason.
      Parameters:
      reason - a description of why the agent is being terminated
    • terminateAsync

      default CompletionStage<akka.Done> terminateAsync()
      Async variant of terminate().
    • terminateAsync

      CompletionStage<akka.Done> terminateAsync(String reason)
      Async variant of terminate(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, and Notification.Stopped.

      Returns:
      a source of notification events