Class ClassToolProvider
- All Implemented Interfaces:
ToolProvider
ToolProvider that wraps a Class<? extends Tool>. Reads
ToolName, ToolDescription, DisplayName, ToolWeight
annotations. Schema is generated once via PojoResponseHandler and cached.
Equality is by wrapped class identity, so registering the same class twice produces
the same provider key, supporting ToolRegistry's upsert-on-same-identity policy.
- Since:
- 0.1 (2026-05-08)
- Author:
- Andrey Santrosyan
-
Method Summary
Modifier and TypeMethodDescriptionAction verb for status surfacing (e.g.Tool<?, ?> create(Identifiable parent) Builds theToolinstance for execution.Human/LLM readable description; truncation is the implementation's choice.Display name (human-facing UI).booleaninthashCode()Class<?> Input POJO type, used for input-guardrail typing (instanceof matching).name()Unique name within a registry.static ClassToolProviderWraps a tool class.JSON Schema ofToolProvider.outputType(), or null when there is no output type.Class<?> Output POJO type, or null when the provider cannot know it.parseInput(com.fasterxml.jackson.databind.JsonNode raw) Parses LLM-emitted input (already converted toJsonNodeupstream byThinkingResponseHandler) into the typed input the tool'sexecuteexpects.booleanreadOnly()Whether invoking this tool leaves the environment unchanged.JSON-Schema bytes that go into theToolDefinitionBlockschema field.ConcreteToolclass produced byToolProvider.create(Identifiable).toString()weight()Effective weight metadata.Methods inherited from interface ToolProvider
metadata
-
Method Details
-
of
Wraps a tool class. Constructs a fresh provider each call; the schema generation it pays for happens once per instance, andToolRegistry's same-identity upsert keeps repeated registrations from stacking. -
name
Description copied from interface:ToolProviderUnique name within a registry. Used for LLM-facing tool identity.- Specified by:
namein interfaceToolProvider
-
description
Description copied from interface:ToolProviderHuman/LLM readable description; truncation is the implementation's choice.- Specified by:
descriptionin interfaceToolProvider
-
schemaJson
Description copied from interface:ToolProviderJSON-Schema bytes that go into theToolDefinitionBlockschema field.- Specified by:
schemaJsonin interfaceToolProvider
-
weight
Description copied from interface:ToolProviderEffective weight metadata.- Specified by:
weightin interfaceToolProvider
-
displayName
Description copied from interface:ToolProviderDisplay name (human-facing UI). Falls back toToolProvider.name()when no override.- Specified by:
displayNamein interfaceToolProvider
-
actionVerb
Description copied from interface:ToolProviderAction verb for status surfacing (e.g. "Searching"). Empty string when unset.- Specified by:
actionVerbin interfaceToolProvider
-
readOnly
public boolean readOnly()Description copied from interface:ToolProviderWhether invoking this tool leaves the environment unchanged. MirrorsToolDescription.readOnly()for class-backed providers.The default is
falsebecause that is the correct answer for a provider that cannot know: an MCP server describes no such property, andrequest_toolsadmits arbitrary tools by construction. Both are genuinely mutating as far as the framework can establish, so the default is the truth rather than a compatibility fallback. A provider returnstrueonly where something asserted it.Consumed by
ReadOnlyPaletteto bound a read-only thinker's palette structurally.- Specified by:
readOnlyin interfaceToolProvider
-
inputType
Description copied from interface:ToolProviderInput POJO type, used for input-guardrail typing (instanceof matching).- Specified by:
inputTypein interfaceToolProvider
-
outputType
Description copied from interface:ToolProviderOutput POJO type, or null when the provider cannot know it. A class-backed provider reads it offTool<I,O>; an MCP-bound provider wraps someone else's tool and has no Java output type, so it answers null.Only the published-schema path consumes this. Nothing model-facing does: a model is told what a tool takes, never what shape comes back, because the answer arrives as a tool result it reads directly.
- Specified by:
outputTypein interfaceToolProvider
-
outputSchemaJson
Description copied from interface:ToolProviderJSON Schema ofToolProvider.outputType(), or null when there is no output type. Published as the MCP tool'soutputSchemaso a consumer knows what it is receiving.- Specified by:
outputSchemaJsonin interfaceToolProvider
-
toolClass
Description copied from interface:ToolProviderConcreteToolclass produced byToolProvider.create(Identifiable). Used by admission predicates and guardrail registries to test class-assignability without having to instantiate the tool.ClassToolProviderreturns the wrapped class; MCP-bound providers returnGenericMCPToolAdapter.class.- Specified by:
toolClassin interfaceToolProvider
-
parseInput
public Object parseInput(com.fasterxml.jackson.databind.JsonNode raw) throws CorrectableLLMException Description copied from interface:ToolProviderParses LLM-emitted input (already converted toJsonNodeupstream byThinkingResponseHandler) into the typed input the tool'sexecuteexpects. Class-based providers convert via the framework JSON serializer; MCP-bound providers wrap the tree as an MCP input envelope without translation.- Specified by:
parseInputin interfaceToolProvider- Throws:
CorrectableLLMException- when the LLM produced input the provider cannot parse; the LLM can correct and retry.
-
create
Description copied from interface:ToolProviderBuilds theToolinstance for execution. May throw when the underlying resource (e.g. an MCP client) cannot be obtained right now.- Specified by:
createin interfaceToolProvider- Throws:
LLMReadableCheckedException
-
equals
-
hashCode
-
toString
-