Class JavaMethodTool
java.lang.Object
uno.anahata.asi.agi.event.BasicPropertyChangeSource
uno.anahata.asi.agi.tool.spi.AbstractTool<JavaMethodToolParameter, JavaMethodToolCall>
uno.anahata.asi.agi.tool.spi.java.JavaMethodTool
- All Implemented Interfaces:
PropertyChangeSource, Rebindable
A model-agnostic, stateful representation of a single Java method tool. This
is a self-contained, executable unit that encapsulates both the definition of
the tool and the logic required to invoke it via reflection.
- Author:
- anahata-gemini-pro-2.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NonNull StringThe full Java method signature.private MethodThe underlying Java method that this tool represents.private StringThe raw JSON schema of the method's return type only.private StringThe fully wrapped JSON schema (including JavaMethodToolResponse structure).Fields inherited from class AbstractTool
description, name, permission, responseJsonSchema, toolkitFields inherited from class BasicPropertyChangeSource
propertyChangeSupport -
Constructor Summary
ConstructorsConstructorDescriptionJavaMethodTool(JavaObjectToolkit toolkit, Method method, AgiTool toolAnnotation) The definitive, intelligent constructor for creating a JavaMethodTool from a reflection Method. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringBuilds a human-readable string representation of a Java method's signature.createCall(AbstractModelMessage modelMessage, String id, Map<String, Object> jsonArgs) Factory method to create a tool-specific call object from raw model data.Returns a rich, formatted description string containing the base description, current permission status, and effective max depth details.Dynamically returns either the wrapped or raw schema based on thewrapResponseSchemasflag in theToolManager.Template method hook for subclasses to provide their specific Response type.Retrieves the instance of the toolkit class from the parent toolkit.private final voidinitAttributes(AgiTool toolAnnotation) Initializes the maxDepth and description attributes.private voidInitializes and populates the parameter list for this tool.voidPerforms post-restoration logic, warming up the reflection method and parameters.voidRefreshes the cached schemas for this tool.Methods inherited from class AbstractTool
getEffectiveMaxDepth, getSelectedModel, getTokenCount, resetTokenCount, setPermissionMethods inherited from class BasicPropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, rebind, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PropertyChangeSource
getPropertyChangeSupport
-
Field Details
-
javaMethodSignature
The full Java method signature. -
method
The underlying Java method that this tool represents. Transient as Method is not serializable. -
wrappedResponseJsonSchema
The fully wrapped JSON schema (including JavaMethodToolResponse structure). -
rawResponseJsonSchema
The raw JSON schema of the method's return type only.
-
-
Constructor Details
-
JavaMethodTool
public JavaMethodTool(JavaObjectToolkit toolkit, Method method, AgiTool toolAnnotation) throws Exception The definitive, intelligent constructor for creating a JavaMethodTool from a reflection Method. This constructor encapsulates all the logic for parsing annotations and generating schemas.- Parameters:
toolkit- The parent toolkit.method- The reflection Method to parse.toolAnnotation- The pre-fetched @AgiTool annotation.- Throws:
Exception- if schema generation fails.
-
-
Method Details
-
initAttributes
Initializes the maxDepth and description attributes.- Parameters:
toolAnnotation- The source @AgiTool annotation containing metadata.
-
refreshSchema
-
getResponseJsonSchema
Dynamically returns either the wrapped or raw schema based on thewrapResponseSchemasflag in theToolManager.- Returns:
- The JSON schema string.
-
getToolkitInstance
Retrieves the instance of the toolkit class from the parent toolkit.- Returns:
- The toolkit instance.
-
postActivate
Performs post-restoration logic, warming up the reflection method and parameters. This is called during the session binding phase to ensure the tool is ready before the UI or AI processing begins.- Throws:
Exception- if method restoration or parameter initialization fails.
-
initParameters
-
getDescription
Returns a rich, formatted description string containing the base description, current permission status, and effective max depth details.- Returns:
- The formatted tool description.
-
buildMethodSignature
-
createCall
public JavaMethodToolCall createCall(AbstractModelMessage modelMessage, String id, Map<String, Object> jsonArgs) Description copied from class:AbstractToolFactory method to create a tool-specific call object from raw model data.- Specified by:
createCallin classAbstractTool<JavaMethodToolParameter, JavaMethodToolCall>- Parameters:
modelMessage- the model message the call will belong to.id- The call ID.jsonArgs- The raw arguments from the model.- Returns:
- A new tool call instance.
-
getResponseType
Description copied from class:AbstractToolTemplate method hook for subclasses to provide their specific Response type.- Specified by:
getResponseTypein classAbstractTool<JavaMethodToolParameter, JavaMethodToolCall>- Returns:
- The reflection Type of the corresponding AbstractToolResponse subclass.
-

