NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
step_plan_repair.h
Go to the documentation of this file.
1
22#pragma once
23
24#include <neograph/api.h>
27
28#include <cstddef>
29#include <cstdint>
30#include <functional>
31#include <string>
32#include <string_view>
33#include <vector>
34
35namespace neograph::program {
36
37inline constexpr std::string_view STEP_PLAN_INTAKE_NODE = "neograph.step_plan_intake/v1";
38inline constexpr std::string_view STEP_PLAN_ROUTE_CONDITION = "neograph.step_plan_route/v1";
39inline constexpr std::string_view STEP_PLAN_REPORT_NODE = "neograph.step_plan_report/v1";
40
42enum class StepPlanFeedback : std::uint8_t {
45 Replace,
47 Append,
48};
49
50NEOGRAPH_PROGRAM_API std::string_view to_string(StepPlanFeedback feedback) noexcept;
51
52struct StepPlanRepairNodeOptions {
55 StepPlanIntakeOptions intake;
57 std::string attestation_id = "host:step-plan-repair";
59 std::uint32_t max_attempts_ceiling = 5;
61 std::size_t max_feedback_bytes = 2048;
62};
63
72NEOGRAPH_PROGRAM_API void add_step_plan_repair(RegistrySnapshotBuilder& builder,
73 const StepPlanRepairNodeOptions& options);
74
77 std::string role;
78 std::string content;
79
80 bool operator==(const PlannerMessage&) const = default;
81};
82
85 std::string text;
86 std::uint64_t prompt_tokens = 0;
87 std::uint64_t completion_tokens = 0;
88};
89
90struct PlanRepairOptions {
91 StepPlanIntakeOptions intake;
92 std::uint32_t max_attempts = 3;
93 StepPlanFeedback feedback = StepPlanFeedback::Replace;
94 std::size_t max_feedback_bytes = 2048;
95};
96
97struct StepPlanRepairResult {
98 bool ok = false;
100 json proposal = nullptr;
101 std::optional<std::string> proposal_hash;
103 json repair = json::object();
104 std::uint32_t attempts = 0;
105 std::uint64_t prompt_tokens = 0;
106 std::uint64_t completion_tokens = 0;
108 std::vector<PlannerMessage> messages;
109};
110
117NEOGRAPH_PROGRAM_API StepPlanRepairResult
118repair_step_plan(const PlanRepairOptions& options,
119 std::string_view request,
120 const std::function<PlannerReply(const std::vector<PlannerMessage>&)>& planner);
121
122} // namespace neograph::program
NEOGRAPH_API export/import macro for shared-library builds.
Move-only builder for one sealed, process-local executable registry.
Definition registry.h:110
Immutable executable registry snapshots for Program admission.
Flat step-plan intake: step-plan/v1 checked and lowered into a TaskGraphProposal.
NEOGRAPH_PROGRAM_API StepPlanRepairResult repair_step_plan(const PlanRepairOptions &options, std::string_view request, const std::function< PlannerReply(const std::vector< PlannerMessage > &)> &planner)
Run the loop around a planner callback, for hosts that plan before they start a run.
NEOGRAPH_PROGRAM_API void add_step_plan_repair(RegistrySnapshotBuilder &builder, const StepPlanRepairNodeOptions &options)
Register the intake node (neograph.step_plan_intake/v1; configuration max_attempts,...
StepPlanFeedback
How the next prompt is built after a rejected plan.
@ Replace
Rebuild the conversation as [system messages, first user message, the rejected plan,...
@ Append
Keep the whole conversation and add the violations to it.
One message of the planner's conversation.
std::string role
"system", "user" or "assistant"
What a planner call returns; usage is the host's own accounting.