Class JavaMethodToolResponse
java.lang.Object
uno.anahata.asi.agi.event.BasicPropertyChangeSource
uno.anahata.asi.agi.tool.spi.AbstractToolResponse<JavaMethodToolCall>
uno.anahata.asi.agi.tool.spi.java.JavaMethodToolResponse
- All Implemented Interfaces:
PropertyChangeSource, Rebindable
A rich POJO that captures the complete and final outcome of a single tool
call. This class now follows a deferred execution model and manages the
thread-local context for Java tool execution.
- Author:
- anahata-gemini-pro-2.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ThreadLocal<JavaMethodToolResponse> A thread-local storage for the currently executing Java tool response.private ThrowableThe raw exception thrown during execution, for debugging and session serialization.private AtomicBooleanGuard to ensure only one thread can execute this response at a time.Fields inherited from class BasicPropertyChangeSource
propertyChangeSupport -
Constructor Summary
ConstructorsConstructorDescriptionJavaMethodToolResponse(@NonNull JavaMethodToolCall call) Constructs a new JavaMethodToolResponse for a specific call. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()Executes the tool logic.static JavaMethodToolResponseGets the tool response associated with the current thread.voidrebind()Re-initializes the transientPropertyChangeSupportafter deserialization.static voidsetCurrent(JavaMethodToolResponse response) Sets the tool response for the current thread.voidstop()Stops the tool execution if it is currently running.Methods inherited from class AbstractToolResponse
addAttachment, addError, addError, addLog, asText, clearLogs, decline, fail, fail, getAgi, getAttachments, getExecutedArgs, getTokenCount, getToolName, removeAttachment, removeLogsIf, resetTokenCount, setErrors, setExpanded, setResult, setStatus, setThreadMethods inherited from class BasicPropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PropertyChangeSource
getPropertyChangeSupport
-
Field Details
-
current
A thread-local storage for the currently executing Java tool response. This allows tool logic to access its own context without explicit parameter passing. -
exception
The raw exception thrown during execution, for debugging and session serialization. Ignored during schema generation as it's an internal detail. -
executing
Guard to ensure only one thread can execute this response at a time.
-
-
Constructor Details
-
JavaMethodToolResponse
Constructs a new JavaMethodToolResponse for a specific call.- Parameters:
call- The originating tool call.
-
-
Method Details
-
getCurrent
Gets the tool response associated with the current thread.- Returns:
- The active tool response, or
nullif none is active.
-
setCurrent
Sets the tool response for the current thread.- Parameters:
response- The response to set, ornullto clear the context.
-
rebind
public void rebind()Re-initializes the transientPropertyChangeSupportafter deserialization.- Specified by:
rebindin interfaceRebindable- Overrides:
rebindin classAbstractToolResponse<JavaMethodToolCall>
-
execute
public void execute()Description copied from class:AbstractToolResponseExecutes the tool logic. This method is responsible for populating the status, result, errors, and executionTimeMillis fields.- Specified by:
executein classAbstractToolResponse<JavaMethodToolCall>
-
stop
public void stop()Description copied from class:AbstractToolResponseStops the tool execution if it is currently running.- Specified by:
stopin classAbstractToolResponse<JavaMethodToolCall>
-

