Playbook Tool
A tool with conditional tool unlocking that uses an LLM to orchestrate sub-tools.
Unlike com.embabel.agent.api.tool.agentic.simple.SimpleAgenticTool which makes all tools available immediately, a PlaybookTool allows tools to be progressively unlocked based on conditions such as:
Prerequisites: unlock after other tools have been called
Artifacts: unlock when certain artifact types are produced
Blackboard: unlock based on process state
Custom predicates: unlock based on arbitrary conditions
This provides more predictable LLM behavior by guiding it through a structured sequence of available tools.
Usage
// Kotlin curried syntax
PlaybookTool("researcher", "Research and analyze topics")
.withTools(searchTool, fetchTool) // always available
.withTool(analyzeTool)(searchTool) // unlocks after search
.withTool(summarizeTool)(analyzeTool) // unlocks after analyze
// Java fluent syntax
new PlaybookTool("researcher", "Research and analyze topics")
.withTools(searchTool, fetchTool)
.withTool(analyzeTool).unlockedBy(searchTool)
.withTool(summarizeTool).unlockedBy(analyzeTool);Parameters
Tool definition (name, description, input schema)
Optional tool metadata
LLM to use for orchestration. It is good practice to provide
Tools that are always available
Tools with unlock conditions
Create prompt for the LLM to use, given context and input
Maximum number of tool loop iterations
Properties
Functions
Execute the tool with JSON 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 copy with different LLM options.
Create a copy with a different max iterations limit.
Create a copy with an additional parameter in the definition.
Create a copy with a fixed system prompt. This is a convenience method that delegates to withSystemPrompt with a creator.
Create a copy with a dynamic system prompt creator. The creator receives the execution context and input string.
Begin registration of a tool with unlock conditions. Returns a ToolRegistration that can be used with curried syntax or fluent API.
Register a class whose @LlmTool methods become available as tools when a single instance of that type is returned as an artifact.
Register a class that can contribute @LlmTool methods when a single instance is retrieved. Kotlin-friendly version using reified type parameter.
Register a class with a predicate. Kotlin-friendly version using reified type parameter.
Register a domain class with a predicate to control when its @LlmTool methods are exposed.
Enable auto-discovery of chained tools from any returned artifact.
Create a copy with tools extracted from an object with @LlmTool methods. If the object has no @LlmTool methods, returns this unchanged.
Add tools that are always available (no unlock conditions).