semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net: Python: [New Group Chat Orchestration] LLM Prompt usage not available in metadata of the orchestration result

Open sushaanttb opened this issue 5 months ago • 8 comments

[SK version - 1.32.0] Unlike general metadata field with LLM prompts usage info which is available in ChatMessageContent objects, same is not available in the final response from the new group chat orchestration result.

Please suggest how to get the LLM prompt usage metadata for the final response from orchestration?

This is required for observability of my orchestration component.

Image

sushaanttb avatar Jun 20 '25 07:06 sushaanttb

Hi @markwallace-microsoft thanks for tagging this for triage!

I’m exploring this issue further and noticed that while ChatMessageContent retains prompt usage metadata, the final_response from orchestration_result.get() doesn't expose it directly — as shown in the debug logs.

Is this an intentional design, or is support for exposing such metadata in final_response planned in future updates?

Also, I’d be happy to help contribute a fix or improvement if this is something the team would be open to. Just let me know if there's any specific direction or constraint you'd suggest following.

Thanks again!

SuvitKumar003 avatar Jun 21 '25 16:06 SuvitKumar003

Hi @moonbox3 Would appreciate an update for this.

sushaanttb avatar Jun 27 '25 05:06 sushaanttb

This isn't intentional to not include usage metadata, looks like it was simply a miss. @SuvitKumar003 please feel free to work on this if you have time.

moonbox3 avatar Jul 02 '25 05:07 moonbox3

Hi @sushaanttb,

Thank you for posting the issue!

Are you looking for the token usage of just the final response or the total toke usage of the entire run of the orchestration?

TaoChenOSU avatar Jul 16 '25 20:07 TaoChenOSU

Hi @sushaanttb,

In Python, the result of the group chat orchestration is produced by the manager's filter_results method: https://learn.microsoft.com/en-us/semantic-kernel/frameworks/agent/agent-orchestration/group-chat?pivots=programming-language-python#customize-the-group-chat-manager.

The return value of the filter_results method is a MessageResult. If you are using the default round robin manager, you should get the message generated by the last agent who spoke, which should contain the metadata of the response. If you are customizing your own group chat manager, please make sure you are including the metadata in the ChatMessageContent.

TaoChenOSU avatar Jul 23 '25 20:07 TaoChenOSU

@TaoChenOSU - This is flagged for both Python and .NET analysis.

crickman avatar Jul 25 '25 00:07 crickman

@TaoChenOSU - This is flagged for both Python and .NET analysis.

Will look at the .Net side too

TaoChenOSU avatar Jul 25 '25 22:07 TaoChenOSU

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar Oct 24 '25 02:10 github-actions[bot]