48 Agent(std::shared_ptr<Provider> provider,
49 std::vector<std::unique_ptr<Tool>> tools,
50 const std::string& instructions =
"",
51 const std::string& model =
"");
75 sp::runtime::Result run(std::vector<sp::Message>& messages,
76 int max_iterations = 10);
80 sp::runtime::Result run(std::vector<sp::Message>& messages,
int max_iterations,
92 sp::runtime::Result run_stream(std::vector<sp::Message>& messages,
93 const std::function<
void(const sp::Event&)>& on_event,
94 int max_iterations = 10);
95 sp::runtime::Result run_stream(std::vector<sp::Message>& messages,
96 const std::function<
void(const sp::Event&)>& on_event,
int max_iterations,
104 sp::runtime::Result complete(const std::vector<sp::Message>& messages);
118 sp::Usage usage()
const {
return usage_->snapshot(); }
119 const std::vector<sp::runtime::Result>& outcomes() const noexcept {
return outcomes_; }
139 std::shared_ptr<ToolExecutionController> controller) {
140 tool_execution_controller_ = std::move(controller);
146 tool_detection_timeout_seconds_ = timeout_seconds;
154 hook_runtime_ = std::move(runtime);
158 std::shared_ptr<Provider> provider_;
159 std::vector<std::unique_ptr<Tool>> tools_;
160 std::string instructions_;
164 std::shared_ptr<UsageAccumulator> usage_ = std::make_shared<UsageAccumulator>();
165 std::vector<sp::runtime::Result> outcomes_;
172 std::shared_ptr<ToolExecutionController> tool_execution_controller_;
174 int tool_detection_timeout_seconds_ = -1;
175 std::shared_ptr<::neograph::RuntimeInterpositionController> runtime_interposition_;
176 std::shared_ptr<::neograph::HookRuntime> hook_runtime_;
178 void ensure_system_message(std::vector<sp::Message>& messages);
179 sp::runtime::Result run_loop(std::vector<sp::Message>& messages,
int max_iterations,
181 std::function<
void(
const sp::Event&)> on_event);
182 std::vector<ChatTool> get_tool_definitions()
const;
186 std::vector<Tool*> tool_ptrs()
const;
Agent(std::shared_ptr< Provider > provider, std::vector< std::unique_ptr< Tool > > tools, const std::string &instructions="", const std::string &model="")
Construct an agent with a provider and tools.