|
NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
|
Abstract base class for all graph nodes. More...
#include <node.h>
Public Member Functions | |
| virtual std::string | get_name () const =0 |
| Get the node's unique name within the graph. | |
| virtual asio::awaitable< NodeOutput > | run (NodeInput in)=0 |
| Unified dispatch entry for sync work, async work, and streaming. | |
Abstract base class for all graph nodes.
Nodes are the building blocks of the graph. Each node reads from the graph state and produces channel writes (and optionally Command or Send directives). Override run(NodeInput) for every node shape.
Node instances are owned by the GraphEngine and shared across all concurrent run() invocations on that engine — including runs with different thread_ids. Implementations MUST therefore be either stateless (the recommended default — derive everything from the GraphState argument) or fully self-synchronized. Storing per-run scratch data in a member variable will silently corrupt parallel runs.
Per-execution state belongs in the channels: read inputs from state.get(...) and emit outputs as ChannelWrites.
|
pure virtual |
Get the node's unique name within the graph.
Implemented in neograph::graph::SyncGraphNode, neograph::a2a::A2ACallerNode, neograph::a2a::CopyNinjaNode, neograph::graph::LLMCallNode, neograph::graph::ToolDispatchNode, neograph::graph::IntentClassifierNode, and neograph::graph::SubgraphNode.
|
pure virtual |
Unified dispatch entry for sync work, async work, and streaming.
New nodes override THIS method. Read in.state for channel inputs, read in.ctx for available per-run metadata (cancel token, thread ID, current step, …), check in.stream_cb for an optional LLM_TOKEN sink, and return a NodeOutput (alias for NodeResult) populated with channel writes plus optional Command / Send directives.
The engine (NodeExecutor::execute_node_with_retry_async) dispatches only through this method. Sync-vs-async is no longer a public virtual cross-product: perform immediate work before co_return, or co_await asynchronous dependencies.
NodeInput and NodeOutput above.Lifetime note: in is taken by value so the coroutine frame owns its own copy of the struct. The state / ctx references inside still point to objects on the engine's suspended-frame stack (which outlive the run by construction), but the struct itself is no longer a reference parameter. The coroutine-reference-parameter UAF fixed in the v0.2.0 RunConfig path does not apply here.
Implemented in neograph::a2a::CopyNinjaNode, neograph::a2a::A2ACallerNode, neograph::graph::SyncGraphNode, neograph::graph::LLMCallNode, neograph::graph::ToolDispatchNode, neograph::graph::IntentClassifierNode, and neograph::graph::SubgraphNode.