ReplanningTool

class ReplanningTool constructor(val delegate: Tool, reason: String, blackboardUpdater: ReplanningToolBlackboardUpdater = ReplanningToolBlackboardUpdater { bb, content -> bb.addObject(content) }) : DelegatingTool

Tool decorator that executes the wrapped tool, adds its result to the blackboard, then throws ReplanRequestedException to terminate the tool loop and trigger replanning.

This enables patterns like:

  • Chat routing: A routing tool classifies intent and triggers replan to switch handlers

  • Discovery: A tool discovers information that requires a different plan

Note: This tool accesses AgentProcess via thread-local at call time, which is set by the decorator chain.

Parameters

delegate

The tool to wrap

reason

Human-readable explanation of why replan is needed

blackboardUpdater

Callback to update the blackboard before replanning. Receives the result content and can add objects to the blackboard. Defaults to adding the result content as a string.

Constructors

Link copied to clipboard
constructor(delegate: Tool, reason: String, blackboardUpdater: ReplanningToolBlackboardUpdater = ReplanningToolBlackboardUpdater { bb, content -> bb.addObject(content) })

Properties

Link copied to clipboard
open override val definition: Tool.Definition

Tool definition for LLM

Link copied to clipboard
open override val delegate: Tool
Link copied to clipboard
open override val metadata: Tool.Metadata

Optional metadata

Functions

Link copied to clipboard
open override fun call(input: String): Tool.Result

Execute the tool with JSON input.

Link copied to clipboard
fun Tool.toSpringToolCallback(): <Error class: unknown class>

Extension function to convert an Embabel Tool to a Spring AI ToolCallback.

Link copied to clipboard

Unwrap a tool to find the innermost implementation. Recursively unwraps DelegatingTool wrappers.

Link copied to clipboard
inline fun <T : Tool> Tool.unwrapAs(): T?

Unwrap a tool to find a specific type, or return null if not found.

Link copied to clipboard
fun Tool.withEventPublication(agentProcess: AgentProcess, action: Action?, llmOptions: <Error class: unknown class>): Tool

Extension function to wrap a Tool with event publication.