refactor: Add agents for providers

This commit is contained in:
Petr Mironychev
2026-06-02 01:10:29 +02:00
parent 6220308a93
commit 98a618cf87
15 changed files with 238 additions and 127 deletions

View File

@@ -5,6 +5,7 @@
#include "JsonPromptTemplate.hpp"
#include <QDebug>
#include <QHash>
#include <QJsonArray>
#include <QJsonDocument>
@@ -42,6 +43,16 @@ nlohmann::json buildContextJson(const ContextData &context)
ctx["files_metadata"] = std::move(files);
}
// tool_result blocks only carry the tool_use_id; resolve the originating
// tool name so templates (e.g. Google's functionResponse.name) can emit it.
QHash<QString, QString> toolNameById;
if (context.history) {
for (const auto &msg : context.history.value())
for (const auto &b : msg.blocks)
if (b.kind == ContentBlockEntry::Kind::ToolUse)
toolNameById.insert(b.toolUseId, b.toolName);
}
nlohmann::json history = nlohmann::json::array();
if (context.history) {
for (const auto &msg : context.history.value()) {
@@ -93,6 +104,7 @@ nlohmann::json buildContextJson(const ContextData &context)
bj["type"] = "tool_result";
bj["tool_use_id"] = b.toolUseId.toStdString();
bj["content"] = b.result.toStdString();
bj["name"] = toolNameById.value(b.toolUseId).toStdString();
break;
case ContentBlockEntry::Kind::Image:
bj["type"] = "image";