Class ToolOutputGuardrailException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
dev.langchain4j.exception.LangChain4jException
dev.langchain4j.guardrail.GuardrailException
dev.langchain4j.guardrail.ToolOutputGuardrailException
- All Implemented Interfaces:
Serializable
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 Summary
ConstructorsConstructorDescriptionToolOutputGuardrailException(String message) Creates the exception with a message.ToolOutputGuardrailException(String message, @Nullable Throwable cause) Creates the exception with a message and a cause. -
Method Summary
Modifier and TypeMethodDescriptionGets 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).Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ToolOutputGuardrailException
Creates the exception with a message.- Parameters:
message- the message
-
ToolOutputGuardrailException
-
-
Method Details
-
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
-