Class RunShellCommandToolConfig.Builder

java.lang.Object
dev.langchain4j.skills.shell.RunShellCommandToolConfig.Builder
Enclosing class:
RunShellCommandToolConfig

public static class RunShellCommandToolConfig.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • name

      Sets the name of the run_shell_command tool.

      Default value is "run_shell_command".

    • description

      public RunShellCommandToolConfig.Builder description(String description)
      Sets the description of the run_shell_command tool.

      By default, the description is generated dynamically and includes the current OS name.

    • commandParameterName

      public RunShellCommandToolConfig.Builder commandParameterName(String commandParameterName)
      Sets the name of the command parameter of the run_shell_command tool.

      Default value is "command".

    • commandParameterDescription

      public RunShellCommandToolConfig.Builder commandParameterDescription(String commandParameterDescription)
      Sets the description of the command parameter of the run_shell_command tool.

      Default value is "The shell command to execute".

    • timeoutSecondsParameterName

      public RunShellCommandToolConfig.Builder timeoutSecondsParameterName(String timeoutSecondsParameterName)
      Sets the name of the timeout_seconds parameter of the run_shell_command tool.

      Default value is "timeout_seconds".

    • timeoutSecondsParameterDescription

      public RunShellCommandToolConfig.Builder timeoutSecondsParameterDescription(String timeoutSecondsParameterDescription)
      Sets the description of the timeout_seconds parameter of the run_shell_command tool.

      Default value is "Optional. The command timeout in seconds. Default: 30 seconds".

    • maxStdOutChars

      public RunShellCommandToolConfig.Builder maxStdOutChars(Integer maxStdOutChars)
      Sets the maximum number of characters of stdout to include in the tool result returned to the LLM. If the output exceeds this limit, the beginning is discarded and a truncation notice is prepended.

      Default value is 10000.

    • maxStdErrChars

      public RunShellCommandToolConfig.Builder maxStdErrChars(Integer maxStdErrChars)
      Sets the maximum number of characters of stderr to include in the tool result returned to the LLM. If the output exceeds this limit, the beginning is discarded and a truncation notice is prepended.

      Default value is 10000.

    • workingDirectory

      public RunShellCommandToolConfig.Builder workingDirectory(Path workingDirectory)
      Sets the working directory in which shell commands will be executed.

      By default, the current JVM working directory (user.dir) is used.

    • executorService

      public RunShellCommandToolConfig.Builder executorService(ExecutorService executorService)
      Sets the ExecutorService used to read the stdout and stderr streams of shell commands submitted via the run_shell_command tool.

      By default, DefaultExecutorProvider.getDefaultExecutorService() is used.

    • throwToolArgumentsExceptions

      public RunShellCommandToolConfig.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 RunShellCommandToolConfig build()