Interface ConflictResolutionStrategy

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ConflictResolutionStrategy
Strategy for resolving conflicts when multiple agents can fire simultaneously on the blackboard. The strategy receives the current scope state and all candidate agents that are ready to fire, and returns which one should be activated.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Selects the first candidate, preserving the declaration order used in the subAgents method.
  • Method Summary

    Modifier and Type
    Method
    Description
    agentOfType(Class<?> agentType)
    Returns a strategy that unconditionally selects the candidate matching agentType, or null if no candidate of that type is present.
    agentOfType(Class<?> agentType, Predicate<dev.langchain4j.agentic.scope.AgenticScope> condition)
    Returns a strategy that selects the candidate matching agentType only when condition is satisfied, or null otherwise.
    agentWithName(String agentName)
    Returns a strategy that unconditionally selects the candidate matching agentName, or null if no candidate with that name is present.
    agentWithName(String agentName, Predicate<dev.langchain4j.agentic.scope.AgenticScope> condition)
    Returns a strategy that selects the candidate matching agentName only when condition is satisfied, or null otherwise.
    Returns a strategy that selects the first candidate in declaration order.
    Chains this strategy with a fallback: if this strategy returns null, the other strategy is applied instead.
    dev.langchain4j.agentic.planner.AgentInstance
    resolve(dev.langchain4j.agentic.scope.AgenticScope scope, List<dev.langchain4j.agentic.planner.AgentInstance> candidates)
     
    selectAgent(Predicate<dev.langchain4j.agentic.planner.AgentInstance> agentFilter)
    Returns a strategy that unconditionally selects the first candidate matching agentFilter, or null if no candidate matches.
    selectAgent(Predicate<dev.langchain4j.agentic.planner.AgentInstance> agentFilter, Predicate<dev.langchain4j.agentic.scope.AgenticScope> condition)
    Returns a strategy that selects the first candidate matching agentFilter only when condition is satisfied, or null otherwise.
  • Field Details

    • DECLARATION_ORDER

      static final ConflictResolutionStrategy DECLARATION_ORDER
      Selects the first candidate, preserving the declaration order used in the subAgents method.
  • Method Details

    • resolve

      dev.langchain4j.agentic.planner.AgentInstance resolve(dev.langchain4j.agentic.scope.AgenticScope scope, List<dev.langchain4j.agentic.planner.AgentInstance> candidates)
    • declarationOrder

      static ConflictResolutionStrategy declarationOrder()
      Returns a strategy that selects the first candidate in declaration order. This is the default strategy used by BlackboardPlanner if no strategy is provided.
    • agentOfType

      static ConflictResolutionStrategy agentOfType(Class<?> agentType, Predicate<dev.langchain4j.agentic.scope.AgenticScope> condition)
      Returns a strategy that selects the candidate matching agentType only when condition is satisfied, or null otherwise. Intended to be chained with or(ConflictResolutionStrategy).
    • agentOfType

      static ConflictResolutionStrategy agentOfType(Class<?> agentType)
      Returns a strategy that unconditionally selects the candidate matching agentType, or null if no candidate of that type is present.
    • agentWithName

      static ConflictResolutionStrategy agentWithName(String agentName, Predicate<dev.langchain4j.agentic.scope.AgenticScope> condition)
      Returns a strategy that selects the candidate matching agentName only when condition is satisfied, or null otherwise. Intended to be chained with or(ConflictResolutionStrategy).
    • agentWithName

      static ConflictResolutionStrategy agentWithName(String agentName)
      Returns a strategy that unconditionally selects the candidate matching agentName, or null if no candidate with that name is present.
    • selectAgent

      static ConflictResolutionStrategy selectAgent(Predicate<dev.langchain4j.agentic.planner.AgentInstance> agentFilter, Predicate<dev.langchain4j.agentic.scope.AgenticScope> condition)
      Returns a strategy that selects the first candidate matching agentFilter only when condition is satisfied, or null otherwise. Intended to be chained with or(ConflictResolutionStrategy).
    • selectAgent

      static ConflictResolutionStrategy selectAgent(Predicate<dev.langchain4j.agentic.planner.AgentInstance> agentFilter)
      Returns a strategy that unconditionally selects the first candidate matching agentFilter, or null if no candidate matches.
    • or

      Chains this strategy with a fallback: if this strategy returns null, the other strategy is applied instead.