Unfolding Tool
A ProgressiveTool with a fixed set of inner tools that are revealed when invoked, regardless of the agent process context.
This pattern is useful for:
Reducing tool set complexity for the LLM
Grouping related tools under a category facade
Progressive disclosure based on LLM intent
Context Preservation
When an UnfoldingTool is expanded, a context tool can be created that preserves the parent's description and optional usage notes. This solves the problem where child tools would lose context about the parent's purpose.
The childToolUsageNotes field provides additional guidance on how to use the child tools, included only once in the context tool rather than duplicated in each child tool's description.
Example:
val spotifyTool = UnfoldingTool.of(
name = "spotify_search",
description = "Search Spotify for music data including artists, albums, and tracks.",
innerTools = listOf(vectorSearchTool, textSearchTool, regexSearchTool),
childToolUsageNotes = "Try vector search first for semantic queries like 'upbeat jazz'. " +
"Use text search for exact artist or album names. " +
"Use regex search for pattern matching on metadata."
)See also
for context-dependent tool revelation
Inheritors
Properties
Optional usage notes to guide the LLM on when to invoke the child tools.
Tool definition for LLM
Whether to include a context tool when this tool is unfolded.
The inner tools that will be exposed when this tool is invoked. This is a fixed set that does not vary by context.
Optional metadata
Whether to remove this tool after invocation.
Functions
Execute the tool with JSON input.
Returns the fixed innerTools regardless of process context.
Select which inner tools to expose based on invocation input.
Extension function to convert an Embabel Tool to a Spring AI ToolCallback.
Wrap this tool to conditionally await before execution.
Wrap this tool to always require confirmation before execution.
Create a new tool with a different description. Useful for providing context-specific descriptions while keeping the same functionality.
Extension function to wrap a Tool with event publication.
Create a new UnfoldingTool with tools added from an annotated object.
Create a new UnfoldingTool with additional tools added.