Class CommandSpecFunctionTools

java.lang.Object
org.machanism.machai.gw.tools.CommandSpecFunctionTools
All Implemented Interfaces:
FunctionTools

public class CommandSpecFunctionTools extends Object implements FunctionTools
Provides function tools for task and execution control within the AIFileProcessor context.

This class registers tools for terminating execution and ending tasks in a controlled manner. It is intended for use with AIFileProcessor and integrates with the Genai provider.

Author:
Viktor Tovstyi
  • Field Details

    • TASK_TERMINATED_BY_FUNCTION_TOOL_MESSAGE

      private static final String TASK_TERMINATED_BY_FUNCTION_TOOL_MESSAGE
      See Also:
  • Constructor Details

    • CommandSpecFunctionTools

      public CommandSpecFunctionTools()
  • Method Details

    • terminateExecution

      public String terminateExecution(String message, int exitCode, File projectDir)
      AI functional tool that terminates the application by throwing a ProcessTerminationException.

      Reads message and exitCode from the supplied JsonNode and throws a ProcessTerminationException. This mechanism allows a tool invocation to abort the overall workflow with an explicit exit code.

      Parameters:
      message - message exposed to the host
      exitCode - exit code associated with termination
      projectDir - project directory associated with the invocation
      Throws:
      ProcessTerminationException - always, to request process termination

    • endTask

      public String endTask(String message)
      AI functional tool that completes the current task by throwing an EndTaskException.

      This method is intended to be used as a function tool for terminating a process when requested by the user or dictated by process logic. It logs the task completion and uses a custom message if provided in the properties.

      Parameters:
      message - message describing task completion
      Throws:
      EndTaskException - always, to request task completion