From fc095be0812271f8ef7dc1d588faea0e2bae29a5 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 28 May 2025 23:04:57 +0200 Subject: [PATCH] Limit user manual search results to fit in context. --- profiler/src/profiler/TracyLlmTools.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/profiler/src/profiler/TracyLlmTools.cpp b/profiler/src/profiler/TracyLlmTools.cpp index bbd3f8fb..0951a50a 100644 --- a/profiler/src/profiler/TracyLlmTools.cpp +++ b/profiler/src/profiler/TracyLlmTools.cpp @@ -732,6 +732,16 @@ std::string TracyLlmTools::SearchManual( const std::string& query, TracyLlmApi& } if( chunks.size() > 5 ) chunks.resize( 5 ); + const auto maxSize = CalcMaxSize(); + int totalSize = 0; + int idx; + for( idx = 0; idx < chunks.size(); idx++ ) + { + totalSize += m_manualChunks[chunks[idx].first].size(); + if( totalSize >= maxSize ) break; + } + if( idx < chunks.size() ) chunks.resize( idx ); + nlohmann::json json; for( auto& chunk : chunks ) {