Class ToolOutputGuardrailException

All Implemented Interfaces:
Serializable

@Experimental public final class ToolOutputGuardrailException extends GuardrailException
Exception thrown when a fatal ToolOutputGuardrail failure aborts the AI service invocation. It is thrown after a tool was executed.

This class is not intended to be thrown within guardrail implementations. It is for the framework only. It is ok to catch it.

Since:
1.25.0
See Also:
  • Constructor Details

    • ToolOutputGuardrailException

      public ToolOutputGuardrailException(String message)
      Creates the exception with a message.
      Parameters:
      message - the message
    • ToolOutputGuardrailException

      public ToolOutputGuardrailException(String message, @Nullable Throwable cause)
      Creates the exception with a message and a cause.
      Parameters:
      message - the message
      cause - the cause, or null when there is none
  • Method Details

    • toolExecutionRequest

      public Optional<ToolExecutionRequest> toolExecutionRequest()
      Gets the tool call that the failure stopped: its id, the name of the tool and its arguments, as the tool was executed with them (after the rewrites of the input guardrails).

      With several tool calls in one response of the LLM, or a guardrail that applies to every tool, it tells which call failed. The message names the tool, but not the arguments, which can hold user data.

      Returns:
      the tool call, or empty if the exception was not thrown by a ToolOutputGuardrailExecutor