Skip to content

Class Tryll::AgentProxy

ClassList > Tryll > AgentProxy

Client-side handle for one server-side agent. More...

  • #include <AgentProxy.h>

Public Types

Type Name
typedef std::function< void(std::string_view toolName, std::string_view argumentsJson)> ToolCallCallback
Callback type for tool-call notifications.

Public Functions

Type Name
AgentProxy () = default
void ChangeParam (std::string_view nodeName, std::string_view paramName, std::string_view paramValue)
Blocking convenience wrapper over ChangeParamAsync .
std::future< void > ChangeParamAsync (std::string_view nodeName, std::string_view paramName, std::string_view paramValue)
Mutate a named parameter on a workflow node asynchronously.
void Destroy ()
Blocking convenience wrapper over DestroyAsync .
std::future< void > DestroyAsync ()
Request agent destruction on the server asynchronously.
std::uint64_t GetAgentId () noexcept const
Server-assigned agent identifier.
void SendText (std::string_view text, std::function< void(std::string_view text, bool isDelta, bool isFinal)> onAnswerText={})
Blocking convenience wrapper over SendTextAsync .
std::future< void > SendTextAsync (std::string_view text, std::function< void(std::string_view text, bool isDelta, bool isFinal)> onAnswerText={})
Send a text message to the agent asynchronously.
void SetOnToolCall (ToolCallCallback cb)
Register a callback to be invoked on each tool-call notification.

Detailed Description

Obtained from TryllClient::CreateAgent. The proxy is copyable — all copies share the same underlying agent binding; the server-side agent is destroyed when Destroy is called explicitly.

Public Types Documentation

typedef ToolCallCallback

Callback type for tool-call notifications.

using Tryll::AgentProxy::ToolCallCallback = 
std::function<void(std::string_view toolName, std::string_view argumentsJson)>;

Invoked on the reader thread for each ToolCallNotification received from the server (i.e. when the agent's graph has a ToolCall node with notify_client = "true").

Parameters: * toolName — the tool the model asked to call. * argumentsJson — compact JSON object of arguments, e.g. {"city":"Berlin"}.

Keep the callback short and non-blocking (same contract as the onAnswerText streaming callback on SendTextAsync).


Public Functions Documentation

function AgentProxy [1/2]

Tryll::AgentProxy::AgentProxy () = default

function ChangeParam

Blocking convenience wrapper over ChangeParamAsync .

void Tryll::AgentProxy::ChangeParam (
    std::string_view nodeName,
    std::string_view paramName,
    std::string_view paramValue
) 

Exception:

  • TryllError On server-reported errors or disconnect.

function ChangeParamAsync

Mutate a named parameter on a workflow node asynchronously.

std::future< void > Tryll::AgentProxy::ChangeParamAsync (
    std::string_view nodeName,
    std::string_view paramName,
    std::string_view paramValue
) 

The agent must not be processing a turn; if it is, the returned future completes with a TryllError carrying error code AgentBusy (3004).

Parameters:

  • nodeName Instance name of the target node (as declared in the graph).
  • paramName Parameter key to set.
  • paramValue New value as a string.

Returns:

Future completing on Ack. Throws TryllError on any server-reported error (UnknownNode 3005, ParamNotMutable 3006, InvalidParamValue 3007, or AgentBusy 3004).


function Destroy

Blocking convenience wrapper over DestroyAsync .

void Tryll::AgentProxy::Destroy () 

Exception:

  • TryllError On server-reported errors, disconnect, or timeout (configured by the owning client).

function DestroyAsync

Request agent destruction on the server asynchronously.

std::future< void > Tryll::AgentProxy::DestroyAsync () 

The proxy becomes inert once the returned future completes; further SendText calls fail with TryllError.

Returns:

Future completing when the server acknowledges destruction.


function GetAgentId

Server-assigned agent identifier.

inline std::uint64_t Tryll::AgentProxy::GetAgentId () noexcept const

Returns:

The agent_id field from the original CreateAgentResponse.


function SendText

Blocking convenience wrapper over SendTextAsync .

void Tryll::AgentProxy::SendText (
    std::string_view text,
    std::function< void(std::string_view text, bool isDelta, bool isFinal)> onAnswerText={}
) 

Parameters:

  • text User-turn text to send.
  • onAnswerText Optional streaming callback; see SendTextAsync.

Exception:

  • TryllError On server-reported errors or disconnect.

function SendTextAsync

Send a text message to the agent asynchronously.

std::future< void > Tryll::AgentProxy::SendTextAsync (
    std::string_view text,
    std::function< void(std::string_view text, bool isDelta, bool isFinal)> onAnswerText={}
) 

The returned future completes (with void) when TurnComplete arrives. Any streaming AnswerText frames received before TurnComplete are dispatched to onAnswerText on the reader thread; keep the callback short and non-blocking.

Parameters:

  • text User-turn text to send.
  • onAnswerText Optional streaming callback invoked with (chunk, isDelta, isFinal) for each streamed chunk. Ignored when empty.

Returns:

Future completing when the turn finishes. Calling future::get() propagates any TryllError reported by the server or raised locally on disconnect.

Exception:

  • TryllError Only via the returned future; never directly.

function SetOnToolCall

Register a callback to be invoked on each tool-call notification.

void Tryll::AgentProxy::SetOnToolCall (
    ToolCallCallback cb
) 

Replaces any previously set callback. Pass an empty (default- constructed) ToolCallCallback to unregister.

The callback fires on the reader thread for every ToolCallNotification frame the server sends for this agent. It must return quickly and must not call any blocking TryllClient or AgentProxy methods.

Parameters:

  • cb Callable to invoke with ``(toolName, argumentsJson), or empty to clear the current callback.


The documentation for this class was generated from the following file C:/_tryll/_monorepo/server/client-cpp/include/tryll/AgentProxy.h