Interface MatryoshkaTool

  • All Implemented Interfaces:
    com.embabel.agent.api.tool.Tool , com.embabel.agent.api.tool.ToolInfo

    
    public interface MatryoshkaTool
     implements 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)
    )
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      List<Tool> selectTools(String input) Select which inner tools to expose based on invocation input.
      abstract List<Tool> getInnerTools() The inner tools that will be exposed when this tool is invoked.
      Boolean getRemoveOnInvoke()
      • Methods inherited from class com.embabel.agent.api.tool.Tool

        call
      • Methods inherited from class com.embabel.agent.api.tool.ToolInfo

        getDefinition, getMetadata
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • selectTools

         List<Tool> selectTools(String input)

        Select which inner tools to expose based on invocation input.

        Override this method to implement category-based or argument-driven tool selection. Default implementation returns all inner tools.

        Parameters:
        input - The JSON input string provided to this tool
        Returns:

        The tools to expose (subset of innerTools or all)

      • getInnerTools

         abstract List<Tool> getInnerTools()

        The inner tools that will be exposed when this tool is invoked.