Interface ToolFunction

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 ToolFunction
Functional interface representing a tool callable by a provider during a run.

Implementations of this interface encapsulate the execution logic for a tool, typically invoked with structured arguments parsed from a model tool invocation request, along with variable runtime context objects (such as the target working directory and configurators).

The apply(JsonNode, Object...) method is the entry point for tool execution, accepting provider-specific parameters as a JsonNode and an array of contextual objects, returning a result object (commonly serialized to JSON).

The constant SESSION_ID_PARAM_NAME defines the standard parameter name for session identification.

Usage Example

 ToolFunction tool = ...;
 JsonNode params = ...;
 File projectDir = ...;
 Configurator config = ...;
 Object result = tool.apply(params, projectDir, config);
 
Author:
Viktor Tovstyi
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Standard parameter name for session identification in tool requests.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(com.fasterxml.jackson.databind.JsonNode params, Object... paramsByType)
    Executes the tool with the given parameters and variable context instances.
  • Field Details

    • SESSION_ID_PARAM_NAME

      static final String SESSION_ID_PARAM_NAME
      Standard parameter name for session identification in tool requests.
      See Also:
  • Method Details

    • apply

      Object apply(com.fasterxml.jackson.databind.JsonNode params, Object... paramsByType) throws Exception
      Executes the tool with the given parameters and variable context instances.
      Parameters:
      params - provider-specific parameters, typically parsed from a JSON structure
      paramsByType - variable-arity parameter list representing runtime contextual environments (e.g. File for working directory, Configurator for lookups)
      Returns:
      the tool execution result (commonly a string or object serializable to JSON)
      Throws:
      Exception - if tool execution fails during processing