Class FTryllAgent¶
#include <TryllAgent.h>
Inherits the following classes: TSharedFromThis< FTryllAgent >, FGCObject
Public Functions¶
| Type | Name |
|---|---|
| virtual void | AddReferencedObjects (FReferenceCollector & Collector) override |
| void | AppendInteractions (const TArray< FTryllDialogInteraction > & Interactions, TFunction< void(uint32 Count, const FTryllError &)> OnComplete=nullptr) |
| void | Cancel (ETryllCancelMode Mode=ETryllCancelMode::StopAndKeep) |
| void | ChangeLocalizedParams (const FString & NodeName, UTryllNodeParamsBase * Params, TFunction< void(const FTryllError &)> OnComplete) |
| void | ChangeParams (const FString & NodeName, UTryllNodeParamsBase * Params, TFunction< void(const FTryllError &)> OnComplete=nullptr) |
| void | ClearAfterDestroyRequest () |
| void | ClearPausedToolBatch () |
| void | DispatchError (const FTryllError & Error) const |
| void | DrainPendingLifecycleCallbacks (const FTryllError & TerminalError) |
| void | EvictKvCache (TFunction< void(const FTryllKvCacheEvictResult &, const FTryllError &)> OnComplete=nullptr) |
| void | ExportDialog (TFunction< void(const FTryllDialogSnapshot &, const FTryllError &)> OnComplete=nullptr) |
| FTryllAgent (TSharedPtr< FTryllConnection > InConnection, std::uint64_t InAgentId, const TArray< FTryllVariableDecl > & InDeclaredVariables={}) |
|
| std::uint64_t | GetAgentId () noexcept const |
| const FString & | GetDeliveryMode () const |
| const FString & | GetDisplayName () const |
| void | GetKvCacheStatus (TFunction< void(const FTryllKvCacheStatus &, const FTryllError &)> OnComplete=nullptr) |
| const FString & | GetLocalizedAssetName () const |
| UTryllNodeParamsBase * | GetNodeParamsBaseline (const FString & NodeName) const |
| TArray< FString > | GetNodeParamsBaselineNames () const |
| const FString & | GetPausedNode () const |
| virtual FString | GetReferencerName () override const |
| FName | GetTextTable () const |
| FTryllAgentVariables & | GetVariables () const |
| const TOptional< FTryllVoiceProfileData > & | GetVoice () const |
| void | HandleAnswerText (const FString & NodeName, const FString & Text, bool bIsDelta, bool bIsFinal) |
| void | HandleError (const FTryllError & Error) |
| void | HandleNodeEvent (const FTryllDecodedNodeEvent & Event, bool bSessionListenerBound) |
| void | HandleTtsAudio (const FString & NodeName, TArrayView< const int16 > Pcm) |
| void | HandleTtsAudioFormat (const FString & NodeName, uint32 SampleRate, uint16 Channels, uint16 BitsPerSample) |
| void | HandleTtsVisemes (const FString & NodeName, TArrayView< const FTryllVisemeEvent > Events) |
| void | HandleTurnComplete (ETryllTurnStatus Status, const FString & DebugInfo, int32 TokensGenerated) |
| bool | HasPausedToolBatch () const |
| void | ImportDialog (const FTryllDialogSnapshot & Snapshot, ETryllDialogCompatibility Compatibility=ETryllDialogCompatibility::Strict, TFunction< void(const FTryllDialogImportResult &, const FTryllError &)> OnComplete=nullptr) |
| bool | IsValid () noexcept const |
| void | PrefillKvCache (TFunction< void(const FTryllKvCachePrefillResult &, const FTryllError &)> OnComplete=nullptr) |
| void | RegisterTool (const FString & ToolName, FTryllToolHandler Handler) |
| void | RegisterTool (const FString & ToolName, FTryllSimpleToolHandler Handler) |
| void | RemoveInteractionsFromEnd (int32 Count, TFunction< void(uint32 RemovedCount, const FTryllError &)> OnComplete=nullptr) |
| void | Resume (const FString & ResumeNode=FString{}, TFunction< void(const FTryllError &)> OnComplete=nullptr) |
| void | ResumeWithToolResult (const FTryllToolResult & ToolResult, const FString & ResumeNode=FString{}, TFunction< void(const FTryllError &)> OnComplete=nullptr) |
| void | ResumeWithToolResults (const TArray< FTryllToolResult > & ToolResults, const FString & ResumeNode=FString{}, TFunction< void(const FTryllError &)> OnComplete=nullptr) |
| void | RetryPausedToolBatch () |
| void | SendGetVariables (TArray< FString > Names, TFunction< void(const TArray< FTryllVariableDecl > &, const FTryllError &)> OnComplete) |
| void | SendMessage (const FString & Text) |
| void | SendUpdateVariables (TArray< FTryllVariableUpdate > Updates, TFunction< void(const FTryllError &)> OnComplete, uint64 CarrierRequestId=0) |
| void | SetCreatedVoice (const TOptional< FTryllVoiceProfileData > & InVoice) |
| void | SetCreatedWithDiagnostics (bool bValue) |
| void | SetDeliveryMode (const FString & Mode, float Intensity=1.f, TFunction< void(const FTryllError &)> OnComplete=nullptr) |
| void | SetDisplayName (FString InName) |
| void | SetListenerProbe (TFunction< bool(ETryllAgentNodeEventKind)> Probe) |
| void | SetLocalizedTextContext (FName InTextTable, const FString & InAssetName) |
| void | SetLocalizedTurnEnded (TFunction< void()> Callback) |
| void | SetNodeParamsBaseline (const FString & NodeName, UTryllNodeParamsBase * Params) |
| void | SetOnAnswerText (TFunction< void(const FString &NodeName, const FString &Text, bool bIsDelta, bool bIsFinal)> Callback) |
| void | SetOnError (TFunction< void(const FTryllError &Error)> Callback) |
| void | SetOnIntentClassified (TFunction< void(const FTryllIntentClassification &Classification)> Callback) |
| void | SetOnIntentLlmClassified (TFunction< void(const FTryllIntentLlmClassification &Classification)> Callback) |
| void | SetOnNodeEvent (TFunction< void(const FString &NodeName, const FString &EventType, const TArray< FTryllNodeEventKeyValue > &KvPairs)> Callback) |
| void | SetOnPaused (TFunction< void(const FString &NodeName, const FString &PendingExit)> Callback) |
| void | SetOnToolCall (TFunction< void(const FString &ToolName, const FString &ArgumentsJson)> Callback) |
| void | SetOnToolCallEvent (TFunction< void(const FTryllToolCall &Call)> Callback) |
| void | SetOnToolCallWithId (TFunction< void(const FString &CallId, const FString &ToolName, const FString &ArgumentsJson)> Callback) |
| void | SetOnToolHandlerError (TFunction< void(const FTryllError &)> Callback) |
| void | SetOnTtsAudio (TFunction< void(const FString &NodeName, TArrayView< const int16 > Pcm)> Callback) |
| void | SetOnTtsAudioFormat (TFunction< void(const FString &NodeName, uint32 SampleRate, uint16 Channels, uint16 BitsPerSample)> Callback) |
| void | SetOnTtsVisemes (TFunction< void(const FString &NodeName, TArrayView< const FTryllVisemeEvent > Events)> Callback) |
| void | SetOnTurnComplete (TFunction< void(ETryllTurnStatus Status, const FString &DebugInfo, int32 TokensGenerated)> Callback) |
| void | SetVoice (const FTryllVoiceProfileData & Voice, TFunction< void(const FTryllError &)> OnComplete=nullptr) |
| bool | UnregisterTool (const FString & ToolName) |
| bool | WasCreatedWithDiagnostics () noexcept const |
| ~FTryllAgent () |
Detailed Description¶
Plain C++ handle for a server-side agent. Created by UTryllSubsystem after a successful CreateAgentResponse.
Ownership: typically held as TSharedPtr<FTryllAgent> by UTryllAgentComponent. Lifetime: deterministic — the owning component releases the shared_ptr; this triggers PushDestroyAgent via UTryllSubsystem::RequestDestroyAgent().
All callbacks are invoked on the game thread (from UTryllSubsystem::Tick).
Public Functions Documentation¶
function AddReferencedObjects¶
function AppendInteractions¶
void FTryllAgent::AppendInteractions (
const TArray< FTryllDialogInteraction > & Interactions,
TFunction< void(uint32 Count, const FTryllError &)> OnComplete=nullptr
)
Append scripted user/assistant interactions without running the graph. Idle-only.
function Cancel¶
Cooperatively cancel the agent's in-flight turn. The turn ends with ETryllTurnStatus::Cancelled via the OnTurnComplete callback. No-op if idle. Mode selects whether the partial interaction is kept (default) or discarded.
function ChangeLocalizedParams¶
void FTryllAgent::ChangeLocalizedParams (
const FString & NodeName,
UTryllNodeParamsBase * Params,
TFunction< void(const FTryllError &)> OnComplete
)
Internal: send params whose Text IDs are already resolved (the language-change refresh). AgentBusy is an expected reply here, so it is not observed as an error.
function ChangeParams¶
void FTryllAgent::ChangeParams (
const FString & NodeName,
UTryllNodeParamsBase * Params,
TFunction< void(const FTryllError &)> OnComplete=nullptr
)
Apply typed node parameters to a workflow node at runtime. The agent must not be processing a turn. Completion is invoked on the game thread via the OnComplete callback.
Clone-set-send idiom (C++): auto* P = UTryllNodeParamsFactory::CloneParams(AgentComp->GetNodeParamsBaseline("gen"), this); Cast<UTryllGenerateParams>(P)->SystemPrompt = TEXT("New prompt"); Agent->ChangeParams(TEXT("gen"), P);
Ticked Localized fields are resolved through the project's text provider on a copy before send (Params is not modified). An empty Text ID, no provider, or an unknown ID fails with InvalidParamValue and nothing is sent. To send your own text for such a field, untick its b<Field>Localized flag first.
function ClearAfterDestroyRequest¶
Called by UTryllSubsystem when the destroy Ack arrives; clears the local agent id.
function ClearPausedToolBatch¶
Discard the retained paused tool-call batch without resuming (terminal disconnect).
function DispatchError¶
Invoke the OnError callback (if set). Used by FTryllAgentVariables to surface an auto-flush rejection on the agent's normal error path.
function DrainPendingLifecycleCallbacks¶
Fail in-flight KV-cache lifecycle callbacks before the agent handle is cleared.
function EvictKvCache¶
void FTryllAgent::EvictKvCache (
TFunction< void(const FTryllKvCacheEvictResult &, const FTryllError &)> OnComplete=nullptr
)
Release backend KV contexts for every eligible language-model node.
function ExportDialog¶
void FTryllAgent::ExportDialog (
TFunction< void(const FTryllDialogSnapshot &, const FTryllError &)> OnComplete=nullptr
)
Export the completed dialog as an owned snapshot. Idle-only. Does not write a file.
function FTryllAgent¶
FTryllAgent::FTryllAgent (
TSharedPtr< FTryllConnection > InConnection,
std::uint64_t InAgentId,
const TArray< FTryllVariableDecl > & InDeclaredVariables={}
)
function GetAgentId¶
function GetDeliveryMode¶
Delivery mode last set successfully, or the voice's default ("" = neutral).
function GetDisplayName¶
function GetKvCacheStatus¶
void FTryllAgent::GetKvCacheStatus (
TFunction< void(const FTryllKvCacheStatus &, const FTryllError &)> OnComplete=nullptr
)
Query aggregate language-model KV-cache lifecycle state.
function GetLocalizedAssetName¶
function GetNodeParamsBaseline¶
Return a deep copy of the last authored params for the named node. Use this as the starting point for a clone-set-send mutation; structural fields are automatically propagated from the baseline.
function GetNodeParamsBaselineNames¶
Node names that have a params baseline.
function GetPausedNode¶
Name of the node this agent's turn is currently paused after, or an empty string when the turn is not paused. A non-empty value means the server is holding the turn open until Resume (or Cancel) — new messages are rejected with AgentBusy until then.
function GetReferencerName¶
function GetTextTable¶
function GetVariables¶
Local mirror of this agent's declared per-agent Variables.
function GetVoice¶
The voice this agent was created with or last set successfully; unset when it has none.
function HandleAnswerText¶
void FTryllAgent::HandleAnswerText (
const FString & NodeName,
const FString & Text,
bool bIsDelta,
bool bIsFinal
)
function HandleError¶
function HandleNodeEvent¶
void FTryllAgent::HandleNodeEvent (
const FTryllDecodedNodeEvent & Event,
bool bSessionListenerBound
)
Agent-scope half of NodeEvent dispatch. The caller has already broadcast session-level delegates. Records tool calls, fires the per-agent callbacks, then (for a pause) runs RegisterTool auto-resume.
Parameters:
bSessionListenerBoundtrue when a session-scope listener for this event's kind is bound: OnPaused for a pause, any of OnToolCall / OnToolCallWithId / OnToolCallDetailed for a tool call (subsystem Blueprint delegates, or in PIE a direct editor listener / registered listener probe). Used only to decide whether a pause is resumable. Agent-scope listeners are counted here as well.
function HandleTtsAudio¶
function HandleTtsAudioFormat¶
void FTryllAgent::HandleTtsAudioFormat (
const FString & NodeName,
uint32 SampleRate,
uint16 Channels,
uint16 BitsPerSample
)
function HandleTtsVisemes¶
void FTryllAgent::HandleTtsVisemes (
const FString & NodeName,
TArrayView< const FTryllVisemeEvent > Events
)
function HandleTurnComplete¶
void FTryllAgent::HandleTurnComplete (
ETryllTurnStatus Status,
const FString & DebugInfo,
int32 TokensGenerated
)
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. A retained batch may already have some handlers succeeded (see RetryPausedToolBatch).
function ImportDialog¶
void FTryllAgent::ImportDialog (
const FTryllDialogSnapshot & Snapshot,
ETryllDialogCompatibility Compatibility=ETryllDialogCompatibility::Strict,
TFunction< void(const FTryllDialogImportResult &, const FTryllError &)> OnComplete=nullptr
)
Replace the agent's dialog with Snapshot. Idle-only. Never appends.
function IsValid¶
function PrefillKvCache¶
void FTryllAgent::PrefillKvCache (
TFunction< void(const FTryllKvCachePrefillResult &, const FTryllError &)> OnComplete=nullptr
)
Synchronise every eligible language-model context to its reusable prefix.
function RegisterTool [1/2]¶
Register game-thread tool sugar. A paused batch auto-resumes only when every call has a handler and every handler reports success.
function RegisterTool [2/2]¶
function RemoveInteractionsFromEnd¶
void FTryllAgent::RemoveInteractionsFromEnd (
int32 Count,
TFunction< void(uint32 RemovedCount, const FTryllError &)> OnComplete=nullptr
)
Remove whole interactions from the end of the dialog. count=0 is a no-op. Idle-only.
function Resume¶
void FTryllAgent::Resume (
const FString & ResumeNode=FString{},
TFunction< void(const FTryllError &)> OnComplete=nullptr
)
Resume a turn that is currently paused (see the Pause node / typed OnNodeEvent event_type="paused" wiring on UTryllSubsystem). ResumeNode empty continues via the paused node's pending exit route; non-empty jumps to that node by name. Completion is invoked on the game thread: nullopt-equivalent (Error.IsOk()) on success, AgentNotPaused (3012) if the agent is not currently paused, or UnknownNode (3005) if ResumeNode does not name a node in the graph.
function ResumeWithToolResult¶
void FTryllAgent::ResumeWithToolResult (
const FTryllToolResult & ToolResult,
const FString & ResumeNode=FString{},
TFunction< void(const FTryllError &)> OnComplete=nullptr
)
Resume with one result correlated to a tool-call ID.
function ResumeWithToolResults¶
void FTryllAgent::ResumeWithToolResults (
const TArray< FTryllToolResult > & ToolResults,
const FString & ResumeNode=FString{},
TFunction< void(const FTryllError &)> OnComplete=nullptr
)
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 (not re-run — no duplicate side effects), remaining handlers run, and a fresh Resume is sent. No-op if there is no retained batch (HasPausedToolBatch() is false). Use after OnToolHandlerError reports a failed handler or a rejected/disconnected resume.
function SendGetVariables¶
void FTryllAgent::SendGetVariables (
TArray< FString > Names,
TFunction< void(const TArray< FTryllVariableDecl > &, const FTryllError &)> OnComplete
)
Send a GetAgentVariablesRequest. Empty Names = every declared variable.
function SendMessage¶
Send a text message to the agent. Response arrives via the OnAnswerText / OnTurnComplete callbacks.
function SendUpdateVariables¶
void FTryllAgent::SendUpdateVariables (
TArray< FTryllVariableUpdate > Updates,
TFunction< void(const FTryllError &)> OnComplete,
uint64 CarrierRequestId=0
)
Send a batched UpdateAgentVariablesRequest (deferred-flush from FTryllAgentVariables::FlushIfDirty).
function SetCreatedVoice¶
Record the voice sent at creation (called by the subsystem).
function SetCreatedWithDiagnostics¶
function SetDeliveryMode¶
void FTryllAgent::SetDeliveryMode (
const FString & Mode,
float Intensity=1.f,
TFunction< void(const FTryllError &)> OnComplete=nullptr
)
Switch the voice's delivery mode (protocol v27 SetAgentDeliveryMode). Allowed mid-turn; applies from the next sentence. "neutral" is always accepted; an unknown mode fails with UnknownDeliveryMode (3024) and the current mode stays; an agent without a voice fails with AgentVoiceRequired (3025). Intensity is clamped to 0..1 by the server; models that cannot use it ignore it.
function SetDisplayName¶
Optional editor/display label (e.g. owning actor name). Not on the wire.
function SetListenerProbe¶
When set, replaces the "callback slot is non-null" listener check. UTryllAgentComponent installs forwarders that are always non-null and a probe that reports the Blueprint delegate's real IsBound() state, so generic-fallback suppression and the unresumable-pause warning see the listeners the game actually bound.
function SetLocalizedTextContext¶
Workflow text table and asset name used to resolve ticked Text IDs in ChangeParams. Set by the subsystem when the agent is created from a graph.
function SetLocalizedTurnEnded¶
Runs before the public turn-complete callback, so a localized param update that came back AgentBusy goes out before gameplay can start the next turn. Independent of SetOnTurnComplete, which gameplay replaces.
function SetNodeParamsBaseline¶
Store/update the authored params baseline for a node (called by the subsystem).
function SetOnAnswerText¶
void FTryllAgent::SetOnAnswerText (
TFunction< void(const FString &NodeName, const FString &Text, bool bIsDelta, bool bIsFinal)> Callback
)
Streaming text callback. Matches the current AnswerText wire message: * NodeName = the workflow node that produced this chunk (multi-sender attribution; ignore it if the graph only ever has one text-producing node). * bIsDelta = true → Text is an incremental token/chunk. * bIsDelta = false → Text is the full response accumulated so far. * bIsFinal = true → This is the last AnswerText before TurnComplete for this node.
function SetOnError¶
Called on any send-side error (connection loss, server error response, etc.).
function SetOnIntentClassified¶
void FTryllAgent::SetOnIntentClassified (
TFunction< void(const FTryllIntentClassification &Classification)> Callback
)
function SetOnIntentLlmClassified¶
void FTryllAgent::SetOnIntentLlmClassified (
TFunction< void(const FTryllIntentLlmClassification &Classification)> Callback
)
function SetOnNodeEvent¶
void FTryllAgent::SetOnNodeEvent (
TFunction< void(const FString &NodeName, const FString &EventType, const TArray< FTryllNodeEventKeyValue > &KvPairs)> Callback
)
function SetOnPaused¶
void FTryllAgent::SetOnPaused (
TFunction< void(const FString &NodeName, const FString &PendingExit)> Callback
)
function SetOnToolCall¶
void FTryllAgent::SetOnToolCall (
TFunction< void(const FString &ToolName, const FString &ArgumentsJson)> Callback
)
Per-agent NodeEvent callbacks. Names match AgentProxy. No agent id: the handle is the agent. An empty callback clears the slot. SetOnToolCallEvent is the owning detailed callback (node + disposition).
function SetOnToolCallEvent¶
function SetOnToolCallWithId¶
void FTryllAgent::SetOnToolCallWithId (
TFunction< void(const FString &CallId, const FString &ToolName, const FString &ArgumentsJson)> Callback
)
function SetOnToolHandlerError¶
Set the callback invoked on the game thread when RegisterTool handler execution or its automatic result-bearing Resume fails. The turn remains paused. Mirrors the Unity client's ToolHandlerError event.
function SetOnTtsAudio¶
void FTryllAgent::SetOnTtsAudio (
TFunction< void(const FString &NodeName, TArrayView< const int16 > Pcm)> Callback
)
Streaming TTS audio callback. Fires for each TtsAudioFrame within a turn. NodeName is the producing node's name (multi-sender attribution). The view references the FTryllConnEvent storage and is valid only for the duration of the callback. End-of-stream is signalled by OnTurnComplete — TtsAudioFrame intentionally carries no is_final field.
function SetOnTtsAudioFormat¶
void FTryllAgent::SetOnTtsAudioFormat (
TFunction< void(const FString &NodeName, uint32 SampleRate, uint16 Channels, uint16 BitsPerSample)> Callback
)
TTS audio format callback. Fires once per turn, before any OnTtsAudio. Parameters: (NodeName, SampleRate, Channels, BitsPerSample). NodeName is the producing node's name (multi-sender attribution — mirrors OnAnswerText). Only mono int16 PCM is currently emitted by the server.
function SetOnTtsVisemes¶
void FTryllAgent::SetOnTtsVisemes (
TFunction< void(const FString &NodeName, TArrayView< const FTryllVisemeEvent > Events)> Callback
)
Viseme track callback. Fires once per synthesized sentence when the agent's voice has emit_visemes (FTryllVoiceProfileData::bEmitVisemes) on, after that sentence's audio. Offsets are turn-absolute samples at the rate from OnTtsAudioFormat; frames of a turn continue from one another. The view is valid only for the duration of the callback.
function SetOnTurnComplete¶
void FTryllAgent::SetOnTurnComplete (
TFunction< void(ETryllTurnStatus Status, const FString &DebugInfo, int32 TokensGenerated)> Callback
)
Called once per turn after all AnswerText chunks, carrying the turn outcome. TokensGenerated: server-reported total tokens sampled across all generation nodes in this turn (prompt tokens excluded).
function SetVoice¶
void FTryllAgent::SetVoice (
const FTryllVoiceProfileData & Voice,
TFunction< void(const FTryllError &)> OnComplete=nullptr
)
Replace the agent's voice (protocol v27 SetAgentVoice). Idle-only: AgentBusy (3004) while a turn runs, unless it is paused before resume. A profile the model cannot use fails with InvalidVoiceProfile (3023) and the old voice stays. The active delivery mode survives when the new profile defines a mode of the same name; otherwise the new profile's default mode applies. On success GetVoice() returns the new profile.
function UnregisterTool¶
Remove a previously registered tool handler.
function WasCreatedWithDiagnostics¶
function ~FTryllAgent¶
The documentation for this class was generated from the following file C:/_tryll/_monorepo3/tryll/clients/unreal/Source/TryllClient/Public/TryllAgent.h