Interface for handling tool execution errors in LangChain4j, providing strategies to report to LLM or fail.
// Source: https://github.com/langchain4j/langchain4j | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package dev.langchain4j.service.tool;
import static dev.langchain4j.internal.ValidationUtils.ensureNotBlank;
import dev.langchain4j.exception.ToolErrorVisibleToLlm;
import dev.langchain4j.exception.ToolExecutionException;
import dev.langchain4j.service.AiServices;
import java.util.function.Function;
/**
* Handler for {@link ToolExecutionException}s thrown by a {@link ToolExecutor}.
* <p>
* There are two ways to handle errors:
* <p>
* 1. Return a {@link ToolErrorHandlerResult#text(String) text message} that will be sent back
* to the LLM, allowing it to respond appropriate
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key