Class ReadResourceToolConfig.Builder

java.lang.Object
dev.langchain4j.skills.ReadResourceToolConfig.Builder
Enclosing class:
ReadResourceToolConfig

public static class ReadResourceToolConfig.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • name

      Sets the name of the read_skill_resource tool.

      Default value is "read_skill_resource".

    • description

      public ReadResourceToolConfig.Builder description(String description)
      Sets the description of the read_skill_resource tool.

      Default value is "Returns the content of a resource referenced in the skill".

    • skillNameParameterName

      public ReadResourceToolConfig.Builder skillNameParameterName(String skillNameParameterName)
      Sets the name of the skill_name parameter of the read_skill_resource tool.

      Default value is "skill_name".

    • skillNameParameterDescription

      public ReadResourceToolConfig.Builder skillNameParameterDescription(String skillNameParameterDescription)
      Sets the description of the skill_name parameter of the read_skill_resource tool.

      Default value is "The name of the skill for which the resource should be read".

    • relativePathParameterName

      public ReadResourceToolConfig.Builder relativePathParameterName(String relativePathParameterName)
      Sets the name of the relative_path parameter of the read_skill_resource tool.

      Default value is "relative_path".

    • relativePathParameterDescription

      public ReadResourceToolConfig.Builder relativePathParameterDescription(String relativePathParameterDescription)
      Sets the description of the relative_path parameter of the read_skill_resource tool.

      By default, the description is generated dynamically and includes an example path taken from the first available skill resource.

      Takes precedence over relativePathParameterDescriptionProvider(Function).

    • relativePathParameterDescriptionProvider

      public ReadResourceToolConfig.Builder relativePathParameterDescriptionProvider(Function<List<? extends Skill>, String> relativePathParameterDescriptionProvider)
      Sets a function that produces the description of the relative_path parameter of the read_skill_resource tool.

      The function receives the list of configured skills and returns the full parameter description. This allows customizing the description template while still incorporating dynamic information such as an example path derived from the available skill resources. Ignored if relativePathParameterDescription(String) is set.

      Default: skills -> "Relative path to the resource. For example: " + <first resource path>

    • throwToolArgumentsExceptions

      public ReadResourceToolConfig.Builder throwToolArgumentsExceptions(Boolean throwToolArgumentsExceptions)
      Controls which exception type is thrown when tool arguments are missing, invalid, or cannot be parsed.

      Although all errors produced by this tool are argument-related, this strategy throws ToolExecutionException by default instead of ToolArgumentsException.

      The reason is historical: by default, AI Services fail fast when a ToolArgumentsException is thrown, whereas ToolExecutionException allows the error message to be returned to the LLM. For these tools, returning the error message to the LLM is usually the desired behavior.

      If this flag is set to true, ToolArgumentsException will be thrown instead.

      Parameters:
      throwToolArgumentsExceptions - whether to throw ToolArgumentsException
      Returns:
      this builder
    • build

      public ReadResourceToolConfig build()