Record Class GroupTask

java.lang.Object
java.lang.Record
com.tnsai.agents.groups.GroupTask
Record Components:
id - unique task ID
name - task name
description - task description
priority - task priority
timeout - maximum execution time
requiredCapabilities - capabilities needed to execute
parameters - task input parameters
status - current execution status
assigneeId - assigned agent ID (null if unassigned)
createdAt - creation timestamp
startedAt - execution start time
completedAt - completion time
result - task result (if completed)

public record GroupTask(String id, String name, String description, GroupTask.Priority priority, Duration timeout, List<String> requiredCapabilities, Map<String,Object> parameters, GroupTask.Status status, String assigneeId, Instant createdAt, Instant startedAt, Instant completedAt, Object result) extends Record
A task to be executed by group members.

GroupTask represents work that can be assigned to agents within a group. Tasks have priorities, timeouts, required capabilities, and can track execution status.

Usage Example


 GroupTask task = GroupTask.builder()
     .name("Analyze Document")
     .description("Extract key insights from the report")
     .priority(Priority.HIGH)
     .timeout(Duration.ofMinutes(5))
     .requiredCapabilities(List.of("nlp", "summarization"))
     .build();

 Optional<Agent> assignee = group.assignTask(task);
 
  • Constructor Details

  • Method Details

    • isTerminal

      public boolean isTerminal()
      Checks if task is in a terminal state.
      Returns:
      true if terminal
    • isAssigned

      public boolean isAssigned()
      Checks if task is assigned.
      Returns:
      true if assigned
    • hasRequirements

      public boolean hasRequirements()
      Checks if task requires specific capabilities.
      Returns:
      true if capabilities required
    • withStatus

      public GroupTask withStatus(GroupTask.Status newStatus)
      Creates a copy with new status.
      Parameters:
      newStatus - new status
      Returns:
      updated task
    • withAssignee

      public GroupTask withAssignee(String agentId)
      Creates a copy with assignee.
      Parameters:
      agentId - assigned agent ID
      Returns:
      updated task
    • withResult

      public GroupTask withResult(Object taskResult)
      Creates a copy with result.
      Parameters:
      taskResult - task result
      Returns:
      updated task
    • builder

      public static GroupTask.Builder builder()
      Creates a new builder.
      Returns:
      builder
    • of

      public static GroupTask of(String name)
      Creates a simple task with just a name.
      Parameters:
      name - task name
      Returns:
      task
    • of

      public static GroupTask of(String name, String description)
      Creates a task with name and description.
      Parameters:
      name - task name
      description - task description
      Returns:
      task
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • priority

      public GroupTask.Priority priority()
      Returns the value of the priority record component.
      Returns:
      the value of the priority record component
    • timeout

      public Duration timeout()
      Returns the value of the timeout record component.
      Returns:
      the value of the timeout record component
    • requiredCapabilities

      public List<String> requiredCapabilities()
      Returns the value of the requiredCapabilities record component.
      Returns:
      the value of the requiredCapabilities record component
    • parameters

      public Map<String,Object> parameters()
      Returns the value of the parameters record component.
      Returns:
      the value of the parameters record component
    • status

      public GroupTask.Status status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • assigneeId

      public String assigneeId()
      Returns the value of the assigneeId record component.
      Returns:
      the value of the assigneeId record component
    • createdAt

      public Instant createdAt()
      Returns the value of the createdAt record component.
      Returns:
      the value of the createdAt record component
    • startedAt

      public Instant startedAt()
      Returns the value of the startedAt record component.
      Returns:
      the value of the startedAt record component
    • completedAt

      public Instant completedAt()
      Returns the value of the completedAt record component.
      Returns:
      the value of the completedAt record component
    • result

      public Object result()
      Returns the value of the result record component.
      Returns:
      the value of the result record component