I need to modify existing assistant messages in a ChatContext to add a "name" field for agent attribution before sending to LLM. I can see that
ChatContext has an add_message() method for adding new messages, but how do I:
1. Iterate through existing messages in a ChatContext?
2. Modify existing ChatMessage objects to add a "name" attribute?
3. Properly update/replace messages in the ChatContext?
I'm trying to follow the same pattern used for tool summaries where we do:
modifiable_ctx = self.chat_ctx.copy()
modifiable_ctx.add_message(role="system", content=summary)
await self.update_chat_ctx(modifiable_ctx)
But instead of adding new messages, I need to modify existing assistant messages to add agent names for proper attribution across agent handoffs.
What's the correct way to access and modify existing messages in a LiveKit ChatContext?