ArtifactSinkingTool

class ArtifactSinkingTool<T : Any>(val delegate: Tool, clazz: Class<T>, sink: ArtifactSink, filter: (T) -> Boolean = { true }, transform: (T) -> Any = { it }) : DelegatingTool

Tool decorator that captures artifacts from tool results, filters and transforms them, then sends to one or more sinks.

Handles both single artifacts and Iterables of artifacts.

Parameters

T

The type of artifact to capture

delegate

The tool to wrap

clazz

The class of T for type filtering

sink

Where to send captured artifacts

filter

Optional filter to decide which artifacts to capture. Default accepts all.

transform

Optional function to transform artifacts before sending to sink. Default passes through.

Constructors

Link copied to clipboard
constructor(delegate: Tool, clazz: Class<T>, sink: ArtifactSink, filter: (T) -> Boolean = { true }, transform: (T) -> Any = { it })

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
inline fun <T : Any> Tool.requireType(message: String? = null): Tool

Wrap this tool to require a value of type T before execution (reified).

fun <T : Any> Tool.requireType(type: Class<T>, messageProvider: (String) -> String? = { null }): Tool

Wrap this tool to require a value of type T before execution.

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
open override fun toString(): String
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

Wrap this tool to conditionally await before execution.

Link copied to clipboard
fun Tool.withConfirmation(messageProvider: (String) -> String): Tool

Wrap this tool to always require confirmation before execution.

Link copied to clipboard
open fun withDescription(newDescription: String): Tool

Create a new tool with a different description. Useful for providing context-specific descriptions while keeping the same functionality.

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.

Link copied to clipboard
open fun withName(newName: String): Tool

Create a new tool with a different name. Useful for namespacing tools when combining multiple tool sources.

Link copied to clipboard
open fun withNote(note: String): Tool

Create a new tool with an additional note appended to the description. Useful for adding context-specific hints to an existing tool.