12#include <agents-cpp/agent.h>
13#include <agents-cpp/coroutine_utils.h>
15#include <condition_variable>
147 std::vector<Step> steps_;
148 std::function<void(
const Step&)> step_callback_;
151 std::atomic<bool> should_stop_{
false};
156 std::promise<String> feedback_promise_;
177 void recordStep(
const Step& step);
183 String getToolDescriptions()
const;
225 std::vector<std::string> split_by_newline(
const std::string& text) {
226 std::vector<std::string> lines;
227 std::istringstream iss(text);
231 while (std::getline(iss, line,
'\n')) {
232 lines.push_back(line);
Agent(std::shared_ptr< AgentContext > context)
Constructor.
void setPlanningStrategy(PlanningStrategy strategy)
Set the planning strategy.
void setStepCallback(std::function< void(const Step &)> callback)
Set a callback for when a step is completed.
std::vector< Step > getSteps() const
Get the steps executed so far.
void stop() override
Stop the agent.
Task< JsonObject > run(const String &task) override
Run the agent with a task using coroutines.
void provideFeedback(const String &feedback) override
Provide human feedback.
PlanningStrategy
Planning strategy for the agent.
Definition autonomous_agent.h:55
@ PLAN_AND_EXECUTE
Generate a plan then execute it.
Definition autonomous_agent.h:67
@ ZERO_SHOT
Generate actions without explicit planning.
Definition autonomous_agent.h:59
@ REACT
Reasoning and acting.
Definition autonomous_agent.h:75
@ TREE_OF_THOUGHT
Generate multiple reasoning paths.
Definition autonomous_agent.h:63
@ REFLEXION
Reflect on past steps for improvement.
Definition autonomous_agent.h:71
AutonomousAgent(std::shared_ptr< AgentContext > context)
Constructor.
~AutonomousAgent() override=default
Destructor.
void init() override
Initialize the agent.
void setSystemPrompt(const String &system_prompt)
Set the system prompt.
Task< String > waitForFeedback(const String &message, const JsonObject &context) override
Wait for feedback using coroutines.
Provide a future-based fallback for Task.
Definition coroutine_utils.h:115
Framework Namespace.
Definition agent.h:18
nlohmann::json JsonObject
JSON object type.
Definition types.h:39
std::string String
String type.
Definition types.h:27
Step in the agent's execution.
Definition autonomous_agent.h:33
JsonObject result
The result of the step.
Definition autonomous_agent.h:45
bool success
Whether the step was successful.
Definition autonomous_agent.h:49
String description
The description of the step.
Definition autonomous_agent.h:37
String status
The status of the step.
Definition autonomous_agent.h:41