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 | 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 & | GetDisplayName () const |
| void | GetKvCacheStatus (TFunction< void(const FTryllKvCacheStatus &, const FTryllError &)> OnComplete=nullptr) |
| UTryllNodeParamsBase * | GetNodeParamsBaseline (const FString & NodeName) const |
| const FString & | GetPausedNode () const |
| virtual FString | GetReferencerName () override const |
| FTryllAgentVariables & | GetVariables () const |
| void | HandleAnswerText (const FString & NodeName, const FString & Text, bool bIsDelta, bool bIsFinal) |
| void | HandleAppendInteractionsResult (std::uint64_t RequestId, uint32 Count, const FTryllError & Error) |
| void | HandleChangeParamResult (std::uint64_t RequestId, const FTryllError & Error) |
| void | HandleError (const FTryllError & Error) |
| void | HandleEvictKvCacheResult (std::uint64_t RequestId, const FTryllKvCacheEvictResult & Result, const FTryllError & Error) |
| void | HandleExportDialogResult (std::uint64_t RequestId, const FTryllDialogSnapshot & Snapshot, const FTryllError & Error) |
| void | HandleGetVariablesResult (std::uint64_t RequestId, const TArray< FTryllVariableDecl > & Variables, const FTryllError & Error) |
| void | HandleImportDialogResult (std::uint64_t RequestId, const FTryllDialogImportResult & Result, const FTryllError & Error) |
| void | HandleKvCacheStatusResult (std::uint64_t RequestId, const FTryllKvCacheStatus & Result, const FTryllError & Error) |
| void | HandlePaused (const FString & NodeName, bool bExternalListenerBound) |
| void | HandlePrefillKvCacheResult (std::uint64_t RequestId, const FTryllKvCachePrefillResult & Result, const FTryllError & Error) |
| void | HandleRemoveInteractionsFromEndResult (std::uint64_t RequestId, uint32 Count, const FTryllError & Error) |
| void | HandleResumeResult (std::uint64_t RequestId, const FTryllError & Error) |
| void | HandleToolCall (const FString & CallId, const FString & NodeName, const FString & ToolName, const FString & ArgumentsJson, const FString & Disposition={}) |
| void | HandleTtsAudio (const FString & NodeName, TArrayView< const int16 > Pcm) |
| void | HandleTtsAudioFormat (const FString & NodeName, uint32 SampleRate, uint16 Channels, uint16 BitsPerSample) |
| void | HandleTurnComplete (ETryllTurnStatus Status, const FString & DebugInfo, int32 TokensGenerated) |
| void | HandleUpdateVariablesResult (std::uint64_t RequestId, const FTryllError & Error) |
| 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 | SetCreatedWithDiagnostics (bool bValue) |
| void | SetDisplayName (FString InName) |
| 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 | 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 | SetOnTurnComplete (TFunction< void(ETryllTurnStatus Status, const FString &DebugInfo, int32 TokensGenerated)> Callback) |
| 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 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);
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 GetDisplayName¶
function GetKvCacheStatus¶
void FTryllAgent::GetKvCacheStatus (
TFunction< void(const FTryllKvCacheStatus &, const FTryllError &)> OnComplete=nullptr
)
Query aggregate language-model KV-cache lifecycle state.
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 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 GetVariables¶
Local mirror of this agent's declared per-agent Variables.
function HandleAnswerText¶
void FTryllAgent::HandleAnswerText (
const FString & NodeName,
const FString & Text,
bool bIsDelta,
bool bIsFinal
)
function HandleAppendInteractionsResult¶
void FTryllAgent::HandleAppendInteractionsResult (
std::uint64_t RequestId,
uint32 Count,
const FTryllError & Error
)
function HandleChangeParamResult¶
Invoked by UTryllSubsystem when a ChangeParamOk or ChangeParamErr arrives.
function HandleError¶
function HandleEvictKvCacheResult¶
void FTryllAgent::HandleEvictKvCacheResult (
std::uint64_t RequestId,
const FTryllKvCacheEvictResult & Result,
const FTryllError & Error
)
function HandleExportDialogResult¶
void FTryllAgent::HandleExportDialogResult (
std::uint64_t RequestId,
const FTryllDialogSnapshot & Snapshot,
const FTryllError & Error
)
function HandleGetVariablesResult¶
void FTryllAgent::HandleGetVariablesResult (
std::uint64_t RequestId,
const TArray< FTryllVariableDecl > & Variables,
const FTryllError & Error
)
Invoked by UTryllSubsystem when a GetVariablesOk or GetVariablesErr arrives.
function HandleImportDialogResult¶
void FTryllAgent::HandleImportDialogResult (
std::uint64_t RequestId,
const FTryllDialogImportResult & Result,
const FTryllError & Error
)
function HandleKvCacheStatusResult¶
void FTryllAgent::HandleKvCacheStatusResult (
std::uint64_t RequestId,
const FTryllKvCacheStatus & Result,
const FTryllError & Error
)
function HandlePaused¶
Parameters:
NodeNamenode the turn is parked after.bExternalListenerBoundtrue when a client delegate (the subsystem's OnPaused) is listening, so a pause that this agent cannot auto-resume may still be resumed by game code. When false and no registered tool handler covers the batch, nothing can resume the turn and a warning is logged.
function HandlePrefillKvCacheResult¶
void FTryllAgent::HandlePrefillKvCacheResult (
std::uint64_t RequestId,
const FTryllKvCachePrefillResult & Result,
const FTryllError & Error
)
Invoked by UTryllSubsystem when a KV-cache lifecycle response arrives.
function HandleRemoveInteractionsFromEndResult¶
void FTryllAgent::HandleRemoveInteractionsFromEndResult (
std::uint64_t RequestId,
uint32 Count,
const FTryllError & Error
)
function HandleResumeResult¶
Invoked by UTryllSubsystem when a ResumeOk or ResumeErr arrives.
function HandleToolCall¶
void FTryllAgent::HandleToolCall (
const FString & CallId,
const FString & NodeName,
const FString & ToolName,
const FString & ArgumentsJson,
const FString & Disposition={}
)
function HandleTtsAudio¶
function HandleTtsAudioFormat¶
void FTryllAgent::HandleTtsAudioFormat (
const FString & NodeName,
uint32 SampleRate,
uint16 Channels,
uint16 BitsPerSample
)
function HandleTurnComplete¶
void FTryllAgent::HandleTurnComplete (
ETryllTurnStatus Status,
const FString & DebugInfo,
int32 TokensGenerated
)
function HandleUpdateVariablesResult¶
void FTryllAgent::HandleUpdateVariablesResult (
std::uint64_t RequestId,
const FTryllError & Error
)
Invoked by UTryllSubsystem when an UpdateVariablesOk or UpdateVariablesErr arrives.
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 SetCreatedWithDiagnostics¶
function SetDisplayName¶
Optional editor/display label (e.g. owning actor name). Not on the wire.
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 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 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 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