NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
plan_execute_graph.h File Reference

Factory for the Plan-and-Execute agent pattern. More...

Include dependency graph for plan_execute_graph.h:

Go to the source code of this file.

Functions

std::unique_ptr< GraphEngineneograph::graph::create_plan_execute_graph (std::shared_ptr< Provider > provider, std::vector< std::unique_ptr< Tool > > tools, const std::string &planner_prompt, const std::string &executor_prompt, const std::string &responder_prompt, const std::string &model="", int max_step_iterations=5)
 Build a Plan-and-Execute graph.
 

Detailed Description

Factory for the Plan-and-Execute agent pattern.

Produces a graph with three phases:

start → planner → [plan_empty? responder : executor] executor → [plan_empty? responder : executor] responder → end

Phase roles:

  • planner: Calls the LLM with planner_prompt. The model must reply with a JSON array of strings (one step per item); the node tolerates fenced ``json blocks and leading prose. The array is written to theplanchannel.
  • executor: Pops the next step offplan, runs an inner ReAct loop against that single step using @p executor_prompt and the shared tool set, and appends {step, result} to the past_stepschannel.
  • responder: Composes a final answer from the original objective and the accumulatedpast_steps, using @p responder_prompt. The text lands on thefinal_responsechannel and is also appended tomessages` as an assistant turn.

The factory registers its three custom node types and the plan_empty condition the first time it is called (idempotent via std::call_once).

Definition in file plan_execute_graph.h.

Function Documentation

◆ create_plan_execute_graph()

std::unique_ptr< GraphEngine > neograph::graph::create_plan_execute_graph ( std::shared_ptr< Provider provider,
std::vector< std::unique_ptr< Tool > >  tools,
const std::string &  planner_prompt,
const std::string &  executor_prompt,
const std::string &  responder_prompt,
const std::string &  model = "",
int  max_step_iterations = 5 
)

Build a Plan-and-Execute graph.

Parameters
providerLLM provider shared by every phase.
toolsTools the executor may invoke (ownership transferred).
planner_promptSystem prompt for the planner phase. Should instruct the model to respond with a JSON array of steps.
executor_promptSystem prompt for the single-step executor.
responder_promptSystem prompt for the final synthesis phase.
modelModel name. Empty falls back to the provider default.
max_step_iterationsMax tool-call iterations inside the executor per step (safety bound on the inner ReAct loop).
Returns
A compiled GraphEngine.

References neograph::graph::create_plan_execute_graph().

Referenced by neograph::graph::create_plan_execute_graph().