Package com.tnsai.autoteam
Class AutoTeamBuilder
java.lang.Object
com.tnsai.autoteam.AutoTeamBuilder
Generates a fully configured multi-agent team from a natural language task description.
AutoTeamBuilder is the main entry point for automatic team generation. It orchestrates the full pipeline:
TaskDecomposer— analyzes the task and proposes agent rolesAgentConfigGenerator— generates tailored system prompts per agentTopologySelector— selects the optimal coordination formation- Agent instantiation via
AgentBuilder AgentGroupconstruction with selected formation
Usage Example
LLMClient llm = new OpenAIClient("gpt-4o", apiKey);
AutoTeamBuilder.Result result = AutoTeamBuilder.create()
.llm(llm)
.tool(new BraveSearchTool())
.tool(new WebScraperTool())
.build("Research and summarize recent advances in quantum computing");
AgentGroup team = result.group();
TeamPlan plan = result.plan();
System.out.println("Created team: " + plan.teamName() + " with " + plan.agentCount() + " agents");
Customization
AutoTeamBuilder.Result result = AutoTeamBuilder.create()
.llm(llm)
.maxAgents(5)
.temperature(0.3f)
.agentCustomizer(builder -> builder.maxContextTokens(4000))
.build("Analyze customer feedback and generate action items");
- Since:
- 0.3.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of the auto-team building process. -
Method Summary
Modifier and TypeMethodDescriptionagentCustomizer(Function<com.tnsai.agents.AgentBuilder, com.tnsai.agents.AgentBuilder> customizer) Sets a customizer function applied to each AgentBuilder before building.authorityScope(com.tnsai.accountability.AuthorityScope authorityScope) DefaultAuthorityScopestamped onto every generated agent's dispatch records.Generates the team for the given task description.static AutoTeamBuildercreate()Creates a new AutoTeamBuilder instance.dynamicTool(com.tnsai.tools.method.DynamicToolMethod dynamicTool) Adds aDynamicToolMethod(e.g. an MCP proxy) to the pool of tools that can be assigned to generated agents.dynamicTools(List<com.tnsai.tools.method.DynamicToolMethod> dynamicTools) Adds a batch ofDynamicToolMethods.liabilitySink(com.tnsai.accountability.LiabilitySink liabilitySink) Liability sink every generated agent publishesAgentLiabilityRecords to.llm(com.tnsai.llm.LLMClient llm) Sets the LLM client used for task decomposition and prompt generation.maxAgents(int maxAgents) Sets the maximum number of agents to generate.Generates only the team plan without building agents.principalProvider(com.tnsai.identity.AgentPrincipalProvider principalProvider) Identity provider that mints anAgentPrincipalfor each generated agent.temperature(float temperature) Sets the LLM temperature for decomposition and prompt generation.Adds tools by reflecting over POJO instances bearing@Tool-annotated methods (the function-shape pattern, see RFC #188).
-
Method Details
-
create
Creates a new AutoTeamBuilder instance.- Returns:
- a new builder
-
llm
Sets the LLM client used for task decomposition and prompt generation.- Parameters:
llm- the LLM client- Returns:
- this builder
-
toolPojos
Adds tools by reflecting over POJO instances bearing@Tool-annotated methods (the function-shape pattern, see RFC #188). Each discovered@Toolmethod becomes aStaticToolMethodwhen generated agents are built.Example:
AutoTeamBuilder.create() .llm(llmClient) .objective(...) .toolPojos(new EmailTools(creds), new SquareTools(token)) .build();- Parameters:
pojos- one or more objects whose public methods carry@Tool- Returns:
- this builder
- Since:
- 0.5.7
-
dynamicTool
Adds aDynamicToolMethod(e.g. an MCP proxy) to the pool of tools that can be assigned to generated agents.- Parameters:
dynamicTool- the runtime-defined tool (non-null)- Returns:
- this builder
- Since:
- 0.7.0 (replaced the legacy
tool(Tool)/tools(List<Tool>)registration paths together with theToolinterface)
-
dynamicTools
Adds a batch ofDynamicToolMethods.- Parameters:
dynamicTools- the runtime-defined tools (may be empty)- Returns:
- this builder
- Since:
- 0.7.0
-
temperature
Sets the LLM temperature for decomposition and prompt generation. Lower values produce more deterministic results.- Parameters:
temperature- temperature (0.0 - 2.0)- Returns:
- this builder
-
maxAgents
Sets the maximum number of agents to generate.- Parameters:
maxAgents- maximum agent count (must be >= 1)- Returns:
- this builder
-
agentCustomizer
public AutoTeamBuilder agentCustomizer(Function<com.tnsai.agents.AgentBuilder, com.tnsai.agents.AgentBuilder> customizer) Sets a customizer function applied to each AgentBuilder before building. Use this to add common configuration (memory stores, context tokens, etc.)- Parameters:
customizer- function that customizes each agent builder- Returns:
- this builder
-
principalProvider
public AutoTeamBuilder principalProvider(com.tnsai.identity.AgentPrincipalProvider principalProvider) Identity provider that mints anAgentPrincipalfor each generated agent. Required (TNS-298) — every agent dispatched by the team needs verifiable identity for the audit trail. UseLocalIdentityProviderfor single-tenant deployments, plug in an external provider (ERC-8004, AIUC-1, X.509) for cross-trust-boundary deployments. -
liabilitySink
Liability sink every generated agent publishesAgentLiabilityRecords to. Optional; no records are constructed or retained unless a sink is supplied. -
authorityScope
DefaultAuthorityScopestamped onto every generated agent's dispatch records. Required (TNS-298). UseAuthorityScope.unrestricted(java.time.Duration)when the deployment deliberately chose not to narrow — that's still an explicit decision, not a silent default. -
build
Generates the team for the given task description.This method orchestrates the full pipeline: decomposition, config generation, topology selection, agent instantiation, and group construction.
- Parameters:
taskDescription- natural-language task description- Returns:
- the build result containing the agent group and team plan
- Throws:
IllegalStateException- if LLM is not configured
-
plan
Generates only the team plan without building agents. Useful for previewing or modifying the plan before instantiation.- Parameters:
taskDescription- natural-language task description- Returns:
- the generated team plan
-