Longbridge OpenAPI C++ SDK
Public Member Functions | Static Public Member Functions | List of all members
longbridge::agent::AgentContext Class Reference

AI Agent conversation context. More...

#include <agent_context.hpp>

Public Member Functions

 AgentContext ()
 
 AgentContext (const lb_agent_context_t *ctx)
 
 AgentContext (const AgentContext &ctx)
 
 AgentContext (AgentContext &&ctx)
 
 ~AgentContext ()
 
AgentContextoperator= (const AgentContext &ctx)
 
void workspaces (AsyncCallback< AgentContext, WorkspacesResponse > callback) const
 List the Workspaces the current account belongs to. More...
 
void agents (const std::string &workspace_id, const std::optional< GetAgentsOptions > &opts, AsyncCallback< AgentContext, AgentsResponse > callback) const
 List the Agents in the specified Workspace. More...
 
void public_agents (const std::optional< GetAgentsOptions > &opts, AsyncCallback< AgentContext, AgentsResponse > callback) const
 
void conversation (const std::string &agent_id, const std::string &query, const std::optional< std::string > &chat_uid, const std::optional< std::string > &parent_message_id, AsyncCallback< AgentContext, ConversationResponse > callback) const
 
void continue_conversation (const std::string &agent_id, const std::string &chat_uid, const std::string &message_id, const AnswersByToolCall &answers, AsyncCallback< AgentContext, ConversationResponse > callback) const
 
void conversation_streamed (const std::string &agent_id, const std::string &query, const std::optional< std::string > &chat_uid, const std::optional< std::string > &parent_message_id, PushCallback< AgentContext, ConversationStreamEvent > on_event, AsyncCallback< AgentContext, ConversationResponse > callback) const
 
void continue_conversation_streamed (const std::string &agent_id, const std::string &chat_uid, const std::string &message_id, const AnswersByToolCall &answers, PushCallback< AgentContext, ConversationStreamEvent > on_event, AsyncCallback< AgentContext, ConversationResponse > callback) const
 

Static Public Member Functions

static AgentContext create (const Config &config)
 Create an AgentContext from a Config. More...
 

Detailed Description

AI Agent conversation context.

Constructor & Destructor Documentation

◆ AgentContext() [1/4]

longbridge::agent::AgentContext::AgentContext ( )

◆ AgentContext() [2/4]

longbridge::agent::AgentContext::AgentContext ( const lb_agent_context_t ctx)

◆ AgentContext() [3/4]

longbridge::agent::AgentContext::AgentContext ( const AgentContext ctx)

◆ AgentContext() [4/4]

longbridge::agent::AgentContext::AgentContext ( AgentContext &&  ctx)

◆ ~AgentContext()

longbridge::agent::AgentContext::~AgentContext ( )

Member Function Documentation

◆ agents()

void longbridge::agent::AgentContext::agents ( const std::string &  workspace_id,
const std::optional< GetAgentsOptions > &  opts,
AsyncCallback< AgentContext, AgentsResponse callback 
) const

List the Agents in the specified Workspace.

◆ continue_conversation()

void longbridge::agent::AgentContext::continue_conversation ( const std::string &  agent_id,
const std::string &  chat_uid,
const std::string &  message_id,
const AnswersByToolCall answers,
AsyncCallback< AgentContext, ConversationResponse callback 
) const

Resume an interrupted conversation, blocking until the run succeeds, is interrupted again, or fails.

Parameters
answersAnswers keyed by tool_call_id, see AnswersByToolCall

◆ continue_conversation_streamed()

void longbridge::agent::AgentContext::continue_conversation_streamed ( const std::string &  agent_id,
const std::string &  chat_uid,
const std::string &  message_id,
const AnswersByToolCall answers,
PushCallback< AgentContext, ConversationStreamEvent on_event,
AsyncCallback< AgentContext, ConversationResponse callback 
) const

Resume an interrupted conversation, calling on_event for every run-progress event observed over SSE, then callback with the final ConversationResponse once the stream ends — same shape as conversation_streamed.

Parameters
answersAnswers keyed by tool_call_id, see AnswersByToolCall

◆ conversation()

void longbridge::agent::AgentContext::conversation ( const std::string &  agent_id,
const std::string &  query,
const std::optional< std::string > &  chat_uid,
const std::optional< std::string > &  parent_message_id,
AsyncCallback< AgentContext, ConversationResponse callback 
) const

Start a conversation with the specified Agent, blocking until the run succeeds, is interrupted, or fails.

Parameters
chat_uidExisting conversation identifier to continue within (std::nullopt to start a brand-new conversation)
parent_message_idmessage_id from a previous response, to attach a follow-up after that message. Only valid together with chat_uid and must be std::nullopt for a new conversation

◆ conversation_streamed()

void longbridge::agent::AgentContext::conversation_streamed ( const std::string &  agent_id,
const std::string &  query,
const std::optional< std::string > &  chat_uid,
const std::optional< std::string > &  parent_message_id,
PushCallback< AgentContext, ConversationStreamEvent on_event,
AsyncCallback< AgentContext, ConversationResponse callback 
) const

Start a conversation with the specified Agent, calling on_event for every run-progress event observed over SSE. A succeeded, failed, or stopped run carries its outcome in a WorkflowFinished event; an interrupted run carries it in a HumanInteractionRequired event instead — the two are never emitted for the same run. Either way, the carrying event isn't necessarily the last one seen — the server may still emit a few more housekeeping events (e.g. ChatTitleUpdated) before actually closing the connection. Once the stream truly ends, callback is invoked with the final ConversationResponse — same as conversation, just arrived at via the streamed path.

Parameters
chat_uidExisting conversation identifier to continue within (std::nullopt to start a brand-new conversation)
parent_message_idmessage_id from a previous response, to attach a follow-up after that message. Only valid together with chat_uid and must be std::nullopt for a new conversation

◆ create()

static AgentContext longbridge::agent::AgentContext::create ( const Config config)
static

Create an AgentContext from a Config.

◆ operator=()

AgentContext& longbridge::agent::AgentContext::operator= ( const AgentContext ctx)

◆ public_agents()

void longbridge::agent::AgentContext::public_agents ( const std::optional< GetAgentsOptions > &  opts,
AsyncCallback< AgentContext, AgentsResponse callback 
) const

List all publicly available Agents on the platform (the Explore catalog). Not scoped to a Workspace.

◆ workspaces()

void longbridge::agent::AgentContext::workspaces ( AsyncCallback< AgentContext, WorkspacesResponse callback) const

List the Workspaces the current account belongs to.


The documentation for this class was generated from the following file: