I need to modify existing assistant messages in a ...
# ask-ai
c
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?
t
Thanks for reaching out, Clovis. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!