fix: truncate context logic

This commit is contained in:
2026-09-30 15:01:28 +02:00
parent a59e4286ad
commit 5fc6fda804
15 changed files with 238 additions and 126 deletions
+4 -6
View File
@@ -20,8 +20,6 @@ class WebFetchTool : public LlmTool {
static constexpr int MaxResponseBytes = 5 * 1024 * 1024;
static constexpr int DefaultTimeoutSeconds = 30;
static constexpr int MaxTimeoutSeconds = 120;
// 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);
@@ -33,6 +31,7 @@ class WebFetchTool : public LlmTool {
void execute(
const QString& toolCallId,
const QJsonObject& args,
int outputBudgetChars,
std::function<void(const QJsonObject& result)> done) override;
void cancel() override;
@@ -47,14 +46,13 @@ class WebFetchTool : public LlmTool {
bool tooLarge = false;
QString format;
QString toolCallId;
int budgetChars = 0;
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;
QString saveToFile(
const Job& job, const QString& content, const QString& mime) const;
QNetworkAccessManager m_manager;
QList<Job*> m_jobs;