Package com.embabel.agent.api.tool
Class AgenticTool
-
- All Implemented Interfaces:
-
com.embabel.agent.api.tool.Tool,com.embabel.agent.api.tool.ToolInfo
public final class AgenticTool implements Tool
An agentic tool that uses an LLM to orchestrate other tools.
Unlike a regular Tool which executes deterministic logic, an AgenticTool tool uses an LLM to decide which sub-tools to call based on a prompt.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classAgenticTool.Companion
-
Field Summary
Fields Modifier and Type Field Description private final Tool.Definitiondefinitionprivate final Tool.Metadatametadataprivate final LlmOptionsllmprivate final List<Tool>toolsprivate final Function1<AgentProcess, String>systemPromptCreatorpublic final static AgenticTool.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description AgenticTool(String name, String description)Create an agentic tool that will need to be customized to add tools (and possibly specify an LLM) to be useful. AgenticTool(Tool.Definition definition, Tool.Metadata metadata, LlmOptions llm, List<Tool> tools, Function1<AgentProcess, String> systemPromptCreator)
-
Method Summary
Modifier and Type Method Description Tool.DefinitiongetDefinition()Tool.MetadatagetMetadata()final LlmOptionsgetLlm()final List<Tool>getTools()final Function1<AgentProcess, String>getSystemPromptCreator()Tool.Resultcall(String input)Execute the tool with JSON input. final AgenticToolwithLlm(LlmOptions llm)Create a copy with different model. final AgenticToolwithParameter(Tool.Parameter parameter)final AgenticToolwithTools(Tool additionalTools)Create a copy with additional tools. final AgenticToolwithSystemPrompt(String prompt)Create a copy with fixed syste prompt. final AgenticToolwithSystemPromptCreator(Function1<AgentProcess, String> promptCreator)final AgenticToolwithToolObject(Object toolObject)Create a copy with tools extracted from an object with @LlmTool methods. final AgenticToolwithToolObjects(Object toolObjects)Create a copy with tools extracted from multiple objects with @LlmTool methods. -
-
Constructor Detail
-
AgenticTool
AgenticTool(String name, String description)
Create an agentic tool that will need to be customized to add tools (and possibly specify an LLM) to be useful.
-
AgenticTool
AgenticTool(Tool.Definition definition, Tool.Metadata metadata, LlmOptions llm, List<Tool> tools, Function1<AgentProcess, String> systemPromptCreator)
- Parameters:
definition- Tool definition (name, description, input schema)metadata- Optional tool metadatallm- Llm to use for orchestrationtools- Sub-tools available for the LLM to orchestratesystemPromptCreator- Create prompt for the LLM to use.
-
-
Method Detail
-
getDefinition
Tool.Definition getDefinition()
-
getMetadata
Tool.Metadata getMetadata()
-
getLlm
final LlmOptions getLlm()
-
getSystemPromptCreator
final Function1<AgentProcess, String> getSystemPromptCreator()
-
call
Tool.Result call(String input)
Execute the tool with JSON input.
- Parameters:
input- JSON string matching inputSchema- Returns:
Result to send back to LLM
-
withLlm
final AgenticTool withLlm(LlmOptions llm)
Create a copy with different model.
-
withParameter
final AgenticTool withParameter(Tool.Parameter parameter)
-
withTools
final AgenticTool withTools(Tool additionalTools)
Create a copy with additional tools.
-
withSystemPrompt
final AgenticTool withSystemPrompt(String prompt)
Create a copy with fixed syste prompt. The system prompt describes the supervisor behavior.
-
withSystemPromptCreator
final AgenticTool withSystemPromptCreator(Function1<AgentProcess, String> promptCreator)
-
withToolObject
final AgenticTool withToolObject(Object toolObject)
Create a copy with tools extracted from an object with @LlmTool methods. If the object has no @LlmTool methods, returns this unchanged.
-
withToolObjects
final AgenticTool withToolObjects(Object toolObjects)
Create a copy with tools extracted from multiple objects with @LlmTool methods. Objects without @LlmTool methods are silently ignored.
-
-
-
-