From 736a2d3ba2a582a9c6afd45f93bc1b9541050f63 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 25 May 2025 03:27:42 +0200 Subject: [PATCH] Indicate forgotten tool outputs in the chat window. --- profiler/src/profiler/TracyLlm.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index ed893834..fa9cffbe 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -400,7 +400,8 @@ void TracyLlm::Draw() const auto rw = ImGui::CalcTextSize( ICON_FA_ROBOT ).x; const auto ew = ImGui::CalcTextSize( ICON_FA_CIRCLE_EXCLAMATION ).x; const auto yw = ImGui::CalcTextSize( ICON_FA_REPLY ).x; - const auto mw = std::max( { uw, rw, ew, yw } ); + const auto cw = ImGui::CalcTextSize( ICON_FA_RECYCLE ).x; + const auto mw = std::max( { uw, rw, ew, yw, cw } ); const auto posStart = ImGui::GetCursorPos().x; const auto& role = line["role"].get_ref(); @@ -411,9 +412,18 @@ void TracyLlm::Draw() const auto isError = role == "error"; const auto isAssistant = role == "assistant"; const auto isToolResponse = isUser && line["content"].get_ref().starts_with( "\n" ); + const auto isForgotten = isToolResponse && line["content"].get_ref() == ForgetMsg; float diff, offset; - if( isToolResponse ) + if( isForgotten ) + { + diff = mw - cw; + offset = diff / 2; + ImGui::Dummy( ImVec2( offset, 0 ) ); + ImGui::SameLine( 0, 0 ); + ImGui::TextColored( style.Colors[ImGuiCol_TextDisabled], ICON_FA_RECYCLE ); + } + else if( isToolResponse ) { diff = mw - yw; offset = diff / 2; @@ -476,7 +486,12 @@ void TracyLlm::Draw() assert( false ); } - if( isToolResponse ) + if( isForgotten ) + { + ImGui::TextUnformatted( "Tool response removed to save context space" ); + treeIdx++; + } + else if( isToolResponse ) { ImGui::PushID( treeIdx++ ); auto expand = ImGui::TreeNode( "Tool response..." );