- 工具循环:capture_image / get_robot_status / spawn_subagent - 子代理:技能超集(run_command 带超时截断、read_file / write_file) - V4L2 摄像头抓帧:MJPEG 优先零转码,YUYV+libjpeg 回退,/dev/video* 自动探测 - 时间戳注入:system prompt 会话级当前时间 + 工具结果执行时间 - CLI:--prompt-file / --camera / --camera-device / --model / --max-turns
24 lines
815 B
C++
24 lines
815 B
C++
#include "subagent.hpp"
|
|
|
|
#include "tools.hpp"
|
|
|
|
namespace {
|
|
|
|
constexpr const char* SUBAGENT_PROMPT =
|
|
"你是机器人的子代理(专家),拥有比主代理更丰富的技能:可以执行 shell 命令、"
|
|
"读写文件、拍照和查询状态。请利用这些技能完成主代理委派的任务,"
|
|
"返回简洁明确的结果,用中文。";
|
|
|
|
} // namespace
|
|
|
|
std::string run_subagent(const AgentConfig& cfg, const std::string& task) {
|
|
ToolRegistry registry;
|
|
registry.add(make_run_command_tool());
|
|
registry.add(make_read_file_tool());
|
|
registry.add(make_write_file_tool());
|
|
registry.add(make_capture_image_tool(cfg.camera_path, cfg.camera_device));
|
|
registry.add(make_robot_status_tool());
|
|
|
|
return run_chat_loop(cfg, SUBAGENT_PROMPT, task, registry, "子代理");
|
|
}
|