NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
neograph::acp::ACPGraphAdapter Class Reference

Map between ACP ContentBlock[] and the engine's channels. More...

#include <server.h>

Public Member Functions

virtual neograph::json build_initial_state (const std::vector< ContentBlock > &blocks, const std::string &session_id) const
 Build the initial graph state for a turn.
 
virtual neograph::json build_session_state (const std::vector< ContentBlock > &blocks, const ACPSessionContext &session) const
 What the server calls to build a turn's initial state.
 
virtual std::string extract_agent_text (const neograph::json &output) const
 Pull the agent's text reply out of the graph's final state.
 
virtual std::string extract_user_text (const std::vector< ContentBlock > &blocks) const
 Join the text of every block with single spaces: text blocks verbatim, resource_link as [name](uri), embedded resources as their text (or as a link when they carry a blob).
 
virtual std::string input_channel () const
 Channel name to write the inbound user text into (default "prompt").
 
virtual std::optional< ACPInterruptPermission > interrupt_permission (const ACPInterrupt &interrupt) const
 Present a NodeInterrupt to the user.
 
virtual neograph::json interrupt_resume_value (const ACPInterrupt &interrupt, const std::string &option_id) const
 The resume value for the option the user selected.
 
virtual std::string output_channel () const
 Channel name to read the agent's text reply from (default "response").
 

Detailed Description

Map between ACP ContentBlock[] and the engine's channels.

The default concatenates the text of every block into the input channel — text blocks verbatim, resource_link blocks as [name](uri), embedded text resources as their text — reads a string out of the output channel and sends it as one agent_message_chunk before StopReason::EndTurn.

Override to handle images/audio/embedded resources, to wire up a conversation-history channel, or to change how interrupts are presented.

Definition at line 123 of file server.h.

Member Function Documentation

◆ build_initial_state()

virtual neograph::json neograph::acp::ACPGraphAdapter::build_initial_state ( const std::vector< ContentBlock > &  blocks,
const std::string &  session_id 
) const
virtual

Build the initial graph state for a turn.

Default behaviour: writes the user text to input_channel() AND seeds the _acp_session_id channel with the active session id (so nodes can locate their session for fs/* / permission calls). Subclasses overriding this should preserve _acp_session_id if they want ACPClient calls to keep working.

◆ build_session_state()

virtual neograph::json neograph::acp::ACPGraphAdapter::build_session_state ( const std::vector< ContentBlock > &  blocks,
const ACPSessionContext &  session 
) const
virtual

What the server calls to build a turn's initial state.

The default calls build_initial_state (so existing overrides keep working) and then seeds, when the state is an object that does not set them already, _acp_cwd, _acp_additional_directories and _acp_mcp_tools. A graph that does not declare those channels ignores them.

◆ extract_agent_text()

virtual std::string neograph::acp::ACPGraphAdapter::extract_agent_text ( const neograph::json &  output) const
virtual

Pull the agent's text reply out of the graph's final state.

Default looks at channels[<output_channel()>].value, then falls back to the content of the last assistant message in channels.messages (matches ReAct examples).

◆ extract_user_text()

virtual std::string neograph::acp::ACPGraphAdapter::extract_user_text ( const std::vector< ContentBlock > &  blocks) const
virtual

Join the text of every block with single spaces: text blocks verbatim, resource_link as [name](uri), embedded resources as their text (or as a link when they carry a blob).

Image and audio blocks contribute nothing unless the adapter overrides this.

◆ interrupt_permission()

virtual std::optional< ACPInterruptPermission > neograph::acp::ACPGraphAdapter::interrupt_permission ( const ACPInterrupt &  interrupt) const
virtual

Present a NodeInterrupt to the user.

The server sends the returned request as session/request_permission in the same prompt turn and resumes the run with interrupt_resume_value() of the option the user selects. The default is a tool call titled with the interrupt reason (kind "other", status "pending", rawInput = the payload, and the interrupt under _meta["neograph/interrupt"]) with the options "approve" (allow_once) and "reject" (reject_once).

Return std::nullopt when the interrupt cannot be answered by a choice; the turn then fails with a JSON-RPC error whose data.code is NG.Interrupted.

◆ interrupt_resume_value()

virtual neograph::json neograph::acp::ACPGraphAdapter::interrupt_resume_value ( const ACPInterrupt &  interrupt,
const std::string &  option_id 
) const
virtual

The resume value for the option the user selected.

Default: the option id as a JSON string ("approve" or "reject").


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