Class AutoTeamBuilder

java.lang.Object
com.tnsai.autoteam.AutoTeamBuilder

public final class AutoTeamBuilder extends Object
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:

  1. TaskDecomposer — analyzes the task and proposes agent roles
  2. AgentConfigGenerator — generates tailored system prompts per agent
  3. TopologySelector — selects the optimal coordination formation
  4. Agent instantiation via AgentBuilder
  5. AgentGroup construction 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:
  • Method Details

    • create

      public static AutoTeamBuilder create()
      Creates a new AutoTeamBuilder instance.
      Returns:
      a new builder
    • llm

      public AutoTeamBuilder llm(com.tnsai.llm.LLMClient llm)
      Sets the LLM client used for task decomposition and prompt generation.
      Parameters:
      llm - the LLM client
      Returns:
      this builder
    • toolPojos

      public AutoTeamBuilder toolPojos(Object... pojos)
      Adds tools by reflecting over POJO instances bearing @Tool-annotated methods (the function-shape pattern, see RFC #188). Each discovered @Tool method becomes a StaticToolMethod when 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

      public AutoTeamBuilder dynamicTool(com.tnsai.tools.method.DynamicToolMethod dynamicTool)
      Adds a DynamicToolMethod (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 the Tool interface)
    • dynamicTools

      public AutoTeamBuilder dynamicTools(List<com.tnsai.tools.method.DynamicToolMethod> dynamicTools)
      Adds a batch of DynamicToolMethods.
      Parameters:
      dynamicTools - the runtime-defined tools (may be empty)
      Returns:
      this builder
      Since:
      0.7.0
    • temperature

      public AutoTeamBuilder temperature(float 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

      public AutoTeamBuilder maxAgents(int 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 an AgentPrincipal for each generated agent. Required (TNS-298) — every agent dispatched by the team needs verifiable identity for the audit trail. Use LocalIdentityProvider for single-tenant deployments, plug in an external provider (ERC-8004, AIUC-1, X.509) for cross-trust-boundary deployments.
    • liabilitySink

      public AutoTeamBuilder liabilitySink(com.tnsai.accountability.LiabilitySink liabilitySink)
      Liability sink every generated agent publishes AgentLiabilityRecords to. Optional; no records are constructed or retained unless a sink is supplied.
    • authorityScope

      public AutoTeamBuilder authorityScope(com.tnsai.accountability.AuthorityScope authorityScope)
      Default AuthorityScope stamped onto every generated agent's dispatch records. Required (TNS-298). Use AuthorityScope.unrestricted(java.time.Duration) when the deployment deliberately chose not to narrow — that's still an explicit decision, not a silent default.
    • build

      public AutoTeamBuilder.Result build(String taskDescription)
      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

      public TeamPlan plan(String taskDescription)
      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