Use exact tokens count when available in server response.

Note that this is not really exacy, as it includes system prompt reminder
and possibly other input data that is dynamically injected.
This commit is contained in:
Bartosz Taudul
2025-06-29 00:53:03 +02:00
parent 047fa3b98f
commit 4969be344e

View File

@@ -825,6 +825,12 @@ bool TracyLlm::OnResponse( const nlohmann::json& json )
if( done )
{
if( json.contains( "usage" ) )
{
auto& usage = json["usage"];
if( usage.contains( "total_tokens" ) ) m_usedCtx = usage["total_tokens"].get<int>();
}
bool isTool = false;
auto& str = back["content"].get_ref<const std::string&>();
if( !str.starts_with( "<debug>" ) )