Interface DesireConflictResolver

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 DesireConflictResolver
Strategy interface for resolving conflicts between desires with the same priority.

When multiple desires have the same priority level, this resolver determines which desire should take precedence. This is particularly useful when desires conflict with each other (e.g., "minimize cost" vs "maximize quality").

Built-in Strategies

Usage Example


 // Specure agent with conflict resolver
 agent.setDesireConflictResolver(DesireConflictResolver.FIRST_WINS);

 // Add potentially conflicting desires
 agent.addDesire(new Desire("Minimize cost", Priority.HIGH, "Budget constraints"));
 agent.addDesire(new Desire("Maximize quality", Priority.HIGH, "Customer satisfaction"));
 // Only one remains (based on strategy)

 // Using LLM-based resolver
 agent.setDesireConflictResolver(new com.tnsai.llm.LLMBasedConflictResolver(llmClient));
 
See Also:
  • Desire
  • invalid reference
    com.tnsai.llm.LLMBasedConflictResolver
  • Field Details

  • Method Details

    • resolve

      Optional<Desire> resolve(List<Desire> conflicting)
      Resolves conflicts among a list of desires with the same priority.
      Parameters:
      conflicting - list of conflicting desires (same priority)
      Returns:
      the resolved desire, or empty if all should be removed
    • mightConflict

      default boolean mightConflict(Desire d1, Desire d2)
      Checks if two desires might conflict with each other. Default implementation uses simple heuristics.
      Parameters:
      d1 - first desire
      d2 - second desire
      Returns:
      true if desires might conflict
    • boostPriority

      static Desire boostPriority(Desire desire)
      Creates a priority-boosted desire if resolution results in tie-breaking.
      Parameters:
      desire - the desire to boost
      Returns:
      a new desire with increased priority (if not already CRITICAL)