unreal.ToolCallAsyncResult

class unreal.ToolCallAsyncResult(outer: Object | None = None, name: Name | str = 'None')

Bases: Object

Base class for an asynchronous tool call result that is analogous to a promise.

Asynchronous tools should not use this base class directly, instead they should use an either define or use an existing derivative of this base class for asynchronous results.

Asynchronous tools return derivatives of this class to indicate a pending result. When an asynchronous tool completes its operation it should perform one of the following operations: * If successful, use MaybeBroadcastSuccessfulCompletion() from the derived class

  • ideally implemented in a method called SetValue - to notify listeners of the

OnCompleted delegate, set bIsComplete to true and set the result’s value.

  • If an error occurs, use SetError() to set the Error property, set bIsComplete to true

    and notify listeners of the OnCompleted delegate.

C++ Source:

  • Plugin: ToolsetRegistry

  • Module: ToolsetRegistry

  • File: ToolCallAsyncResult.h

Editor Properties: (see get_editor_property/set_editor_property)

  • error (str): [Read-Write] If this is an non-empty string, an error occurred while executing the tool that returned this instance. An empty string indicates either no error occurred or the associated tool call is not complete. warning: Do not set this from C++ instead use SetError() or SetValue() if implemented by the subclass.

  • is_complete (bool): [Read-Write] Whether the associated tool call is complete and the result via Value and GetValueAsJson() or Error are available to read. warning: Do not set this from C++ instead use SetError() or SetValue() if implemented by the subclass.

  • on_completed (ToolCallAsyncResultCompleted): [Read-Write] Notified when the tool call is completes successfully or with an error.

broadcast_on_completed_if_complete() bool

Broadcast to subscribers of the OnCompleted delegate if the result is already complete.

This must be called after subscribing to OnCompleted to ensure an event receives a notification when the result is already complete. note: This is thread safe, OnCompleted will always be signaled on the main thread. remark: Ideally we would override subscription methods for the OnCompleted delegate and notify subscribers there but unfortunately that isn’t possible.

Returns:

true if the result was complete, false otherwise.

Return type:

bool

property error: str

[Read-Only] If this is an non-empty string, an error occurred while executing the tool that returned this instance. An empty string indicates either no error occurred or the associated tool call is not complete. warning: Do not set this from C++ instead use SetError() or SetValue() if implemented by the subclass.

Type:

(str)

get_value_as_json_string() str

Get the JSON representation of the Value. If the associated tool call is not complete or an error occurred, this returns an empty string.

Return type:

str

property is_complete: bool

[Read-Only] Whether the associated tool call is complete and the result via Value and GetValueAsJson() or Error are available to read. warning: Do not set this from C++ instead use SetError() or SetValue() if implemented by the subclass.

Type:

(bool)

property on_completed: ToolCallAsyncResultCompleted

[Read-Write] Notified when the tool call is completes successfully or with an error.

Type:

(ToolCallAsyncResultCompleted)

set_error(error) bool

Complete this result with an error and notify listeners of OnCompleted. note: This is thread safe, the Error property will always be updated and OnCompleted will be signaled on the main thread.

Parameters:

error (str)

Returns:

true the result was completed with the error, false otherwise.

Return type:

bool