Package com.axelor.ai.tool
Interface ToolExecutor
- All Known Implementing Classes:
NoOpToolExecutor
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Executes a tool by name and returns the result.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordOne call of a tool: its id in the conversation and, when it carries on after a confirmation it asked for (ToolResult.PendingConfirmation), the user's answer.static enumWhether a tool must run inside the loop's JPA transaction, or outside it (e.g. -
Method Summary
Modifier and TypeMethodDescriptionInvokes the named tool with the given input.default ToolResultexecute(String toolName, Object input, boolean approvalGranted, ToolExecutor.Call call) Invokes the named tool for one identified call.default ToolExecutor.ToolExecutionModeexecutionMode(String toolName) Execution mode for a tool.default StringresolveToolTitle(String toolCode, Object input) What to call one call of a tool, ornullwhen the tool is unknown.
-
Method Details
-
execute
Invokes the named tool with the given input.- Parameters:
toolName- the tool to invoke (matches the name from the LLM's tool call)input- the parsed tool input (typically aMap)approvalGranted-trueif the user has already approved execution of this tool (bypasses the approval check);falsefor normal execution that may returnToolResult.PendingApproval- Returns:
- success with output, or error with message — never
null
-
execute
default ToolResult execute(String toolName, Object input, boolean approvalGranted, ToolExecutor.Call call) Invokes the named tool for one identified call. Decorators must forward it; the default drops the call, which is right only for executors that never run a tool that asks for confirmation. -
resolveToolTitle
What to call one call of a tool, ornullwhen the tool is unknown.The call's own input is passed because one call of a tool is not like the next: a tool that takes one record or several can only be named accurately once it knows which it was handed. The tool decides; the configured name is what it decides from, and what stands when it has nothing to add.
The default implementation returns
null. Override in decorator plugins that have access to tool metadata. -
executionMode
Execution mode for a tool. Default isToolExecutor.ToolExecutionMode.TRANSACTIONAL; decorators override for tools whose work is an external network call that must not hold a DB connection.
-