Interface ActionHandler

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 ActionHandler
Handles action execution in a ReAct loop.

Implementations define how actions identified by the LLM reasoning step are actually executed. This decouples the ReAct loop from specific execution mechanisms (tool execution, API calls, local methods, etc.).

  • Method Summary

    Modifier and Type
    Method
    Description
    execute(String actionName, String actionInput)
    Executes an action and returns the observation.
    withFallback(ActionHandler primary, String fallbackMessage)
    Creates an action handler that always returns a fixed message for unknown actions.
  • Method Details

    • execute

      Optional<String> execute(String actionName, String actionInput)
      Executes an action and returns the observation.
      Parameters:
      actionName - the name of the action to execute
      actionInput - the input/arguments for the action
      Returns:
      the observation result, or empty if the action is unknown
    • withFallback

      static ActionHandler withFallback(ActionHandler primary, String fallbackMessage)
      Creates an action handler that always returns a fixed message for unknown actions.