Skip to main content
Overview > Inworld Graph Executor Class: InworldGraphExecutor | Inherits from: MonoBehaviour Component responsible for executing Inworld AI graph assets within Unity. Manages the lifecycle of graph compilation, execution, and result handling for AI-powered workflows. Provides event-driven architecture for monitoring graph state and receiving output data.

Properties

Methods

Events

Reference

The graph executor is the independent hub of the graph engine. Assign a graph asset in editor or at runtime, then compile it to make it executable. InworldGraphExecutor Unity Component

Graph

Gets or sets the graph asset to be executed by this component. When set, clears the current compilation state and runtime objects.

Returns

Type: InworldGraphAsset

Error

Gets or sets the current error message from graph operations. When set, automatically logs the error and triggers the OnGraphError event.

Returns

Type: string

IsCompiled

Gets a value indicating whether the current graph has been successfully compiled.

Returns

Type: bool

IsExecuting

Gets a value indicating whether the graph is currently executing.

Returns

Type: bool

RuntimeGraph

Gets the runtime instance of the compiled graph. Returns null if no graph is loaded or compilation failed.

Returns

Type: InworldGraph

IsInitialized

Gets a value indicating whether the graph executor is initialized and ready for execution.

Returns

Type: bool

LoadData

Loads a new graph asset for execution, replacing the current one. Cannot be called while a graph is currently executing. Automatically clears compilation state and runtime objects.

Parameters

ParameterTypeDescription
graphAssetInworldGraphAssetThe graph asset to load for execution.

Returns

Type: void

Compile

Compiles the current graph asset into a runtime executable form. Must be called before executing the graph. Triggers OnGraphCompiled event on success or OnGraphError on failure.

Parameters

ParameterTypeDescription
compiledCompiledGraphInterfaceOptional compiled graph interface.

Returns

Type: bool Description: True if compilation succeeded, false otherwise.

ExecuteGraphAsync

Executes the compiled graph asynchronously with optional input data. The graph must be compiled before execution can begin. Supports both streaming and simplified execution modes.

Parameters

ParameterTypeDescription
executorNamestringOptional identifier for this execution instance. If empty, a GUID will be generated.
inputInworldBaseDataOptional input data to provide to the graph. If null, an empty InworldBaseData will be used.

Returns

Type: Awaitable<bool> Description: A task that completes with true if execution started successfully, false otherwise.

StopExecution

Stops the current graph execution if one is running. Closes all active executions and triggers the OnGraphFinished event.

Returns

Type: void

CleanupRuntimeObjects

Cleans up all runtime objects associated with the current graph. Resets compilation and execution state to allow for fresh graph loading.

Returns

Type: void

OnGraphCompiled

Event triggered when a graph asset has been successfully compiled and is ready for execution.

Parameters

ParameterTypeDescription
graphAssetInworldGraphAssetThe compiled graph asset.

OnGraphStarted

Event triggered when graph execution begins.

Parameters

ParameterTypeDescription
graphAssetInworldGraphAssetThe graph asset that started execution.

OnGraphResult

Event triggered when the graph produces a result during execution. Provides access to intermediate and final output data from the graph.

Parameters

ParameterTypeDescription
resultInworldBaseDataThe result data produced by the graph.

OnGraphFinished

Event triggered when graph execution completes successfully.

Parameters

ParameterTypeDescription
graphAssetInworldGraphAssetThe graph asset that finished execution.

OnGraphError

Event triggered when an error occurs during graph compilation or execution.

Parameters

ParameterTypeDescription
graphAssetInworldGraphAssetThe graph asset that encountered an error.
errorMessagestringThe error message describing what went wrong.