fix: truncate webfetch content to fit context
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 2m18s
C++ / clang-tidy (pull_request) Failing after 2m7s
JS/TS / fmt (pull_request) Failing after 9s
JS/TS / lint (pull_request) Successful in 9s
Python / static (pull_request) Successful in 29s
Rust / build (pull_request) Successful in 50s
Python / verify (pull_request) Successful in 1m38s
Rust / fmt (pull_request) Successful in 26s
Rust / clippy (pull_request) Successful in 47s

This commit is contained in:
2026-09-03 22:46:46 +02:00
parent ae5c1fa148
commit fcb848b6d2
31 changed files with 1386 additions and 135 deletions
+9 -1
View File
@@ -20,7 +20,9 @@ class WebFetchTool : public LlmTool {
static constexpr int MaxResponseBytes = 5 * 1024 * 1024;
static constexpr int DefaultTimeoutSeconds = 30;
static constexpr int MaxTimeoutSeconds = 120;
static constexpr int MaxOutputChars = 64 * 1024;
// Where the full (untruncated) output of each call is stored so the
// model can page through it with the readfile tool.
static const QString StoragePath;
explicit WebFetchTool(QObject* parent = nullptr);
~WebFetchTool() override;
@@ -29,6 +31,7 @@ class WebFetchTool : public LlmTool {
QString description() const override;
QJsonObject parameters() const override;
void execute(
const QString& toolCallId,
const QJsonObject& args,
std::function<void(const QJsonObject& result)> done) override;
void cancel() override;
@@ -43,10 +46,15 @@ class WebFetchTool : public LlmTool {
QByteArray body;
bool tooLarge = false;
QString format;
QString toolCallId;
std::function<void(const QJsonObject& result)> done;
};
void completeJob(Job* job, QJsonObject result);
// Writes the full output to StoragePath; returns the file path, or an
// empty string when saving failed.
QString saveToFile(const Job& job, const QString& content,
const QString& mime) const;
QNetworkAccessManager m_manager;
QList<Job*> m_jobs;