How can I grab the message id of AzureAIAgent assistant responses? #12909
mollaosmanoglu
started this conversation in
General
Replies: 1 comment
-
Hi @mollaosmanoglu, thanks for surfacing this and for the feedback. We appreciate it. In |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I’m using Semantic Kernel (Python) with Azure AI Agents and running into a frustrating limitation.
In my app, I stream responses from the agent and extract citations from StreamingAnnotationContent chunks. The idea is to pair those citations with the exact assistant message they came from so my frontend can contain the citations in the user/assistant pair, which means I need the assistant message’s service id.
The problem is: SK doesn’t expose the Azure message id on the streamed message objects, only the thread_id. For the user message it’s fine, I create it manually via client.agents.messages.create(...) and get its id right away. But for the assistant message, SK starts streaming without giving me its id.
The only workaround I’ve found is to, right after the first streamed delta, poll client.agents.messages.list(thread_id, order="desc", limit=1) to grab the latest assistant message’s id and then attach citations to it.
So the question is: is there any way in SK to get the assistant message id immediately when streaming starts? Or do I have to either keep polling or ditch SK and consume the Azure AI Agents stream directly since it provides a thread.message.created event which includes the message id?
Beta Was this translation helpful? Give feedback.
All reactions