fromToolObject

open override fun fromToolObject(instance: Any, name: String, description: String, removeOnInvoke: Boolean, childToolUsageNotes: String?): UnfoldingTool

Create an UnfoldingTool from any object with @LlmTool methods, providing explicit name and description.

Unlike fromInstance, this does NOT require the class to be annotated with @UnfoldingTools or @MatryoshkaTools. The name and description are provided as parameters rather than being derived from a class-level annotation.

This is useful for wrapping tool objects (e.g., interface implementations with @LlmTool default methods) that cannot or should not be annotated with @UnfoldingTools.

Example:

val fileTools = UnfoldingTool.fromToolObject(
instance = FileWriteTools(),
name = "file_write_tools",
description = "Tools for writing files",
)

Return

An UnfoldingTool wrapping the annotated methods

Parameters

instance

Any object with @LlmTool annotated methods

name

Unique name for the UnfoldingTool

description

Description explaining when to use this tool category

removeOnInvoke

Whether to remove this tool after invocation (default true)

childToolUsageNotes

Optional notes to guide LLM on using the child tools

Throws

if the object has no @LlmTool methods


fun fromToolObject(instance: Any, name: String, description: String): UnfoldingTool