proud-match-31207
07/29/2025, 8:53 AMlivekit-agents@1.2.2 . I noticed there are changes around the chat context timestamps and the order of messages added:
1. It seems like the user transcript is added to agent session's chat ctx and conversation_item_added event is emitted after the LLM inference is invoked.
a. This is causing issues in the custom plugin that I had written, any way to make the agent session's chat ctx keep in sync too with latest transcript? I am adding some custom items to the agent session chat ctx that I want the LLM to have context of.
2. The created_at timestamp seems to have been also updated because of 1 I guess (?) where the created_at timestamp is now different for assistant role and has the timestamp of when the LLM started responding and the user utterances have the created_at when the user completes speaking.
a. Earlier in version 1.0.22 - the created_at for both assistant and user had timestamp when they completed their turn, this helped us infer the start timestamp to create a utterance level start and end timestamps from the transcript
b. In the newer version - we have the assistant's start timestamp and user's end timestamp which is harder to infer for utterance level start and end timestamps now.
c. I am unsure if we can do anything about this here?
I believe both these are being caused because of the older version - 1.0.22 had this change which is being updated in the new version with this change.
@jolly-air-155 - would really appreciate if you can suggest what I can do here to resolve this? Any reason the order was changed. I can raise a PR to have the message added before the llm inference. Would that help go back to the prev state?jolly-air-155
07/29/2025, 9:06 AMagent.chat_ctx after the llm inference starts, but the created_at of the user message is still the same as before, it’s the time user turn completed.proud-match-31207
07/29/2025, 9:08 AMcreated_at after the user turn completes. But the agent's created_at is when the agent starts speaking which is inconsistent behavior I feel.
Also - do you feel we should emit the conversation_item_added event before running the llm inference? I am unsure why that was changed in the recent version. I am happy to raise a PR to keep it the old wayjolly-air-155
07/29/2025, 9:09 AMjolly-air-155
07/29/2025, 9:12 AMagent.chat_ctx when llm generate starts, but after it confirms the user turn is done. for your case, I think we can customize the llm_node instead, and the chat ctx sent to the llm_node is always the version including the latest user messagejolly-air-155
07/29/2025, 9:12 AMon_user_turn_completed and add your custom messages to both turn_ctx and the agent.chat_ctx therejolly-air-155
07/29/2025, 9:14 AMthe user message has thethis is to fix the order when user interrupts the agent, so the order is (interrupted agent message, new user message), instead of (new user message, interrupted agent message)after the user turn completes. But the agent’screated_atis when the agent starts speaking which is inconsistent behavior I feel.created_at
proud-match-31207
07/29/2025, 9:17 AMagent.chat_ctx when llm generate starts, but after it confirms the user turn is done. for your case, I think we can customize the llm_node instead, and the chat ctx sent to the llm_node is always the version including the latest user message
I am merging the latest chat_ctx in the LLMStream class of the plugin and the agent ctx that I have which is resolving the issue of keeping the transcripts consistent before making LLM requests.
> this is to fix the order when user interrupts the agent, so the order is (interrupted agent message, new user message), instead of (new user message, interrupted agent message)
Understood on why this change was made. Thanks for explaining this.
Any way you suggest us to do the start and end time calculations for the user and assistant utterances in the latest version of the SDK? The created_at field being different for both of them is not allowing to infer either the start and end time for both of them.jolly-air-155
07/29/2025, 9:22 AMjolly-air-155
07/29/2025, 9:22 AMproud-match-31207
07/29/2025, 9:26 AMjolly-air-155
07/29/2025, 9:29 AMuser_state_changed and agent_state_changed event to monitor listening and speaking states.jolly-air-155
07/29/2025, 9:29 AMproud-match-31207
07/29/2025, 9:31 AMperhaps we can add a start time and a end time to the chat message thoYes - will this be added soon? I am happy to help contribute too. This will help multiple folks. I see issues around word level timestamps being exposed in chat ctx is needed for multiple users
jolly-air-155
07/29/2025, 9:34 AMproud-match-31207
07/29/2025, 9:39 AM