Skip to content

Support LIVEKIT_AGENT_NAME environment variable#1332

Merged
toubatbrian merged 4 commits intomainfrom
claude/port-python-to-js-fwnEY
Apr 28, 2026
Merged

Support LIVEKIT_AGENT_NAME environment variable#1332
toubatbrian merged 4 commits intomainfrom
claude/port-python-to-js-fwnEY

Conversation

@toubatbrian
Copy link
Copy Markdown
Contributor

Description

Add support for the LIVEKIT_AGENT_NAME environment variable to enable explicit agent dispatch. This aligns the TypeScript SDK with the Python SDK's behavior, allowing agents to be dispatched based on a name specified either via configuration or environment variable.

Changes Made

  • Added agentNameIsEnv boolean field to ServerOptions to track whether the agent name was sourced from the environment variable
  • Updated ServerOptions constructor to check for LIVEKIT_AGENT_NAME environment variable when agentName is not explicitly provided
  • Updated worker info response to include agent_name_is_env field for proper tracking on the server side
  • Added LIVEKIT_AGENT_NAME to the turbo.json environment variables list
  • Updated WorkerResponse interface to include the new agent_name_is_env field
  • Added comprehensive JSDoc comments explaining the explicit dispatch behavior
  • Added changeset entry for the patch release

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title
  • Video demo: N/A - Configuration feature

Testing

  • No automated tests needed - this is a straightforward configuration feature that mirrors existing Python SDK behavior
  • Changes are backward compatible; existing code without the environment variable will continue to work as before

Additional Notes

This change includes references to the corresponding Python SDK implementation (livekit-agents/livekit/agents/worker.py) for consistency and maintainability.

https://claude.ai/code/session_01DRRyse5LLFAuvWVf1LuJbr

Port from python livekit/agents#5571: when agentName is not provided
in ServerOptions, fall back to the LIVEKIT_AGENT_NAME environment
variable. The /worker HTTP endpoint now reports agent_name_is_env so
deployments can tell whether the explicit dispatch name came from code
or the environment.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 28, 2026

🦋 Changeset detected

Latest commit: 7419378

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

claude added 3 commits April 28, 2026 08:54
…tion

cli.ts reconstructs ServerOptions by spreading an existing instance, which
caused agentNameIsEnv to flip back to false when the resolved agentName
came from LIVEKIT_AGENT_NAME. Accept agentNameIsEnv as an optional
constructor parameter so the env-source signal survives re-construction.
@toubatbrian toubatbrian merged commit 54f108e into main Apr 28, 2026
8 of 9 checks passed
@toubatbrian toubatbrian deleted the claude/port-python-to-js-fwnEY branch April 28, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants