Class UTryllAgentComponent¶
ClassList > UTryllAgentComponent
#include <TryllAgentComponent.h>
Inherits the following classes: UActorComponent
Public Attributes¶
| Type | Name |
|---|---|
| ETryllKvCacheInitialization | KvCacheInitialization = ETryllKvCacheInitialization::AllocateOnly |
| FOnTryllAgentReady | OnAgentReady |
| FOnTryllAgentAnswerFull | OnAnswerFull |
| FOnTryllAgentAnswerText | OnAnswerText |
| FOnTryllAppendInteractionsError | OnAppendInteractionsError |
| FOnTryllDialogExportedNative | OnDialogExported |
| FOnTryllDialogImportedNative | OnDialogImported |
| FOnTryllAgentError | OnError |
| FOnTryllInteractionsAppended | OnInteractionsAppended |
| FOnTryllInteractionsRemoved | OnInteractionsRemoved |
| FOnTryllKvCacheEvictError | OnKvCacheEvictError |
| FOnTryllKvCacheEvicted | OnKvCacheEvicted |
| FOnTryllKvCachePrefillError | OnKvCachePrefillError |
| FOnTryllKvCachePrefilled | OnKvCachePrefilled |
| FOnTryllKvCacheStatus | OnKvCacheStatus |
| FOnTryllKvCacheStatusError | OnKvCacheStatusError |
| FOnTryllMessageQueued | OnMessageQueued |
| FOnTryllParamChanged | OnParamChanged |
| FOnTryllRemoveInteractionsError | OnRemoveInteractionsError |
| FOnTryllResumed | OnResumed |
| FOnTryllAgentTurnComplete | OnTurnComplete |
| TObjectPtr< UTryllSpeakerComponent > | Speaker = nullptr |
| TArray< FTryllVariableOverride > | VariableOverrides |
| UTryllWorkflowAsset * | WorkflowAsset = nullptr |
| ETryllWorkload | Workload = ETryllWorkload::Interactive |
| bool | bAutoCreateOnConnect = true |
| bool | bEnableDiagnostics = false |
| bool | bMaintainDialogueHistory = true |
Public Functions¶
| Type | Name |
|---|---|
| void | AppendInteractions (const TArray< FTryllDialogInteraction > & Interactions) |
| void | Cancel (ETryllCancelMode Mode=ETryllCancelMode::StopAndKeep) |
| void | ChangeParams (const FString & NodeName, UTryllNodeParamsBase * Params) |
| void | CreateAgent () |
| void | DestroyAgent () |
| void | EvictKvCache () |
| void | ExportDialog () |
| const FTryllToolHandler * | FindToolHandler (const FString & ToolName) const |
| const TSharedPtr< FTryllAgent > & | GetAgent () const |
| int64 | GetAgentId () const |
| void | GetKvCacheStatus () |
| FTryllAgentVariables * | GetLiveVariables () |
| UTryllNodeParamsBase * | GetNodeParamsBaseline (const FString & NodeName) const |
| FString | GetPausedNode () const |
| const FString & | GetPendingMessage () const |
| UTryllAgentVariables * | GetVariables () |
| bool | HasLiveAgent () const |
| bool | HasPausedToolBatch () const |
| bool | HasPendingMessage () const |
| void | ImportDialog (const FTryllDialogSnapshot & Snapshot, ETryllDialogCompatibility Compatibility=ETryllDialogCompatibility::Strict) |
| bool | IsAgentReady () const |
| void | PrefillKvCache () |
| void | RegisterTool (const FString & ToolName, FTryllToolHandler Handler) |
| void | RegisterTool (const FString & ToolName, FTryllSimpleToolHandler Handler) |
| void | RemoveInteractionsFromEnd (int32 Count) |
| void | Resume (const FString & ResumeNode=TEXT("")) |
| void | ResumeWithToolResult (const FTryllToolResult & ToolResult, const FString & ResumeNode=TEXT("")) |
| void | ResumeWithToolResults (const TArray< FTryllToolResult > & ToolResults, const FString & ResumeNode=TEXT("")) |
| void | RetryPausedToolBatch () |
| void | SendMessage (const FString & Message) |
| bool | TryFlushPendingMessage () |
| UTryllAgentComponent () |
|
| bool | UnregisterTool (const FString & ToolName) |
Protected Functions¶
| Type | Name |
|---|---|
| virtual void | BeginPlay () override |
| virtual void | EndPlay (const EEndPlayReason::Type EndPlayReason) override |
Detailed Description¶
Actor component: manages one Tryll server-side agent. Attach to any Actor; Blueprint users bind to the delegates and call SendMessage().
The graph comes from WorkflowAsset — a designer-authored data asset in the Content Browser. CreateAgent fails if no asset is assigned. To build a graph in C++ without an asset, use FTryllGraphBuilder and UTryllSubsystem::RequestCreateAgent.
The component auto-creates an agent once the session is ready (if bAutoCreateOnConnect) — it queues until OnCreateSessionComplete if it spawns before the session is configured. It auto-destroys the agent on EndPlay.
Public Attributes Documentation¶
variable KvCacheInitialization¶
How language-model KV contexts are materialised at agent creation.
variable OnAgentReady¶
Fired once after the server confirms the agent has been created.
variable OnAnswerFull¶
Fired after TurnComplete with the full accumulated response text.
variable OnAnswerText¶
Fired for each streaming AnswerText chunk. * Text = the chunk (delta or accumulated, per server config). * bIsFinal = true on the last chunk before TurnComplete.
variable OnAppendInteractionsError¶
variable OnDialogExported¶
variable OnDialogImported¶
variable OnError¶
Fired on any agent-level error (send failure, server error response).
variable OnInteractionsAppended¶
variable OnInteractionsRemoved¶
variable OnKvCacheEvictError¶
variable OnKvCacheEvicted¶
variable OnKvCachePrefillError¶
variable OnKvCachePrefilled¶
variable OnKvCacheStatus¶
variable OnKvCacheStatusError¶
variable OnMessageQueued¶
Fired when SendMessage could not hand the message over immediately and queued it instead. Carries the queued text, so a game can show that it is waiting rather than leaving the player wondering whether their line registered.
variable OnParamChanged¶
Fired when a ChangeParam request completes. * bSuccess = true on Ack; false on any server error. * ErrorMessage = empty on success; human-readable description on failure.
variable OnRemoveInteractionsError¶
variable OnResumed¶
Fired when a Resume request completes. * bSuccess = true on Ack; false on any server error (e.g. AgentNotPaused, UnknownNode). * ErrorMessage = empty on success; human-readable description on failure.
variable OnTurnComplete¶
Fired when TurnComplete arrives, carrying the turn outcome status.
variable Speaker¶
Optional speaker component used to play streaming TTS audio frames emitted by the agent (e.g. from a GenerateAndSpeak node).
If left unset, BeginPlay will auto-discover a UTryllSpeakerComponent on the same actor (the common case — add both components to your actor and you're done). Set this explicitly when the owning actor has more than one speaker and you need to pick a specific one.
To disable TTS playback entirely: leave this unset AND have no speaker component on the actor.
variable VariableOverrides¶
Per-instance value overrides for the workflow's declared variables (Material-Instance pattern — name/type come from the declaration; only the initial value can be overridden). Entries whose Name/Type no longer match a declared variable are skipped with a warning at agent-creation time.
variable WorkflowAsset¶
Designer-authored workflow asset. Required for agent creation.
variable Workload¶
Whether a human ever waits on this agent's turns. Set Background for world-logic/evaluator agents so the inference scheduler paces or defers their work first under GPU pressure. Purely a scheduling hint.
variable bAutoCreateOnConnect¶
Automatically create the agent once the session is ready (connected + configured).
variable bEnableDiagnostics¶
Request the server to populate TurnComplete.debug_info with workflow execution data. Authoring UI retired (Package 2): Chat and Agent Log OR this on via transient override / diagnostics-demand lease. Kept for runtime/Blueprint API and asset compatibility; default remains false (zero overhead in production).
variable bMaintainDialogueHistory¶
When true (default) the agent keeps its full dialogue history across turns. When false the history is discarded after each turn — a stateless agent, useful for technical/classification agents that should not store or project prior turns.
Public Functions Documentation¶
function AppendInteractions¶
void UTryllAgentComponent::AppendInteractions (
const TArray< FTryllDialogInteraction > & Interactions
)
Append scripted user/assistant interactions without running the graph.
function Cancel¶
Cooperatively cancel the in-flight turn. The turn ends with ETryllTurnStatus::Cancelled via OnTurnComplete. No-op if idle or the agent is not ready. Mode selects whether the partial interaction is kept (StopAndKeep, the chat "Stop" button) or discarded (StopAndDiscard).
function ChangeParams¶
Mutate a named parameter on a workflow node at runtime. The agent must not be processing a turn. On completion (success or error), OnParamChanged fires.
Use the clone-set-send idiom: auto* P = Cast<UTryllGenerateParams>(GetNodeParamsBaseline("gen")); auto* Mut = Cast<UTryllGenerateParams>(UTryllNodeParamsFactory::CloneParams(P, this)); Mut->SystemPrompt = TEXT("New prompt"); ChangeParams(TEXT("gen"), Mut);
Parameters:
NodeNameInstance name of the target node in the graph.ParamsFully specified typed params for the node (clone of baseline + edits).
function CreateAgent¶
Request creation of a server-side agent from WorkflowAsset. Fires OnAgentReady on success; OnError on failure (including when no WorkflowAsset is assigned). Safe to call from Blueprint Begin Play.
function DestroyAgent¶
Request destruction of the current server-side agent. OnAgentDestroyed (on the subsystem) fires on completion.
function EvictKvCache¶
Release every eligible language-model backend KV context.
function ExportDialog¶
Export the completed dialog. C++ only — snapshot is not Blueprint-exposed.
function FindToolHandler¶
Look up a registered tool handler without going through an agent, or nullptr when this component has none for that name. Lets an external driver that runs its own agent — the Dialog Lab — invoke the same game-side handler this component would have used, instead of simulating it with authored data.
A handler that keeps per-conversation state must be told when the dialogue restarts, and such a driver's agent is not this component's, so none of the delegates here fire for it. The convention is a parameterless UFUNCTION() named ResetToolState on the handler's component, which the driver dispatches by name. In-game and Chat-panel callers need nothing extra: the handler binds OnAgentReady and OnInteractionsRemoved itself.
The returned pointer is owned by this component's handler map and is invalidated by RegisterTool / UnregisterTool. Call it, do not store it.
function GetAgent¶
Native access to the underlying agent, for C++ callers that need per-call callbacks the Blueprint event surface cannot express — a KV-residency policy managing several agents, for instance, needs to know which prefill finished. Not a UFUNCTION: TSharedPtr is not a Blueprint type. Mirrors the public Agent property on the Unity component.
May be null before creation completes; check IsAgentReady() first.
function GetAgentId¶
Server-assigned agent id, or 0 if the agent has not been created yet.
function GetKvCacheStatus¶
Query aggregate language-model KV-cache lifecycle state.
function GetLiveVariables¶
C++ access to the live variables mirror: the PIE agent when ready, otherwise an editor-preview agent attached by Tryll Chat (if any). Null when neither is active. Used by Details customization for live override apply / Flush Now.
function GetNodeParamsBaseline¶
UTryllNodeParamsBase * UTryllAgentComponent::GetNodeParamsBaseline (
const FString & NodeName
) const
Return the authored params baseline for the named node. Call after OnAgentReady has fired; returns null if the node name is unknown.
function GetPausedNode¶
Name of the node this agent's turn is paused after, or an empty string when it is not paused. Non-empty means the server is holding the turn open until Resume (or Cancel) — Send Message will keep failing with AgentBusy until one of those arrives. Covers Pause nodes as well as pausing tool calls, unlike Has Paused Tool Batch.
function GetPendingMessage¶
The queued message, or empty. For a "waiting to send" indicator.
function GetVariables¶
Blueprint/C++ access to this agent's declared per-agent Variables, or nullptr if no agent is ready. Use to Set/Get/AddToSet/RemoveFromSet/Reset declared variables from Blueprint or C++ — see UTryllAgentVariables. (C++ code that needs the raw mirror can use the agent's own FTryllAgent::GetVariables().)
function HasLiveAgent¶
True when a PIE agent or editor-preview agent is available for live variable edits.
function HasPausedToolBatch¶
True while a paused tool-call batch is retained: surfaced by the current pause and not yet cleared by a successful resume Ack, turn end/cancel, destroy, or a terminal disconnect. False when no agent is ready.
function HasPendingMessage¶
True while a message is waiting for the agent to become available.
function ImportDialog¶
void UTryllAgentComponent::ImportDialog (
const FTryllDialogSnapshot & Snapshot,
ETryllDialogCompatibility Compatibility=ETryllDialogCompatibility::Strict
)
Replace the agent's dialog. C++ only — snapshot is not Blueprint-exposed.
function IsAgentReady¶
True after the server has confirmed agent creation (OnAgentReady has fired).
function PrefillKvCache¶
Synchronise every eligible language-model context to its reusable prefix.
function RegisterTool [1/2]¶
Register native game-thread auto-resume sugar for a named tool.
function RegisterTool [2/2]¶
void UTryllAgentComponent::RegisterTool (
const FString & ToolName,
FTryllSimpleToolHandler Handler
)
function RemoveInteractionsFromEnd¶
Remove whole interactions from the end of the dialog.
function Resume¶
Resume a turn that is currently paused (see the subsystem's OnPaused event, fired for the Pause node / pausing ToolCall dispositions). On completion (success or error), OnResumed fires.
Parameters:
ResumeNodeEmpty continues via the paused node's pending exit route; non-empty jumps to that node by name.
function ResumeWithToolResult¶
void UTryllAgentComponent::ResumeWithToolResult (
const FTryllToolResult & ToolResult,
const FString & ResumeNode=TEXT("")
)
Resume with one result correlated to a tool-call ID.
function ResumeWithToolResults¶
void UTryllAgentComponent::ResumeWithToolResults (
const TArray< FTryllToolResult > & ToolResults,
const FString & ResumeNode=TEXT("")
)
Resume with the complete result batch for one paused tool-call pass.
function RetryPausedToolBatch¶
Re-attempt the retained paused tool-call batch: handlers that already produced a result on a previous attempt are skipped, remaining handlers run, and a fresh Resume is sent. No-op when no agent is ready or there is no retained batch.
function SendMessage¶
Send a user-turn message to the agent. Streaming tokens arrive on OnAnswerText; the turn ends with OnTurnComplete + OnAnswerFull. No-op if the agent is not yet ready (IsAgentReady() == false).
The message is queued, not dropped, when the agent exists but cannot accept it yet. An agent refuses a send with AgentBusy while a turn is running or a KV-cache operation is in flight — and a cache operation is exactly what happens when a game prefills the agent the player has just selected. Without queueing, a message typed during that window is silently lost and the player must retype it, which is the worst available outcome. The queue is flushed automatically when the agent becomes ready, when a turn completes, and when a cache operation finishes.
Only the most recent message is held: if two are sent before either reaches the agent, the newer line is the one the player meant. OnMessageQueued fires when a send is deferred.
function TryFlushPendingMessage¶
Hands the queued message to the agent if it can accept one now. Safe and cheap to call repeatedly; returns true only when a message was actually handed over.
Called automatically on agent-ready, turn-complete and cache-operation-complete. It is public because a KV-residency policy that drives prefills through FTryllAgent directly — rather than through this component — closes a busy window this component never observed, and should nudge the queue when it does.
function UTryllAgentComponent¶
function UnregisterTool¶
Remove a previously registered native tool handler.
Protected Functions Documentation¶
function BeginPlay¶
function EndPlay¶
The documentation for this class was generated from the following file C:/_tryll/_monorepo3/tryll/clients/unreal/Source/TryllClient/Public/TryllAgentComponent.h