From 6dd09e3ed8f10d36165b7dd1bcedfcc3e41f9f22 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 3 Aug 2026 20:09:24 +0200 Subject: [PATCH] Make the tool reply limit easier to understand. --- profiler/src/profiler/TracyLlm.cpp | 24 ++++++++++++++++++++---- profiler/src/profiler/TracyLlm.hpp | 2 ++ profiler/src/profiler/TracyLlmTools.cpp | 6 ++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index 92574b45..2a054ed4 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -399,18 +399,34 @@ void TracyLlm::Draw( WindowConstraints& constraints ) } ImGui::SameLine(); ImGui::TextDisabled( "(bytes)" ); - constraints.MarkMinWidth(); if( !s_config.llmLimitToolReplySize ) ImGui::EndDisabled(); - if( !models.empty() ) + ImGui::SameLine(); + TextDisabledUnformatted( "Effective: " ); + ImGui::SameLine(); + bool known = false; + if( s_config.llmLimitToolReplySize ) + { + known = true; + TextDisabledUnformatted( MemSizeToString( s_config.llmMaxToolReplySizeValue ) ); + } + else if( !models.empty() ) { const auto ctxSize = models[m_modelIdx].contextSize; const int ctxBasedLimit = TracyLlmTools::CalcCtxBasedLimit( ctxSize ); if( ctxBasedLimit > 0 ) { - ImGui::SameLine(); - ImGui::TextDisabled( "(ctx: %d bytes)", ctxBasedLimit); + known = true; + TextDisabledUnformatted( MemSizeToString( ctxBasedLimit ) ); } } + if( !known ) + { + TextDisabledUnformatted( MemSizeToString( DefaultToolReplyLimit ) ); + ImGui::SameLine(); + TextColoredUnformatted( 0xFF00FFFF, ICON_FA_TRIANGLE_EXCLAMATION ); + TooltipIfHovered( "Will change when model context size is known" ); + } + constraints.MarkMinWidth(); char buf[1024]; diff --git a/profiler/src/profiler/TracyLlm.hpp b/profiler/src/profiler/TracyLlm.hpp index 24f4ae4a..f8580220 100644 --- a/profiler/src/profiler/TracyLlm.hpp +++ b/profiler/src/profiler/TracyLlm.hpp @@ -16,6 +16,8 @@ namespace tracy { +constexpr int DefaultToolReplyLimit = 48 * 1024; + class TracyLlmApi; class TracyLlmChat; class TracyLlmTools; diff --git a/profiler/src/profiler/TracyLlmTools.cpp b/profiler/src/profiler/TracyLlmTools.cpp index 6cde1a77..574c9403 100644 --- a/profiler/src/profiler/TracyLlmTools.cpp +++ b/profiler/src/profiler/TracyLlmTools.cpp @@ -376,11 +376,9 @@ int TracyLlmTools::CalcCtxBasedLimit( int ctxSize ) int TracyLlmTools::CalcMaxSize() const { - constexpr int defaultLimit = 48*1024; - const int limit = s_config.llmLimitToolReplySize ? s_config.llmMaxToolReplySizeValue : defaultLimit; + if( s_config.llmLimitToolReplySize ) return s_config.llmMaxToolReplySizeValue; const int ctxLimit = CalcCtxBasedLimit( m_ctxSize ); - if( ctxLimit <= 0 ) return limit; - return std::min( ctxLimit, limit ); + return ctxLimit > 0 ? ctxLimit : DefaultToolReplyLimit; } std::string TracyLlmTools::TrimString( std::string&& str ) const