5#ifndef FORESTHUB_AGENT_RUNNER_HPP
6#define FORESTHUB_AGENT_RUNNER_HPP
24using json = nlohmann::json;
69 RunResultOrError Run(
const std::shared_ptr<Agent>& starting_agent,
const std::shared_ptr<core::Input>& input);
72 const std::shared_ptr<foresthub::core::LLMClient>&
client()
const {
return client_; }
79 std::shared_ptr<foresthub::core::LLMClient> client_;
85 std::shared_ptr<foresthub::core::Tool> handoff_tool;
87 bool is_handoff =
false;
95 ExecResult ExecuteFunctionTools(
const std::vector<foresthub::core::ToolCallRequest>& requests,
96 const std::shared_ptr<Agent>&
agent);
Agent with instructions, tools, and optional response format.
Runner & WithMaxTurns(int max_turns)
Set the turn limit for agent execution.
RunResultOrError Run(const std::shared_ptr< Agent > &starting_agent, const std::shared_ptr< core::Input > &input)
Execute an agent workflow from the given starting point.
const core::ModelID & default_model() const
Definition runner.hpp:74
const std::shared_ptr< foresthub::core::LLMClient > & client() const
Definition runner.hpp:72
const foresthub::Optional< int > & max_turns() const
Definition runner.hpp:76
Runner(std::shared_ptr< foresthub::core::LLMClient > client, foresthub::core::ModelID model)
Construct a runner with an LLM client and default model.
Wrapper for nlohmann/json that works around abs macro conflicts.
Agent framework: multi-turn execution with tool calling and handoffs.
std::string ModelID
Unique identifier for an LLM model.
Definition model.hpp:23
Top-level namespace for the ForestHub SDK.
Minimal Optional<T> polyfill for C++14 compatibility.
LLMClient and Provider interfaces for chat operations.
Minimal Optional<T> polyfill for C++14 compatibility.
Definition optional.hpp:21
Result wrapper that holds either a RunResult or an error message.
Definition runner.hpp:34
static RunResultOrError Failure(std::string error_message)
Create a failure result.
Definition runner.hpp:49
static RunResultOrError Success(RunResult result)
Create a successful result.
Definition runner.hpp:44
foresthub::Optional< RunResult > result
Present on success.
Definition runner.hpp:35
bool HasError() const
Check if an error occurred.
Definition runner.hpp:39
std::string error
Non-empty on failure.
Definition runner.hpp:36
Final outcome of an agent execution workflow.
Definition runner.hpp:27
std::shared_ptr< Agent > last_agent
Agent active when execution finished.
Definition runner.hpp:29
json final_output
Output produced by the agent.
Definition runner.hpp:28
int turns
Number of LLM round-trips taken.
Definition runner.hpp:30