NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
step_plan.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <neograph/api.h>
20
21#include <cstddef>
22#include <cstdint>
23#include <optional>
24#include <string>
25#include <string_view>
26#include <type_traits>
27#include <vector>
28
29namespace neograph::program {
30
34 std::string path;
36 std::string code;
39 std::string message;
41 std::string hint;
43 json detail = json::object();
44
45 bool operator==(const StepPlanViolation&) const = default;
46};
47
50 std::uint32_t max_steps = 32;
51 std::uint32_t max_params_per_step = 16;
52 std::uint32_t max_after_per_step = 8;
53 std::uint32_t max_literal_bytes = 4096;
54 std::uint32_t max_total_literal_bytes = 32768;
55 std::uint32_t max_literal_depth = 6;
56 std::uint32_t max_retry_attempts = 3;
57 std::uint32_t max_violations = 32;
58 std::uint32_t max_document_bytes = 131072;
59};
60
66 std::string template_id;
68 std::vector<std::string> required_params;
70 std::string summary;
71
72 bool operator==(const StepPlanTemplateInfo&) const = default;
73};
74
75struct StepPlanIntakeOptions {
77 std::string source_id = "step-plan";
78 StepPlanLimits limits;
81 TaskGraphProposalLimits proposal_limits;
83 std::vector<TaskGraphTemplateContract> template_allowlist;
84 std::vector<StepPlanTemplateInfo> template_info;
85};
86
88enum class StepPlanEnvelope : std::uint8_t {
90 None,
92 Strict,
95};
96
97NEOGRAPH_PROGRAM_API std::string_view to_string(StepPlanEnvelope envelope) noexcept;
98
99struct StepPlanIntakeResult {
101 std::vector<StepPlanViolation> violations;
102 StepPlanEnvelope envelope = StepPlanEnvelope::None;
104 std::string plan_digest;
106 std::optional<json> proposal;
108 std::optional<std::string> proposal_hash;
110 std::vector<SourceMapEntry> source_map;
112 json report = json::object();
113
114 bool ok() const noexcept { return violations.empty() && proposal.has_value(); }
115};
116
118NEOGRAPH_PROGRAM_API StepPlanIntakeResult
119intake_step_plan_text(std::string_view text, const StepPlanIntakeOptions& options);
120
122NEOGRAPH_PROGRAM_API StepPlanIntakeResult
123intake_step_plan_document(const json& document, const StepPlanIntakeOptions& options);
124
125inline StepPlanIntakeResult intake_step_plan(std::string_view text,
126 const StepPlanIntakeOptions& options) {
127 return intake_step_plan_text(text, options);
128}
129
130template <class Document,
131 std::enable_if_t<std::is_same_v<std::remove_cv_t<std::remove_reference_t<Document>>, json>,
132 int> = 0>
133StepPlanIntakeResult intake_step_plan(const Document& document,
134 const StepPlanIntakeOptions& options) {
135 return intake_step_plan_document(document, options);
136}
137
142NEOGRAPH_PROGRAM_API std::string
143format_violations_for_model(const std::vector<StepPlanViolation>& violations,
144 std::size_t max_bytes);
145
151NEOGRAPH_PROGRAM_API json
152step_plan_json_schema(const std::vector<TaskGraphTemplateContract>& templates,
153 const StepPlanLimits& limits);
154
155} // namespace neograph::program
NEOGRAPH_API export/import macro for shared-library builds.
Deeply owned, immutable Program source values.
NEOGRAPH_PROGRAM_API json step_plan_json_schema(const std::vector< TaskGraphTemplateContract > &templates, const StepPlanLimits &limits)
A JSON Schema (2020-12) specialised to a catalog, for providers that enforce structured output: use i...
NEOGRAPH_PROGRAM_API StepPlanIntakeResult intake_step_plan_document(const json &document, const StepPlanIntakeOptions &options)
Intake of an already parsed document.
NEOGRAPH_PROGRAM_API StepPlanIntakeResult intake_step_plan_text(std::string_view text, const StepPlanIntakeOptions &options)
Intake of the planner's text: the first top-level JSON object, in a fence or after prose.
NEOGRAPH_PROGRAM_API std::string format_violations_for_model(const std::vector< StepPlanViolation > &violations, std::size_t max_bytes)
Deterministic text for the planner's next prompt, at most max_bytes long: one numbered line per viola...
StepPlanEnvelope
How the JSON object was found in the planner's text.
Definition step_plan.h:88
@ Recovered
The object came from a fenced block, or from text around it.
Ceilings on the size and shape of a submitted plan.
Definition step_plan.h:49
Advisory, host-authored facts about one template.
Definition step_plan.h:65
std::string summary
At most 160 bytes; shown to the planner by catalog views.
Definition step_plan.h:70
std::vector< std::string > required_params
Input names without the leading '/'.
Definition step_plan.h:68
One problem found in a submitted plan.
Definition step_plan.h:32
std::string path
JSON Pointer into the submitted document; "" is the document.
Definition step_plan.h:34
std::string code
Stable code, always STEP_*.
Definition step_plan.h:36
std::string message
One sentence.
Definition step_plan.h:39
std::string hint
One imperative sentence; lists at most five valid names.
Definition step_plan.h:41
json detail
Machine fields: given, expected, choices, and so on.
Definition step_plan.h:43
Finite structural and resource ceilings enforced before a proposal is usable.
Immutable, non-executable TaskGraphProposal-v1 values.