45namespace neograph::graph {
65using ReducerFn = std::function<json(
const json& current,
const json& incoming)>;
106 : std::runtime_error(reason), reason_(reason) {}
110 const std::string&
reason()
const {
return reason_; }
208 return static_cast<StreamMode>(
static_cast<uint8_t
>(a) |
static_cast<uint8_t
>(b));
215 return static_cast<StreamMode>(
static_cast<uint8_t
>(a) &
static_cast<uint8_t
>(b));
222 return static_cast<uint8_t
>(flags & test) != 0;
242 std::map<std::string, std::string>
routes;
NEOGRAPH_API export/import macro for shared-library builds.
Thread-safe container for all graph state channels.
Exception thrown from inside a node to trigger a dynamic breakpoint.
const std::string & reason() const
Get the interrupt reason.
NodeInterrupt(const std::string &reason)
Construct a NodeInterrupt with a reason message.
std::function< void(const GraphEvent &)> GraphStreamCallback
Callback for receiving graph execution events.
constexpr const char * START_NODE
Special node name representing the graph entry point.
StreamMode operator|(StreamMode a, StreamMode b)
Bitwise OR for StreamMode flags.
bool has_mode(StreamMode flags, StreamMode test)
Check if a specific stream mode flag is set.
constexpr const char * END_NODE
Special node name representing the graph exit point.
StreamMode
Bitfield flags for selecting which events to stream during execution.
@ TOKENS
LLM_TOKEN events (streaming tokens).
@ UPDATES
Channel write deltas per node.
@ EVENTS
NODE_START, NODE_END, INTERRUPT, ERROR events.
@ VALUES
Full state snapshot after each super-step.
@ DEBUG
Internal debug info (retry attempts, routing decisions).
StreamMode operator&(StreamMode a, StreamMode b)
Bitwise AND for StreamMode flags.
std::function< json(const json ¤t, const json &incoming)> ReducerFn
Custom reducer function signature.
ReducerType
Strategy for merging values when writing to a channel.
@ OVERWRITE
Replace the current value entirely.
@ APPEND
Append to the current value (arrays are concatenated).
@ CUSTOM
Use a custom reducer function.
std::function< std::string(const GraphState &)> ConditionFn
Condition function signature for conditional edge routing.
Abstract LLM provider interface.
Output of a node: a write to a named channel.
json value
Value to write through the channel's reducer.
std::string channel
Target channel name.
A state channel that holds a value with a reducer and version tracking.
ReducerType reducer_type
Merge strategy.
uint64_t version
Version counter (incremented on each write).
json value
Current channel value.
ReducerFn reducer
Custom reducer (when type == CUSTOM).
std::string name
Channel name.
Combined routing override + state update.
std::vector< ChannelWrite > updates
State updates to apply before routing.
std::string goto_node
Next node to execute (overrides edge routing).
A conditional edge with runtime routing based on state.
std::string from
Source node name.
std::string condition
Condition function name in ConditionRegistry.
std::map< std::string, std::string > routes
Mapping of condition result to destination node.
A static edge connecting two nodes.
std::string to
Destination node name.
std::string from
Source node name.
An event emitted during graph execution for streaming.
json data
Event-specific data payload.
std::string node_name
Name of the node that generated this event.
Type
Event type enumeration.
@ NODE_START
A node began execution.
@ LLM_TOKEN
A token was received from the LLM.
@ CHANNEL_WRITE
A value was written to a channel.
@ INTERRUPT
Execution was interrupted (HITL).
@ ERROR
An error occurred during execution.
@ NODE_END
A node finished execution.
Dependency injection context passed to nodes during construction.
std::shared_ptr< Provider > provider
LLM provider for making completions.
json extra_config
Additional configuration (node-type specific).
std::string model
Model name override (empty = use provider default).
std::vector< Tool * > tools
Non-owning tool pointers consumed by node factories at compile() time.
std::string instructions
System prompt / instructions for the LLM.
Extended result returned by node execution.
std::vector< Send > sends
If non-empty, triggers dynamic fan-out.
std::optional< Command > command
If set, overrides edge-based routing.
std::vector< ChannelWrite > writes
Channel writes from this node.
NodeResult(std::vector< ChannelWrite > w)
Construct from plain channel writes (backward compatible).
Retry policy for node execution with exponential backoff.
int initial_delay_ms
Delay before the first retry (milliseconds).
int max_delay_ms
Maximum delay cap (milliseconds).
float jitter_pct
Random jitter as a fraction of the computed delay, in [0, 1].
int max_retries
Maximum retry attempts. 0 = no retry.
float backoff_multiplier
Multiplier applied to delay after each retry.
Dynamic fan-out request (map-reduce pattern).
json input
Channel writes for that invocation.
std::string target_node
Node to dispatch.
Foundation types for NeoGraph: messages, tool calls, and LLM completions.