Matryoshka Tool
A tool that contains other tools, enabling progressive tool disclosure.
Named after Russian nesting dolls, a MatryoshkaTool presents a high-level description to the LLM. When invoked, its inner tools become available and (optionally) the MatryoshkaTool itself is removed.
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
Example:
val databaseTool = MatryoshkaTool.of(
name = "database_operations",
description = "Use this to work with the database. Invoke to see specific operations.",
innerTools = listOf(queryTableTool, insertRecordTool, updateRecordTool)
)See also
Properties
Functions
Execute the tool with JSON input.
Select which inner tools to expose based on invocation input.
Extension function to convert an Embabel Tool to a Spring AI ToolCallback.
Unwrap a tool to find the innermost implementation. Recursively unwraps DelegatingTool wrappers.
Extension function to wrap a Tool with event publication.