Interface Team
- All Superinterfaces:
com.tnsai.agents.groups.AgentGroup
- All Known Implementing Classes:
DefaultTeam
public interface Team
extends com.tnsai.agents.groups.AgentGroup
A mission-oriented group of agents working toward a common goal.
Team extends AgentGroup with mission tracking, role assignments, and coordinated execution patterns. Teams are formed for specific tasks and can be disbanded after completion.
Key Features
- Mission: Defined goal the team works toward
- Roles: Specialized roles assigned to members
- Formations: Execution patterns (parallel, sequential, hierarchical)
- Progress Tracking: Monitor mission completion
Usage Example
Team team = Team.builder()
.name("Research Team")
.mission("Analyze customer feedback")
.timeout(Duration.ofMinutes(30))
.formation(TeamFormation.PARALLEL)
.member(analyst, TeamRole.LEAD)
.member(researcher1, TeamRole.MEMBER)
.member(researcher2, TeamRole.MEMBER)
.build();
team.start();
TeamResult result = team.execute("Generate insights from Q4 feedback");
team.disband();
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAssembles a team from agents with required roles.voidassignRole(String agentId, TeamRole role) Assigns a role to a team member.static TeamBuilderbuilder()Creates a new Team builder.voiddisband()Disbands the team after mission completion.Executes a task using the team's formation pattern.Executes a task with custom context.executeAsync(String task) Executes a task asynchronously.executeAsync(String task, Map<String, Object> context) Executes a task asynchronously with context.Returns the team formation pattern.default Optional<com.tnsai.agents.Agent> getLead()Gets the team lead if one is assigned.List<com.tnsai.agents.Agent> getMembersWithRole(TeamRole role) Gets all members with a specific role.Returns the mission description.Returns the mission tracker for progress monitoring.Gets the role of a team member.Returns the mission timeout.booleanChecks if the team is disbanded.booleanChecks if the team has completed its mission.Methods inherited from interface com.tnsai.agents.groups.AgentGroup
addLifecycleListener, addMember, addMembershipListener, assignTask, broadcast, broadcast, dissolve, electLeader, electLeader, findMembers, getDescription, getEventBus, getId, getLeader, getLifecycle, getMember, getMemberCount, getMembers, getMembershipManager, getMetrics, getName, getPolicy, hasMember, isActive, isDissolved, removeLifecycleListener, removeMember, removeMembershipListener, scatter, scatter, scatterAsync, setPolicy, start, stop, stopNow
-
Method Details
-
getMission
String getMission()Returns the mission description.- Returns:
- mission description
-
getTimeout
Duration getTimeout()Returns the mission timeout.- Returns:
- timeout duration
-
getFormation
TeamFormation getFormation()Returns the team formation pattern.- Returns:
- formation
-
getMissionTracker
MissionTracker getMissionTracker()Returns the mission tracker for progress monitoring.- Returns:
- mission tracker
-
assignRole
Assigns a role to a team member.- Parameters:
agentId- agent IDrole- role to assign- Throws:
IllegalArgumentException- if agent is not a member
-
getRole
Gets the role of a team member.- Parameters:
agentId- agent ID- Returns:
- role, or empty if not a member
-
getMembersWithRole
Gets all members with a specific role.- Parameters:
role- role to find- Returns:
- members with that role
-
getLead
Gets the team lead if one is assigned.- Returns:
- team lead
-
execute
Executes a task using the team's formation pattern.- Parameters:
task- task to execute- Returns:
- execution result
-
execute
Executes a task with custom context.- Parameters:
task- task to executecontext- additional context- Returns:
- execution result
-
executeAsync
Executes a task asynchronously.- Parameters:
task- task to execute- Returns:
- future with result
-
executeAsync
Executes a task asynchronously with context.- Parameters:
task- task to executecontext- additional context- Returns:
- future with result
-
disband
void disband()Disbands the team after mission completion. All members are removed and the team is dissolved. -
isMissionComplete
boolean isMissionComplete()Checks if the team has completed its mission.- Returns:
- true if mission complete
-
isDisbanded
boolean isDisbanded()Checks if the team is disbanded.- Returns:
- true if disbanded
-
builder
Creates a new Team builder.- Returns:
- builder
-
assemble
static Optional<Team> assemble(String mission, List<com.tnsai.agents.Agent> agents, List<TeamRole> requiredRoles) Assembles a team from agents with required roles.- Parameters:
mission- mission descriptionagents- available agentsrequiredRoles- required roles- Returns:
- assembled team, or empty if requirements not met
-