straight-jelly-92105
11/12/2025, 3:57 PMtall-airline-16756
11/12/2025, 3:57 PMtall-airline-16756
11/12/2025, 3:58 PM@function_tool decorator, which makes transitions really smooth.
• Create Configuration: Next, run the lk agent config command to generate a livekit.yaml file that holds all your agent metadata. Then, deploy your agents with lk agent deploy.
• Run Agents: When you’re ready to run your agents, use python myagent.py dev for development mode or python myagent.py start for production.
• Enable Auto-Start: To keep things running without a hitch, I recommend using a process manager like supervisord. This will help your agents start automatically and restart if anything unexpected happens. Just make sure your supervisord.conf includes autostart=true and autorestart=unexpected.
If you’re looking to build more advanced workflows, you might find the Restaurant Agent or Drive-thru Agent examples really helpful for coordinating multiple agents. Feel free to reach out if you want me to walk you through those or if you have any other questions—I’m here to help!
Sources: steam-headless/overlay/etc/supervisord.conf | README.md | An open source stack for real-time multimodal AI | test/agents.go | Workflows | LiveKit Docsstraight-jelly-92105
11/12/2025, 3:59 PMtall-airline-16756
11/12/2025, 4:00 PMLIVEKIT_URL, LIVEKIT_API_KEY, and `LIVEKIT_API_SECRET`—these are essential for your agents to connect properly.
• Containerization: Next, create Docker images for your agents. You can use the Dockerfiles provided in the starter projects, or tweak them to suit your needs.
• Deployment: When you’re ready, deploy your agents to platforms like Fly.io or Kubernetes. For Fly.io, you’ll set secrets using fly secrets set and then deploy with fly deploy. On Kubernetes, use deployment manifests to define how many replicas you want and set resource limits.
• Scaling: You can scale your agents manually or set up autoscaling based on metrics. For example, Fly.io lets you use fly scale count, and Kubernetes offers the Horizontal Pod Autoscaler (HPA) for this purpose.
• Load Balancing: The great news is that LiveKit automatically balances jobs across your available agents, so you don’t need to worry about adding an extra load balancer.
• Monitoring: Keep an eye on your agents using the LiveKit CLI. Commands like lk agent status give you real-time updates on deployment health, and you can check logs or manage deployments easily.
If you’d like, I can also provide specific deployment templates or guide you further with your custom setup—just let me know! I’m here to help every step of the way.
Sources: cmd/lk/agent.go | livekit/livekit_cloud_agent.pb.go | Sources/LiveKit/Types/RoomConfiguration.swift | Deploying to custom environments | LiveKit Docs | README.mdstraight-jelly-92105
11/12/2025, 4:02 PMtall-airline-16756
11/12/2025, 4:03 PMstraight-jelly-92105
11/12/2025, 4:04 PMtall-airline-16756
11/12/2025, 4:05 PMLIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET so your agents can connect smoothly to the LiveKit server.
• Autoscaling: You'll want to handle autoscaling at the infrastructure level, and here are some ways to do that:
1. Cloud VM Autoscaling: If you're using cloud providers, tools like AWS EC2 Auto Scaling Groups, GCP Managed Instance Groups, or Azure Virtual Machine Scale Sets can help scale your VMs based on CPU, memory, or custom metrics.
2. Kubernetes: For Kubernetes users, configuring the Horizontal Pod Autoscaler (HPA) is a great option to scale your agent pods based on CPU or custom metrics. The LiveKit Helm chart makes deployment easier here.
3. Self-Managed Autoscaling: If you're working with on-prem or bare-metal VMs, you can use Prometheus to keep an eye on metrics and create a custom script that starts or stops VMs or containers depending on the load.
• Load Balancing: A nice thing about LiveKit is that it automatically balances jobs across agents, so you usually won’t need an extra load balancer unless your agents expose HTTP endpoints.
• Example: If you’re using platforms like Fly.io, they support autoscaling based on metrics. You can easily adjust the number of agent instances using fly scale count.
If you’d like, I’m happy to provide a sample script or configuration template tailored to your specific platform—just let me know!
Sources: Deploying to custom environments | LiveKit Docs | fly.io/README.md | deploy/README.md | examples/server-gke-vpc-native.yaml | Self-hosting the Egress Service | LiveKit docsstraight-jelly-92105
11/12/2025, 4:07 PMtall-airline-16756
11/12/2025, 4:07 PMLIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET.
• Deployment: Finally, deploy your Docker image to a VM. Here are some options you might consider:
1. Render: Set up an environment group for LiveKit secrets, create a blueprint pointing to your repository, and deploy your agent seamlessly.
2. *Fly.io:* Use the Fly CLI to create an app, configure your secrets, and deploy the agent using a fly.toml configuration file.
3. Custom VM: Run the container directly on your VM using Docker or systemd. For autoscaling, you can integrate cloud-native tools like AWS Auto Scaling Groups or GCP Managed Instance Groups.
If you’d like, I’m here to help with specific templates, deployment scripts, or setting up automation workflows—just let me know!
Sources: Deploying to custom environments | LiveKit docs | Deploying to custom environments | LiveKit Docs | fly.io/README.mdstraight-jelly-92105
11/12/2025, 4:09 PMtall-airline-16756
11/12/2025, 4:10 PM@function_tool
async def dynamically_created_tool(context: RunContext, parameter: str):
"""Tool created at runtime based on conditions"""
# Dynamic logic here
return result
• Dynamic Instruction Updates: You can modify the agent's behavior on the fly using update_instructions, allowing you to shift the agent's focus or capabilities as needed.
• Context Variables: Inject dynamic information through context variables to influence how the agent responds.
• Multi-Agent Handoff: Create and switch to specialized agents dynamically depending on the task. For instance:
@function_tool
async def switch_to_specialized_agent(context: RunContext, task_type: str):
"""Dynamically create and switch to a specialized agent"""
if task_type == "story":
new_agent = StoryAgent(context.userdata.name, context.userdata.location)
return new_agent, "Switching to story mode!"
• RPC-Based Control: Register RPC methods so external systems can dynamically adjust agent behavior or add new features.
• Examples: I recommend checking out the LiveKit examples repository—it has great demos on dynamic tool creation, updating agent instructions, and managing multi-agent systems.
If you'd like, I can provide a specific implementation example or assist you further. Just let me know—I'm here to help!
Sources: README.md | avatars/hedra/README.md