Skip to content

Class UTryllSubsystem

ClassList > UTryllSubsystem

More...

  • #include <TryllSubsystem.h>

Inherits the following classes: UGameInstanceSubsystem, FTickableGameObject

Classes

Type Name
struct FEmbeddedStorageInfo

Public Types

Type Name
typedef void(FEmbeddedStorageInfo, FTryllError) FTryllOnEmbeddedStorageCreated
typedef void(FTryllError) FTryllOnEmbeddedStorageDestroyed
typedef void(FTryllError) FTryllOnStringStorage

Public Attributes

Type Name
FOnTryllAgentDestroyed OnAgentDestroyed
FOnTryllConnectionChanged OnConnectionChanged
FOnTryllCreateEmbeddedStringStorage OnCreateEmbeddedStringStorageComplete
FOnTryllCreateSession OnCreateSessionComplete
FOnTryllCreateStringStorage OnCreateStringStorageComplete
FOnTryllDestroyEmbeddedStringStorage OnDestroyEmbeddedStringStorageComplete
FOnTryllDestroyStringStorage OnDestroyStringStorageComplete
FOnTryllDownloadComplete OnDownloadComplete
FOnTryllDownloadProgress OnDownloadProgress
FOnTryllError OnError
FOnTryllIntentClassified OnIntentClassified
FOnTryllListModels OnListModelsComplete
FOnTryllLoadModel OnLoadModelComplete
FOnTryllModelReady OnModelReady
FOnTryllNodeEvent OnNodeEvent
FOnTryllPaused OnPaused
FOnTryllToolCall OnToolCall
FOnTryllToolCallDetailed OnToolCallDetailed
FOnTryllToolCallWithId OnToolCallWithId
FOnTryllUnloadModel OnUnloadModelComplete
FString ServerBuildConfig
FString ServerExePath
FString ServerHost = TEXT("127.0.0.1")
int32 ServerIdleTimeoutSeconds = 0
int32 ServerPort = 9100
FString ServerRunId
FString ServerVersion
bool bServerManaged = false

Public Functions

Type Name
void BindVoiceInputClient (const TSharedPtr< FTryllVoiceInput > & Voice) const
void Connect ()
void CreateSession (ETryllInferenceEngine Engine, FString GameName=TEXT(""), ETryllInferenceEngine SttEngine=ETryllInferenceEngine::Mock, ETryllInferenceEngine TtsEngine=ETryllInferenceEngine::Mock, ETryllInferenceEngine EmbeddingEngine=ETryllInferenceEngine::Mock, FString StorageDataFolder=TEXT(""))
void CreateSessionFromSettings ()
virtual void Deinitialize () override
void Disconnect ()
TSharedPtr< FTryllAgent > FindAgent (uint64 AgentId) const
int64 GetSessionId () const
virtual TStatId GetStatId () override const
virtual ETickableTickType GetTickableTickType () override const
virtual void Initialize (FSubsystemCollectionBase & Collection) override
bool IsConnected () const
bool IsSessionReady () const
virtual bool IsTickable () override const
virtual bool IsTickableInEditor () override const
virtual bool IsTickableWhenPaused () override const
void RegisterAgent (std::uint64_t AgentId, TWeakPtr< FTryllAgent > Agent)
void RequestCreateAgent (const FTryllGraphDescription & Graph, TFunction< FTryllOnAgentCreated > OnComplete, bool bEnableDiagnostics=false, bool bMaintainDialogueHistory=true, const TArray< FTryllVariableDecl > & Variables={}, ETryllKvCacheInitialization KvCacheInitialization=ETryllKvCacheInitialization::AllocateOnly, ETryllWorkload Workload=ETryllWorkload::Interactive)
void RequestCreateEmbeddedStringStorage (const FString & Name, const FString & ConfigPath, const FString & EmbeddingModel=FString{}, TFunction< FTryllOnEmbeddedStorageCreated > OnComplete=nullptr)
void RequestCreateEmbeddedStringStorageFromStrings (const FString & Name, const TArray< FString > & Strings, const FString & EmbeddingModel, TFunction< FTryllOnEmbeddedStorageCreated > OnComplete=nullptr)
void RequestCreateStringStorage (const FString & Name, const TArray< FString > & Strings, TFunction< FTryllOnStringStorage > OnComplete=nullptr)
void RequestCreateStringStorageFromFile (const FString & Name, const FString & FilePath, uint8 Kind=0, TFunction< FTryllOnStringStorage > OnComplete=nullptr)
void RequestCreateStringStorageKeyed (const FString & Name, const TArray< FString > & Keys, const TArray< FString > & Values, uint8 Kind=1, TFunction< FTryllOnStringStorage > OnComplete=nullptr)
void RequestCreateVoiceInput (const FTryllVoiceInputConfig & Config, TFunction< FTryllOnVoiceInputCreated > OnComplete)
void RequestDestroyAgent (TSharedPtr< FTryllAgent > Agent)
void RequestDestroyEmbeddedStringStorage (const FString & Name, TFunction< FTryllOnEmbeddedStorageDestroyed > OnComplete=nullptr)
void RequestDestroyStringStorage (const FString & Name, TFunction< FTryllOnStringStorage > OnComplete=nullptr)
void RequestDestroyVoiceInput (TSharedPtr< FTryllVoiceInput > Voice)
void RequestDownloadModel (const FString & ModelName)
void RequestListModels (TFunction< FTryllOnListModels > OnComplete)
void RequestLoadModel (const FString & ModelName)
void RequestModel (const FString & ModelName)
void RequestUnloadModel (const FString & ModelName)
void SetInferenceThrottle (float Level)
TArray< FTryllRegisteredAgentSnapshot > SnapshotRegisteredAgents () const
virtual void Tick (float DeltaTime) override
void UnregisterAgent (std::uint64_t AgentId)

Public Static Functions

Type Name
TArray< EServerBuildVariant > GetAvailableServerVariants ()
FString GetServerRootDir ()
FString ResolveServerExePath (EServerBuildVariant Preferred)

Detailed Description

Game-instance subsystem: one TCP session to the Tryll server. Manages the socket connection on a background thread (FTryllConnection) and drains the event queue on Tick(), dispatching to registered agents and delegates.

Default (zero-wiring) path — driven by UTryllRuntimeSettings: * bAutoLaunchServer → spawns the bundled tryll_server.exe on Initialize. * bAutoConnect → Connect() on Initialize (connect-retry covers server startup). * bAutoCreateSession → on Connected, CreateSessionFromSettings() applies the Engine / Stt / Tts / Embedding selections from settings. UTryllAgentComponent / UTryllVoiceInputComponent then create themselves once IsSessionReady() — they queue until OnCreateSessionComplete if they spawn earlier. So the common case is: add the components, pick engines in Project Settings, press play.

Manual path — turn those flags off to drive the session yourself: * Connect() — open TCP session to ServerHost:ServerPort. * OnConnectionChanged(bConnected=true) — bind to continue; or poll IsConnected(). * CreateSession(Engine, ...) — configure explicitly (overrides settings). Completion arrives on OnCreateSessionComplete; IsSessionReady() is true thereafter. * CreateAgent — attach a UTryllAgentComponent (auto-creates once the session is ready) or call RequestCreateAgent(). * SendMessage(Text) — drive one turn; chunks on OnAnswerText, the turn ends with OnTurnComplete(Status). * RequestDestroyAgent / Disconnect — tear down when done.

All delegates fire on the game thread from Tick(); it is safe to touch UObjects and UI directly from callbacks.

Public Types Documentation

typedef FTryllOnEmbeddedStorageCreated

using UTryllSubsystem::FTryllOnEmbeddedStorageCreated = void(FEmbeddedStorageInfo, FTryllError);

typedef FTryllOnEmbeddedStorageDestroyed

using UTryllSubsystem::FTryllOnEmbeddedStorageDestroyed = void(FTryllError);

typedef FTryllOnStringStorage

using UTryllSubsystem::FTryllOnStringStorage = void(FTryllError);

Public Attributes Documentation

variable OnAgentDestroyed

FOnTryllAgentDestroyed UTryllSubsystem::OnAgentDestroyed;

variable OnConnectionChanged

FOnTryllConnectionChanged UTryllSubsystem::OnConnectionChanged;

variable OnCreateEmbeddedStringStorageComplete

FOnTryllCreateEmbeddedStringStorage UTryllSubsystem::OnCreateEmbeddedStringStorageComplete;

variable OnCreateSessionComplete

FOnTryllCreateSession UTryllSubsystem::OnCreateSessionComplete;

variable OnCreateStringStorageComplete

FOnTryllCreateStringStorage UTryllSubsystem::OnCreateStringStorageComplete;

variable OnDestroyEmbeddedStringStorageComplete

FOnTryllDestroyEmbeddedStringStorage UTryllSubsystem::OnDestroyEmbeddedStringStorageComplete;

variable OnDestroyStringStorageComplete

FOnTryllDestroyStringStorage UTryllSubsystem::OnDestroyStringStorageComplete;

variable OnDownloadComplete

FOnTryllDownloadComplete UTryllSubsystem::OnDownloadComplete;

variable OnDownloadProgress

FOnTryllDownloadProgress UTryllSubsystem::OnDownloadProgress;

variable OnError

FOnTryllError UTryllSubsystem::OnError;

variable OnIntentClassified

FOnTryllIntentClassified UTryllSubsystem::OnIntentClassified;

Broadcast when a ClassifyIntentNode emits an intent on its "found" path with notify_client enabled.


variable OnListModelsComplete

FOnTryllListModels UTryllSubsystem::OnListModelsComplete;

variable OnLoadModelComplete

FOnTryllLoadModel UTryllSubsystem::OnLoadModelComplete;

variable OnModelReady

FOnTryllModelReady UTryllSubsystem::OnModelReady;

Fired when a RequestModel sequence terminates (load succeeded, or fallback download+load succeeded, or any step failed). bSuccess is the final outcome.


variable OnNodeEvent

FOnTryllNodeEvent UTryllSubsystem::OnNodeEvent;

Broadcast for any NodeEvent whose event_type has no typed delegate (or whose typed delegate has no subscribers). Untyped fallback.


variable OnPaused

FOnTryllPaused UTryllSubsystem::OnPaused;

Broadcast when the executor pauses a turn between nodes (Pause node, or pausing ToolCall dispositions).


variable OnToolCall

FOnTryllToolCall UTryllSubsystem::OnToolCall;

Broadcast when a ToolCallNode emits a tool_call NodeEvent (notifying dispositions).


variable OnToolCallDetailed

FOnTryllToolCallDetailed UTryllSubsystem::OnToolCallDetailed;

Detailed tool-call event carrying the full owning FTryllToolCall (node + disposition).


variable OnToolCallWithId

FOnTryllToolCallWithId UTryllSubsystem::OnToolCallWithId;

Call-ID-aware tool-call event used to correlate Resume tool results.


variable OnUnloadModelComplete

FOnTryllUnloadModel UTryllSubsystem::OnUnloadModelComplete;

variable ServerBuildConfig

FString UTryllSubsystem::ServerBuildConfig;

Server build configuration ("Debug" | "Release" | "Production").


variable ServerExePath

FString UTryllSubsystem::ServerExePath;

Canonical path of the connected server executable (empty if unknown).


variable ServerHost

FString UTryllSubsystem::ServerHost;

Host name or IP address of the Tryll server. Defaults to localhost.


variable ServerIdleTimeoutSeconds

int32 UTryllSubsystem::ServerIdleTimeoutSeconds;

Server idle-shutdown grace period in seconds (0 when standalone).


variable ServerPort

int32 UTryllSubsystem::ServerPort;

TCP port the Tryll server is listening on (default: 9100).


variable ServerRunId

FString UTryllSubsystem::ServerRunId;

Per-process server run id (UUID).


variable ServerVersion

FString UTryllSubsystem::ServerVersion;

Server version string.


variable bServerManaged

bool UTryllSubsystem::bServerManaged;

True when the server runs in managed (idle-self-exit) mode.


Public Functions Documentation

function BindVoiceInputClient

void UTryllSubsystem::BindVoiceInputClient (
    const TSharedPtr< FTryllVoiceInput > & Voice
) const

function Connect

void UTryllSubsystem::Connect () 

Open a TCP session to ServerHost:ServerPort. Asynchronous — completion is reported via OnConnectionChanged(bConnected=true). Errors fire OnError. Calling Connect() while already connected is a no-op.


function CreateSession

void UTryllSubsystem::CreateSession (
    ETryllInferenceEngine Engine,
    FString GameName=TEXT(""),
    ETryllInferenceEngine SttEngine=ETryllInferenceEngine::Mock,
    ETryllInferenceEngine TtsEngine=ETryllInferenceEngine::Mock,
    ETryllInferenceEngine EmbeddingEngine=ETryllInferenceEngine::Mock,
    FString StorageDataFolder=TEXT("")
) 

Send CreateSessionRequest. Must be called after Connected and before CreateAgent. Result is delivered via OnCreateSessionComplete delegate.

Parameters:

  • Engine Inference backend to use for this session.
  • GameName Integration identifier for telemetry grouping (e.g. "tryll-roleplay-demo"). Leave empty to omit; the server defaults to "unknown" when telemetry is on. Pass UTryllRuntimeSettings::GameName to drive this from the project settings asset.
  • StorageDataFolder Project-relative storage root (e.g. UTryllRuntimeSettings::StorageDataFolder) or an absolute path. Resolved to a full path on the wire. Empty = server default storage root.

function CreateSessionFromSettings

void UTryllSubsystem::CreateSessionFromSettings () 

Configure the session from project settings (UTryllRuntimeSettings): engine selections, game name, and storage folder.

This is the "use settings" path. It runs automatically once connected when UTryllRuntimeSettings::bAutoCreateSession is true; call it yourself if you connected with that flag disabled and still want the settings-driven config. To override settings, call CreateSession() with explicit parameters instead.


function Deinitialize

virtual void UTryllSubsystem::Deinitialize () override

function Disconnect

void UTryllSubsystem::Disconnect () 

Close the active session. OnConnectionChanged(bConnected=false) fires once the socket is down.


function FindAgent

TSharedPtr< FTryllAgent > UTryllSubsystem::FindAgent (
    uint64 AgentId
) const

function GetSessionId

int64 UTryllSubsystem::GetSessionId () const

Server-assigned session id, or 0 when not connected.


function GetStatId

virtual TStatId UTryllSubsystem::GetStatId () override const

function GetTickableTickType

virtual ETickableTickType UTryllSubsystem::GetTickableTickType () override const

function Initialize

virtual void UTryllSubsystem::Initialize (
    FSubsystemCollectionBase & Collection
) override

function IsConnected

bool UTryllSubsystem::IsConnected () const

True while the background connection is in the Connected state.


function IsSessionReady

bool UTryllSubsystem::IsSessionReady () const

True once the current connection has a successfully configured session (CreateSession completed OK). Agent / VoiceInput creation must wait for this — creating against an unconfigured session is rejected by the server.


function IsTickable

virtual bool UTryllSubsystem::IsTickable () override const

function IsTickableInEditor

inline virtual bool UTryllSubsystem::IsTickableInEditor () override const

function IsTickableWhenPaused

inline virtual bool UTryllSubsystem::IsTickableWhenPaused () override const

function RegisterAgent

void UTryllSubsystem::RegisterAgent (
    std::uint64_t AgentId,
    TWeakPtr< FTryllAgent > Agent
) 

function RequestCreateAgent

void UTryllSubsystem::RequestCreateAgent (
    const FTryllGraphDescription & Graph,
    TFunction< FTryllOnAgentCreated > OnComplete,
    bool bEnableDiagnostics=false,
    bool bMaintainDialogueHistory=true,
    const TArray< FTryllVariableDecl > & Variables={},
    ETryllKvCacheInitialization KvCacheInitialization=ETryllKvCacheInitialization::AllocateOnly,
    ETryllWorkload Workload=ETryllWorkload::Interactive
) 

Begin create-agent; completion is delivered via OnComplete on the game thread.

Parameters:

  • Graph Workflow graph description to send to the server.
  • bEnableDiagnostics When true the server populates TurnComplete.debug_info.
  • bMaintainDialogueHistory When true (default) the agent keeps its full dialogue history; when false the history is discarded after each turn (stateless agent — for classification/routing/tool-picking agents).

function RequestCreateEmbeddedStringStorage

void UTryllSubsystem::RequestCreateEmbeddedStringStorage (
    const FString & Name,
    const FString & ConfigPath,
    const FString & EmbeddingModel=FString{},
    TFunction< FTryllOnEmbeddedStorageCreated > OnComplete=nullptr
) 

Create an EmbeddedStringStorage from a server-side *.fig.json. Path A: config file + optional embeddingModel override.


function RequestCreateEmbeddedStringStorageFromStrings

void UTryllSubsystem::RequestCreateEmbeddedStringStorageFromStrings (
    const FString & Name,
    const TArray< FString > & Strings,
    const FString & EmbeddingModel,
    TFunction< FTryllOnEmbeddedStorageCreated > OnComplete=nullptr
) 

Create an EmbeddedStringStorage from inline strings. Path B: requires EmbeddingModel.


function RequestCreateStringStorage

void UTryllSubsystem::RequestCreateStringStorage (
    const FString & Name,
    const TArray< FString > & Strings,
    TFunction< FTryllOnStringStorage > OnComplete=nullptr
) 

Create a named StringStorage on the server from an inline string array. Completion is broadcast via OnCreateStringStorageComplete.


function RequestCreateStringStorageFromFile

void UTryllSubsystem::RequestCreateStringStorageFromFile (
    const FString & Name,
    const FString & FilePath,
    uint8 Kind=0,
    TFunction< FTryllOnStringStorage > OnComplete=nullptr
) 

Create a named StringStorage on the server from a server-side file path.

Parameters:

  • Kind 0=List (default), 1=Map, 2=Multimap. When Kind is Map or Multimap the file must be a JSON array of {id, text} objects. Completion is broadcast via OnCreateStringStorageComplete.

function RequestCreateStringStorageKeyed

void UTryllSubsystem::RequestCreateStringStorageKeyed (
    const FString & Name,
    const TArray< FString > & Keys,
    const TArray< FString > & Values,
    uint8 Kind=1,
    TFunction< FTryllOnStringStorage > OnComplete=nullptr
) 

Create a named StringStorage on the server from inline key/value pairs.

Parameters:

  • Kind 1=Map (default; keys must be unique), 2=Multimap (duplicate keys allowed). Completion is broadcast via OnCreateStringStorageComplete.

function RequestCreateVoiceInput

void UTryllSubsystem::RequestCreateVoiceInput (
    const FTryllVoiceInputConfig & Config,
    TFunction< FTryllOnVoiceInputCreated > OnComplete
) 

Create a server-side VoiceInput (STT) handle. Completion is delivered via OnComplete on the game thread with a TSharedPtr<FTryllVoiceInput> on success.


function RequestDestroyAgent

void UTryllSubsystem::RequestDestroyAgent (
    TSharedPtr< FTryllAgent > Agent
) 

Queue destroy for the given agent.


function RequestDestroyEmbeddedStringStorage

void UTryllSubsystem::RequestDestroyEmbeddedStringStorage (
    const FString & Name,
    TFunction< FTryllOnEmbeddedStorageDestroyed > OnComplete=nullptr
) 

Destroy a named EmbeddedStringStorage on the server. Nodes that already hold the storage are unaffected.


function RequestDestroyStringStorage

void UTryllSubsystem::RequestDestroyStringStorage (
    const FString & Name,
    TFunction< FTryllOnStringStorage > OnComplete=nullptr
) 

Destroy a named StringStorage on the server. Nodes that already hold the storage are unaffected.


function RequestDestroyVoiceInput

void UTryllSubsystem::RequestDestroyVoiceInput (
    TSharedPtr< FTryllVoiceInput > Voice
) 

Queue destroy for the given VoiceInput handle.


function RequestDownloadModel

void UTryllSubsystem::RequestDownloadModel (
    const FString & ModelName
) 

Start downloading a model. Progress is broadcast via OnDownloadProgress (name, bytesDownloaded, totalBytes, percent 0–100); completion via OnDownloadComplete (name, bSuccess, errorMessage — empty on success).


function RequestListModels

void UTryllSubsystem::RequestListModels (
    TFunction< FTryllOnListModels > OnComplete
) 

List models available for the session's inference engine.


function RequestLoadModel

void UTryllSubsystem::RequestLoadModel (
    const FString & ModelName
) 

Pin a model into memory on the server (LoadAndPin). Completion is broadcast via OnLoadModelComplete.


function RequestModel

void UTryllSubsystem::RequestModel (
    const FString & ModelName
) 

Ensure a model is loaded and pinned. Tries LoadModel first; if the model is not present on disk the subsystem falls back to DownloadModel and retries the load. Single completion event: OnModelReady(name, bSuccess).


function RequestUnloadModel

void UTryllSubsystem::RequestUnloadModel (
    const FString & ModelName
) 

Demote a pinned model to on-demand and evict it if no contexts hold it. Completion is broadcast via OnUnloadModelComplete.


function SetInferenceThrottle

void UTryllSubsystem::SetInferenceThrottle (
    float Level
) 

Report how hard the server should yield the GPU back to the game (the manual inference throttle knob). Fire-and-forget: no response, no error surfaced locally. Never sent automatically — a session that never calls this runs unthrottled.

Parameters:

  • Level 0 = full speed (default), 1 = maximum yielding. Clamped server-side; out-of-range values do not fail here.

function SnapshotRegisteredAgents

TArray< FTryllRegisteredAgentSnapshot > UTryllSubsystem::SnapshotRegisteredAgents () const

function Tick

virtual void UTryllSubsystem::Tick (
    float DeltaTime
) override

function UnregisterAgent

void UTryllSubsystem::UnregisterAgent (
    std::uint64_t AgentId
) 

Public Static Functions Documentation

function GetAvailableServerVariants

static TArray< EServerBuildVariant > UTryllSubsystem::GetAvailableServerVariants () 

Variant subfolders (Default/Release) whose target resolves on disk.


function GetServerRootDir

static FString UTryllSubsystem::GetServerRootDir () 

<PluginBaseDir>/Binaries/ThirdParty/TryllServer; empty if the plugin is not found.


function ResolveServerExePath

static FString UTryllSubsystem::ResolveServerExePath (
    EServerBuildVariant Preferred
) 

Server exe to launch for Preferred; see .cpp for the editor/packaged resolution.



The documentation for this class was generated from the following file C:/_tryll/_monorepo3/tryll/clients/unreal/Source/TryllClient/Public/TryllSubsystem.h