An agent that operates autonomously to complete a task.
More...
#include <autonomous_agent.h>
|
|
std::string | agent_prompt_ |
| | The agent prompt.
|
|
PlanningStrategy | planning_strategy_ = PlanningStrategy::REACT |
| | Planning strategy for the agent.
|
|
std::vector< Step > | steps_ |
| | The steps executed so far.
|
|
std::function< void(const Step &)> | step_callback_ |
| | Callback for when a step is completed.
|
|
std::function< void(const JsonObject &)> | task_callback_ |
| | Callback for task's incremental updates.
|
|
std::atomic< bool > | should_stop_ {false} |
| | Execution state flag to indicate if the agent should stop.
|
|
std::promise< std::string > | feedback_promise_ |
| | Promise for coroutine-based feedback.
|
An agent that operates autonomously to complete a task.
Autonomous agents start with a task, plan steps to accomplish it, and use tools to execute those steps. They can be configured with various strategies and human-in-the-loop options.
- Examples
- autonomous_agent_example.cpp, and coroutine_example.cpp.
◆ PlanningStrategy
Planning strategy for the agent.
| Enumerator |
|---|
| ZERO_SHOT | Generate actions without explicit planning.
|
| TREE_OF_THOUGHT | Generate multiple reasoning paths.
|
| PLAN_AND_EXECUTE | Generate a plan then execute it.
|
| REFLEXION | Reflect on past steps for improvement.
|
| REACT | Reasoning and acting.
|
- Examples
- autonomous_agent_example.cpp.
◆ State
Agent execution state.
| Enumerator |
|---|
| READY | Ready to start execution.
|
| RUNNING | Currently executing.
|
| WAITING | Waiting for human input.
|
| COMPLETED | Execution completed successfully.
|
| FAILED | Execution failed.
|
| STOPPED | Execution stopped by user.
|
◆ AutonomousAgent()
| agents::AutonomousAgent::AutonomousAgent |
( |
std::shared_ptr< Context > | context | ) |
|
◆ executeStep()
| Task< Step > agents::AutonomousAgent::executeStep |
( |
std::string & | step_description, |
|
|
JsonObject & | context ) |
|
protected |
Execute a step using coroutines.
- Parameters
-
| step_description | The description of the step |
| context | The context |
- Returns
- The result of the step
◆ executeTask()
| Task< JsonObject > agents::AutonomousAgent::executeTask |
( |
const std::string & | task | ) |
|
|
protected |
Execute the agent's task using coroutines.
- Parameters
-
- Returns
- The result of the task
◆ getContext()
| std::shared_ptr< Context > agents::Agent::getContext |
( |
| ) |
const |
|
inherited |
Get the agent's context.
- Returns
- The agent context
◆ getOptions()
| const Options & agents::Agent::getOptions |
( |
| ) |
const |
|
inherited |
Get execution options.
- Returns
- The execution options
◆ getState()
| State agents::Agent::getState |
( |
| ) |
const |
|
inherited |
Get the agent's current state.
- Returns
- The agent state
◆ getSteps()
| std::vector< Step > agents::AutonomousAgent::getSteps |
( |
| ) |
const |
Get the steps executed so far.
- Returns
- The steps executed so far
◆ getToolDescriptions()
| std::string agents::AutonomousAgent::getToolDescriptions |
( |
| ) |
const |
|
protected |
Get tool descriptions for prompts.
- Returns
- The tool descriptions
◆ init()
| void agents::AutonomousAgent::init |
( |
| ) |
|
|
overridevirtual |
◆ planAndExecute()
| Task< JsonObject > agents::AutonomousAgent::planAndExecute |
( |
const std::string & | task | ) |
|
|
protected |
Plan and execute.
- Parameters
-
- Returns
- The plan
◆ planReact()
| Task< JsonObject > agents::AutonomousAgent::planReact |
( |
const std::string & | task | ) |
|
|
protected |
Plan using React.
- Parameters
-
- Returns
- The plan
◆ planReflexion()
| Task< JsonObject > agents::AutonomousAgent::planReflexion |
( |
const std::string & | task | ) |
|
|
protected |
Plan using Reflexion.
- Parameters
-
- Returns
- The plan
◆ planTreeOfThought()
| Task< JsonObject > agents::AutonomousAgent::planTreeOfThought |
( |
const std::string & | task | ) |
|
|
protected |
Plan using Tree of Thought.
- Parameters
-
- Returns
- The plan
◆ planZeroShot()
| Task< JsonObject > agents::AutonomousAgent::planZeroShot |
( |
const std::string & | task | ) |
|
|
protected |
Plan using Zero Shot.
- Parameters
-
- Returns
- The plan
◆ provideFeedback()
| void agents::AutonomousAgent::provideFeedback |
( |
const std::string & | feedback | ) |
|
|
overridevirtual |
Provide human feedback.
- Parameters
-
Reimplemented from agents::Agent.
◆ recordStep()
| void agents::AutonomousAgent::recordStep |
( |
const Step & | step | ) |
|
|
protected |
Record a completed step.
- Parameters
-
◆ run()
| Task< JsonObject > agents::AutonomousAgent::run |
( |
const std::string & | task | ) |
|
|
overridevirtual |
Run the agent with a task using coroutines.
- Parameters
-
- Returns
- The result of the task
Implements agents::Agent.
◆ runAsync()
| void agents::AutonomousAgent::runAsync |
( |
const std::string & | task, |
|
|
std::function< void(const JsonObject &)> | callback ) |
|
overridevirtual |
Run the agent with a callback.
- Parameters
-
| task | The task to run |
| callback | The callback for incremental updates |
Reimplemented from agents::Agent.
◆ setAgentPrompt()
| void agents::AutonomousAgent::setAgentPrompt |
( |
const std::string & | agent_prompt | ) |
|
Set the agent prompt.
- Parameters
-
| agent_prompt | The agent prompt |
◆ setOptions()
| void agents::Agent::setOptions |
( |
const Options & | options | ) |
|
|
inherited |
Set execution options.
- Parameters
-
| options | The execution options |
◆ setPlanningStrategy()
Set the planning strategy.
- Parameters
-
| strategy | The planning strategy |
◆ setStatusCallback()
| void agents::Agent::setStatusCallback |
( |
std::function< void(const std::string &)> | callback | ) |
|
|
inherited |
Set a callback for status updates.
- Parameters
-
| callback | The callback to set |
- Examples
- simple_agent.cpp.
◆ setStepCallback()
| void agents::AutonomousAgent::setStepCallback |
( |
std::function< void(const Step &)> | callback | ) |
|
Set a callback for when a step is completed.
- Parameters
-
◆ stop()
| void agents::AutonomousAgent::stop |
( |
| ) |
|
|
overridevirtual |
◆ waitForFeedback()
| Task< std::string > agents::AutonomousAgent::waitForFeedback |
( |
const std::string & | message, |
|
|
const JsonObject & | context ) |
|
overridevirtual |
Wait for feedback using coroutines.
- Parameters
-
| message | The message to wait for feedback |
| context | The context |
- Returns
- The feedback
Reimplemented from agents::Agent.