Companion

object Companion

Functions

Link copied to clipboard
fun <T> conditionalReplan(tool: Tool, decider: (t: T, replanContext: ReplanContext) -> ReplanDecision?): DelegatingTool

When the decider returns a ReplanDecision, replan after execution, adding the artifact to the blackboard along with any additional updates from the decision. The decider receives the artifact cast to type T and the replan context. If the artifact is null or cannot be cast to T, the decider is not called.

Link copied to clipboard
fun create(name: String, description: String, handler: Tool.Handler): Tool

Create a tool with no parameters (Java-friendly). This method is easier to call from Java as it uses the Handler interface.

fun create(name: String, description: String, inputSchema: Tool.InputSchema, handler: Tool.Handler): Tool

Create a tool with input schema (Java-friendly).

fun create(name: String, description: String, metadata: Tool.Metadata, handler: Tool.Handler): Tool

Create a tool with custom metadata (Java-friendly).

fun create(name: String, description: String, inputSchema: Tool.InputSchema, metadata: Tool.Metadata, handler: Tool.Handler): Tool

Create a fully configured tool (Java-friendly).

Link copied to clipboard
fun formatToolTree(name: String, tools: List<Tool>): String

Format a list of tools as an ASCII tree structure. MatryoshkaTools are expanded recursively to show their inner tools.

Link copied to clipboard
fun fromInstance(instance: Any, objectMapper: <Error class: unknown class> = jacksonObjectMapper()): List<Tool>

Create Tools from all methods annotated with LlmTool on an instance.

Link copied to clipboard
fun fromMethod(instance: Any, method: KFunction<*>, objectMapper: <Error class: unknown class> = jacksonObjectMapper()): Tool

Create a Tool from a method annotated with com.embabel.agent.api.annotation.LlmTool.

Link copied to clipboard
fun of(name: String, description: String, metadata: Tool.Metadata = Metadata.DEFAULT, function: Tool.Function): Tool

Create a tool with no parameters.

fun of(name: String, description: String, inputSchema: Tool.InputSchema, metadata: Tool.Metadata = Metadata.DEFAULT, function: Tool.Function): Tool

Create a tool from a function.

Link copied to clipboard
fun replanAlways(tool: Tool): Tool

Make this tool always replan after execution, adding the artifact to the blackboard.

Link copied to clipboard
fun <T> replanAndAdd(tool: Tool, valueComputer: (t: T) -> Any?): DelegatingTool

Replan and add the object returned by the predicate to the blackboard.

Link copied to clipboard
fun <T> replanWhen(tool: Tool, predicate: (t: T) -> Boolean): DelegatingTool

When the predicate matches the tool result artifact, replan, adding the artifact to the blackboard. The predicate receives the artifact cast to type T. If the artifact is null or cannot be cast to T, returns normally.

Link copied to clipboard
fun safelyFromInstance(instance: Any, objectMapper: <Error class: unknown class> = jacksonObjectMapper()): List<Tool>

Safely create Tools from an instance, returning empty list if no annotated methods found. This is useful when you want to scan an object that may or may not have tool methods.