agents
agents copied to clipboard
Metadata Revert Bug
Bug Description
Hey, I've encountered this strange behaviour of local_participant.metadata: it automatically reverts to arbitrary previous state before shutdown_callback.
I've setup a minimal example here: https://github.com/ivanpuhachov/debug-agent-starter-python. TLDR: I use @session.on("conversation_item_added") and execute await ctx.room.local_participant.set_metadata(content) passing the last message added to the conversation.
I am also watching for @ctx.room.on("participant_metadata_changed") and reporting each metadata change.
Agent is hosted locally, accessed through livekit Agents Playground
Here is a log example:
---> on_conversation_item_added
conversation text: Goodbye! Have a wonderful day.
---> metadata_update_handler
---> participant_metadata_changed
2025-11-13 15:51:59,521 - INFO root - metadata changed FROM Once upon a time in a quiet town, there lived a small terrier named Milo. Milo had a shiny black coat and a nose that could sniff out trouble from a mile away. Every morning, he would trot down the lane, tail wagging, greeting the baker with a friendly bark and the postman with a polite nod.
One rainy afternoon, a stray cat named Whisper slipped into Milo’s yard. Whisper was sleek and scared, her -TO- Goodbye! Have a wonderful day. {"room": "playground-O3xD-I4ZM", "pid": 86459, "job_id": "AJ_Lavvez8WBJSE"}
---> participant_metadata_changed
2025-11-13 15:51:59,541 - INFO root - metadata changed FROM Goodbye! Have a wonderful day. -TO- Once upon a time in a quiet town, there lived a small terrier named Milo. Milo had a shiny black coat and a nose that could sniff out trouble from a mile away. Every morning, he would trot down the lane, tail wagging, greeting the baker with a friendly bark and the postman with a polite nod.
As you see, at 2025-11-13 15:51:59,521 metadata was correctly changed to Goodbye! Have a wonderful day. (last message in the conversation). Hovewer, right after that the metadata got reversed back to Once upon a time... without any on_conversation_item_added event. Why?
Expected Behavior
I expect metadata to stay unchanged.
Reproduction Steps
https://github.com/ivanpuhachov/debug-agent-starter-python
Operating System
macOS
Models Used
Deepgram Nova-3, Groq openai/gpt-oss-20b, Cartesia Sonic-3
Package Versions
livekit==1.0.19, livekit-agents==1.2.18
Session/Room/Call IDs
"room": "playground-O3xD-I4ZM", "pid": 86459, "job_id": "AJ_Lavvez8WBJSE" Agent is hosted locally, accessed through livekit Agents Playground
Proposed Solution
Additional Context
No response
Screenshots and Recordings
---> on_conversation_item_added
conversation text: You. Goodbye.
---> metadata_update_handler
---> participant_metadata_changed
2025-11-13 15:51:56,793 - INFO root - metadata changed FROM Once upon a time in a quiet town, there lived a small terrier named Milo. Milo had a shiny black coat and a nose that could sniff out trouble from a mile away. Every morning, he would trot down the lane, tail wagging, greeting the baker with a friendly bark and the postman with a polite nod.
One rainy afternoon, a stray cat named Whisper slipped into Milo’s yard. Whisper was sleek and scared, her -TO- You. Goodbye. {"room": "playground-O3xD-I4ZM", "pid": 86459, "job_id": "AJ_Lavvez8WBJSE"}
---> participant_metadata_changed
2025-11-13 15:51:56,819 - INFO root - metadata changed FROM You. Goodbye. -TO- Once upon a time in a quiet town, there lived a small terrier named Milo. Milo had a shiny black coat and a nose that could sniff out trouble from a mile away. Every morning, he would trot down the lane, tail wagging, greeting the baker with a friendly bark and the postman with a polite nod.
One rainy afternoon, a stray cat named Whisper slipped into Milo’s yard. Whisper was sleek and scared, her {"room": "playground-O3xD-I4ZM", "pid": 86459, "job_id": "AJ_Lavvez8WBJSE"}
---> on_conversation_item_added
conversation text: Goodbye! Have a wonderful day.
---> metadata_update_handler
---> participant_metadata_changed
2025-11-13 15:51:59,521 - INFO root - metadata changed FROM Once upon a time in a quiet town, there lived a small terrier named Milo. Milo had a shiny black coat and a nose that could sniff out trouble from a mile away. Every morning, he would trot down the lane, tail wagging, greeting the baker with a friendly bark and the postman with a polite nod.
One rainy afternoon, a stray cat named Whisper slipped into Milo’s yard. Whisper was sleek and scared, her -TO- Goodbye! Have a wonderful day. {"room": "playground-O3xD-I4ZM", "pid": 86459, "job_id": "AJ_Lavvez8WBJSE"}
---> participant_metadata_changed
2025-11-13 15:51:59,541 - INFO root - metadata changed FROM Goodbye! Have a wonderful day. -TO- Once upon a time in a quiet town, there lived a small terrier named Milo. Milo had a shiny black coat and a nose that could sniff out trouble from a mile away. Every morning, he would trot down the lane, tail wagging, greeting the baker with a friendly bark and the postman with a polite nod.
One rainy afternoon, a stray cat named Whisper slipped into Milo’s yard. Whisper was sleek and scared, her {"room": "playground-O3xD-I4ZM", "pid": 86459, "job_id": "AJ_Lavvez8WBJSE"}
2025-11-13 15:52:00,878 - INFO livekit.agents - closing agent session due to participant disconnect (disable via `RoomInputOptions.close_on_disconnect=False`) {"room": "playground-O3xD-I4ZM", "participant": "identity-4iu6", "reason": "CLIENT_INITIATED", "pid": 86459, "job_id": "AJ_Lavvez8WBJSE"}
2025-11-13 15:52:00,879 - DEBUG livekit.agents - stream closed {"room": "playground-O3xD-I4ZM", "participant": "identity-4iu6", "source": "SOURCE_MICROPHONE", "pid": 86459, "job_id": "AJ_Lavvez8WBJSE"}
2025-11-13 15:52:00,884 - DEBUG livekit.agents - input stream detached {"room": "playground-O3xD-I4ZM", "participant": "identity-4iu6", "source": "SOURCE_UNKNOWN", "accepted_sources": ["SOURCE_MICROPHONE"], "pid": 86459, "job_id": "AJ_Lavvez8WBJSE"}
2025-11-13 15:52:02,890 - DEBUG livekit.agents - session closed {"room": "playground-O3xD-I4ZM", "reason": "participant_disconnected", "error": null, "pid": 86459, "job_id": "AJ_Lavvez8WBJSE"}
== attributes ==== attributes ==== attributes ==== attributes ==
{'lk.agent_name': '', 'lk.agent.state': 'listening'}
== metadata ==== metadata ==== metadata ==== metadata ==
Once upon a time in a quiet town, there lived a small terrier named Milo. Milo had a shiny black coat and a nose that could sniff out trouble from a mile away. Every morning, he would trot down the lane, tail wagging, greeting the baker with a friendly bark and the postman with a polite nod.
One rainy afternoon, a stray cat named Whisper slipped into Milo’s yard. Whisper was sleek and scared, her
== job metadata ==== job metadata ==== job metadata ==== job metadata ==
====================