Interface ReasoningStrategyHandle


public interface ReasoningStrategyHandle
SPI handle for reasoning strategy integration.

This interface defines the reasoning contract that Agent uses. Concrete implementations live in tnsai-intelligence and are discovered via SpiLoader.

Supported strategies include:

  • ReAct: Reason → Act → Observe loop
  • Tree of Thoughts: Multi-path exploration with pruning
  • Graph of Thoughts: Graph-based reasoning with merging
  • Self-Consistency: Multiple paths with consensus voting

Usage Example


 Agent agent = AgentBuilder.create()
     .role(new MyRole())
     .reasoningStrategy("react")
     .build();

 // Agent uses ReAct loop instead of simple LLM call
 String answer = agent.chat("Solve this problem step by step");

 // Access reasoning details
 agent.getLastReasoningResult().ifPresent(result -> {
     System.out.println("Steps: " + result.metadata().get("steps"));
     System.out.println("LLM calls: " + result.metadata().get("llmCalls"));
 });
 
  • Method Details

    • reason

      Performs reasoning on a message using the strategy's algorithm.
      Parameters:
      message - user message to reason about
      context - reasoning context providing LLM, tools, and history
      Returns:
      result containing the answer and strategy-specific metadata
    • name

      String name()
      Returns the strategy name (e.g., "react", "tot", "got", "self-consistency").
      Returns:
      strategy identifier