wooden-solstice-35084
11/12/2025, 12:56 PMtall-airline-16756
11/12/2025, 12:56 PMtall-airline-16756
11/12/2025, 12:56 PMuserdata? Also, do you clear or update it during the session?
• Have you noticed any particular moments when memory usage spikes?
• Are you using any custom changes to the restaurant_agent.py example?
Knowing these details will really help us find the best way to resolve this together.
Sources: Operational Best Practices | livekit/livekit_composite | DeepWikiwooden-solstice-35084
11/12/2025, 1:16 PMtall-airline-16756
11/12/2025, 1:17 PMdataclass for your userdata. This way, related data stays nicely grouped together, and you can avoid accidentally sharing mutable data. For instance, using field(default_factory=list) for collections ensures each instance is independent.
• Lazy Loading: It’s great that you’re already using lazy loading! Keep fetching or constructing agent data only when it’s really needed—this helps keep the initial load light.
• Minimize Data Retention: Regularly tidying up unused or outdated data in your userdata can make a big difference. Try to avoid holding onto large or unnecessary data longer than needed.
• Pass Context During Agent Handoff: When switching between agents, passing along the existing userdata helps keep everything seamless without creating duplicate states.
• Store References: Instead of copying big data objects, keeping references to shared resources can really help reduce memory use.
I hope these suggestions make your multi-agent workflow smoother and lighter on memory. If you want to dive deeper into any of these or need a hand with implementation, just let me know—I’m here to help!
Sources: Workflows | LiveKit Docs | lerobot/common/utils/buffer.py | VoiceAgent/Chat/Receive/TranscriptionStreamReceiver.swift | context-readmes/USERDATA_GUIDE.md | main.pywooden-solstice-35084
11/12/2025, 1:22 PMtall-airline-16756
11/12/2025, 1:24 PMuserdata. This approach keeps your agents lightweight and easy to scale.
• Clean Transitions: Using lifecycle methods such as onEnter() to initialize agents with well-managed context helps avoid duplicating data and keeps transitions clean.
Following these steps should make your memory usage more efficient and help prevent crashes in multi-agent workflows. If you’d like me to explain anything further or assist with putting these into practice, just let me know—I’m here to help!
Sources: main.py | Tool definition and use | LiveKit docs | Building Multi-Agent Architectures with LiveKit Agents | Workflows | LiveKit Docs | README.md