接口 SubAgentProvider<T extends Agent>

类型参数:
T - The type of agent this provider creates
函数接口:
这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。

@FunctionalInterface public interface SubAgentProvider<T extends Agent>
Factory interface for creating agent instances.

Since ReActAgent is not thread-safe, this provider pattern ensures that each tool call gets a fresh agent instance. This is similar to Spring's ObjectProvider pattern.

Example usage:


 SubAgentProvider<ReActAgent> provider = () -> ReActAgent.builder()
     .name("ResearchAgent")
     .model(model)
     .sysPrompt("You are a research expert...")
     .build();

 toolkit.registration()
     .subAgent(provider)
     .apply();
 
  • 方法概要

    修饰符和类型
    方法
    说明
    Provides a new agent instance.
  • 方法详细资料

    • provide

      T provide()
      Provides a new agent instance.

      This method is called for each tool invocation to ensure thread safety. Implementations should create a new agent instance each time this method is called.

      返回:
      A new agent instance