Class ToolInputGuardrailException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
dev.langchain4j.exception.LangChain4jException
dev.langchain4j.guardrail.GuardrailException
dev.langchain4j.guardrail.ToolInputGuardrailException
- All Implemented Interfaces:
Serializable
Exception thrown when a fatal
ToolInputGuardrail failure aborts the AI service invocation.
It is thrown before a tool is executed, so the tool was not 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
ConstructorsConstructorDescriptionToolInputGuardrailException(String message) Creates the exception with a message.ToolInputGuardrailException(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 failing guardrail validated them: after the rewrites of the guardrails that ran before it (the arguments the LLM sent if none of them rewrote them).Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ToolInputGuardrailException
Creates the exception with a message.- Parameters:
message- the message
-
ToolInputGuardrailException
-
-
Method Details
-
toolExecutionRequest
Gets the tool call that the failure stopped: its id, the name of the tool and its arguments, as the failing guardrail validated them: after the rewrites of the guardrails that ran before it (the arguments the LLM sent if none of them rewrote them). The tool was not executed, but the framework reports the rejected call with these arguments, as it does for a non-fatal failure (seeToolInputGuardrailResult.rewrittenArguments()).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
ToolInputGuardrailExecutor
-