Package com.google.genkit.ai
Class ToolInterruptException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.google.genkit.ai.ToolInterruptException
- All Implemented Interfaces:
Serializable
Exception thrown when a tool execution is interrupted.
This exception is used to implement the interrupt pattern, which allows tools to pause execution and request user input (human-in-the-loop). When a tool throws this exception, the generation loop stops and returns the interrupt information to the caller.
Example usage:
Tool<Input, Output> confirmTool = genkit.defineInterrupt(InterruptConfig.<Input, Output>builder()
.name("confirmAction").description("Ask user for confirmation before proceeding").inputSchema(Input.class)
.outputSchema(Output.class).build());
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ToolInterruptException with no metadata.ToolInterruptException(String message, Map<String, Object> metadata) Creates a new ToolInterruptException with a message and metadata.ToolInterruptException(Map<String, Object> metadata) Creates a new ToolInterruptException with metadata. -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ToolInterruptException
public ToolInterruptException()Creates a new ToolInterruptException with no metadata. -
ToolInterruptException
Creates a new ToolInterruptException with metadata.- Parameters:
metadata- additional metadata about the interrupt
-
ToolInterruptException
Creates a new ToolInterruptException with a message and metadata.- Parameters:
message- the exception messagemetadata- additional metadata about the interrupt
-
-
Method Details
-
getMetadata
Gets the interrupt metadata.- Returns:
- the metadata, never null (returns empty map if not set)
-