TTMSMCPCloudAI token count only reports the last tool call

Hi,

I noticed a possible issue with the token usage reported by TTMSMCPCloudAI when an OpenAI conversation involves one or more tool calls.

At the end of the conversation, the component appears to report only the number of tokens used by the final OpenAI API call, rather than the total number of tokens used by the entire conversation flow.

For example, in one of my tests, TTMSMCPCloudAI reported a total usage of:

15010 tokens

However, when I checked the OpenAI dashboard logs for the same task, I found three separate API calls with the following token usage:

7135 tokens
9590 tokens
15010 tokens

Therefore, the total number of tokens used by the complete task should be:

7135 + 9590 + 15010 = 31735 tokens

It seems that the token usage value exposed by the component is overwritten after each tool-related API call and, at the end, contains only the usage of the last call.

Is this the expected behaviour?

Would it be possible for the component to expose both:

  • the token usage of the latest API call;
  • the cumulative token usage of the entire conversation or task, including all tool calls?

This would be useful for accurately monitoring API usage and calculating the actual cost of each user request.

Thank you.

Is this with the latest version of TMS AI Studio v1.7.3.0?

Yes, I’m using the latest version of TMS AI Studio, v1.7.3.0.

I read the number of used tokens in the OnExecuted event through the AResponse.TotalTokens property.

Thanks for reporting.
We applied an improvement that will be in the next release.