Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
agents::Agent Class Referenceabstract

Interface for agents. More...

#include <agent.h>

Inheritance diagram for agents::Agent:
agents::ActorAgent agents::AutonomousAgent

Classes

struct  Options
 Agent execution options. More...
 

Public Types

enum class  State {
  READY ,
  RUNNING ,
  WAITING ,
  COMPLETED ,
  FAILED ,
  STOPPED
}
 Agent execution state. More...
 

Public Member Functions

 Agent (std::shared_ptr< AgentContext > context)
 Constructor.
 
virtual ~Agent ()=default
 Destructor.
 
virtual void init ()=0
 Initialize the agent.
 
virtual Task< JsonObjectrun (const String &task)=0
 Run the agent with a task using coroutines.
 
void runAsync (const String &task, std::function< void(const JsonObject &)> callback)
 Run the agent with a callback.
 
virtual void stop ()
 Stop the agent.
 
std::shared_ptr< AgentContextgetContext () const
 Get the agent's context.
 
State getState () const
 Get the agent's current state.
 
void setOptions (const Options &options)
 Set execution options.
 
const OptionsgetOptions () const
 Get execution options.
 
void setStatusCallback (std::function< void(const String &)> callback)
 Set a callback for status updates.
 
virtual void provideFeedback (const String &feedback)
 Provide human feedback.
 
virtual Task< StringwaitForFeedback (const String &message, const JsonObject &context)
 Wait for feedback using coroutines.
 

Detailed Description

Interface for agents.

Agents are LLM-powered systems that can use tools and make decisions to accomplish a task.

Examples
actor_agent_example.cpp.

Member Enumeration Documentation

◆ State

enum class agents::Agent::State
strong

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.

Constructor & Destructor Documentation

◆ Agent()

agents::Agent::Agent ( std::shared_ptr< AgentContext > context)

Constructor.

Parameters
contextThe agent context

Member Function Documentation

◆ getContext()

std::shared_ptr< AgentContext > agents::Agent::getContext ( ) const

Get the agent's context.

Returns
The agent context

◆ getOptions()

const Options & agents::Agent::getOptions ( ) const

Get execution options.

Returns
The execution options

◆ getState()

State agents::Agent::getState ( ) const

Get the agent's current state.

Returns
The agent state

◆ init()

virtual void agents::Agent::init ( )
pure virtual

Initialize the agent.

Implemented in ActorAgent, agents::ActorAgent, and agents::AutonomousAgent.

◆ provideFeedback()

virtual void agents::Agent::provideFeedback ( const String & feedback)
virtual

Provide human feedback.

Parameters
feedbackThe feedback to provide

Reimplemented in ActorAgent, agents::ActorAgent, and agents::AutonomousAgent.

◆ run()

virtual Task< JsonObject > agents::Agent::run ( const String & task)
pure virtual

Run the agent with a task using coroutines.

Parameters
taskThe task to run
Returns
The result of the task

Implemented in ActorAgent, agents::ActorAgent, and agents::AutonomousAgent.

◆ runAsync()

void agents::Agent::runAsync ( const String & task,
std::function< void(const JsonObject &)> callback )

Run the agent with a callback.

Parameters
taskThe task to run
callbackThe callback to run

◆ setOptions()

void agents::Agent::setOptions ( const Options & options)

Set execution options.

Parameters
optionsThe execution options

◆ setStatusCallback()

void agents::Agent::setStatusCallback ( std::function< void(const String &)> callback)

Set a callback for status updates.

Parameters
callbackThe callback to set

◆ stop()

virtual void agents::Agent::stop ( )
virtual

Stop the agent.

Reimplemented in ActorAgent, agents::ActorAgent, and agents::AutonomousAgent.

◆ waitForFeedback()

virtual Task< String > agents::Agent::waitForFeedback ( const String & message,
const JsonObject & context )
inlinevirtual

Wait for feedback using coroutines.

Parameters
messageThe message to wait for feedback
contextThe context to wait for feedback
Returns
The feedback

Reimplemented in ActorAgent, agents::ActorAgent, and agents::AutonomousAgent.