feat(cli): add --reload-dir to dev for extra watch directories#5634
Open
korya wants to merge 1 commit intolivekit:mainfrom
Open
feat(cli): add --reload-dir to dev for extra watch directories#5634korya wants to merge 1 commit intolivekit:mainfrom
korya wants to merge 1 commit intolivekit:mainfrom
Conversation
Lets users extend the dev-mode auto-reload watch list with additional directories (repeatable flag, also LIVEKIT_RELOAD_DIRS env var, split on os.pathsep). Auto-discovery of the entrypoint, livekit.agents, and editable plugins is unchanged; this is purely additive. Without this, edits to sibling packages the agent imports from (common in monorepo layouts) silently don't trigger a reload β the worker keeps holding the old module objects with no warning. Mirrors uvicorn's --reload-dir. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
dev-mode auto-reload only watches the entrypoint,livekit.agents, and editable plugins. Edits to other packages the agent imports (shared utility code mounted editable in monorepos) are silently ignored β the worker keeps holding stale module objects with no warning.Solution
Add repeatable
--reload-dir(andLIVEKIT_RELOAD_DIRS,os.pathsep-split) todev. Resolved paths are unioned with the auto-discovered list and passed to the existingwatchfiles.arun_process. Auto-discovery is unchanged; omitting the flag preserves identical behavior.flowchart LR F["--reload-dir / LIVEKIT_RELOAD_DIRS"] --> CA[CliArgs.reload_dirs] AD[_find_watchable_paths<br/>main + livekit.agents + plugins] --> U[union] CA --> U U --> AP["watchfiles.arun_process(*paths,<br/>watch_filter=PythonFilter())"]Naming mirrors uvicorn's
--reload-dirso muscle memory transfers.Notes worth flagging
PythonFilteris retained, so.git/,.venv/,__pycache__/,node_modules/, and non-.pyfiles don't trigger reloads β even inside user-supplied dirs.A,Bβ single path). Only the env var splits onos.pathsep. Help text calls this out./,~, paths abovecwd): hard-rejecting outsidecwdwould break the very monorepo workflow this is for, andPythonFilteralready drops the dangerous dirs.Test plan
tests/test_reload_dir.pyβ 16 scenarios:~paths, symlink resolutionCliArgspickle round-trip--reload-dir)WatchServer.run()unions auto + user paths, keepsPythonFilterPythonFilterdrops.git/HEAD,.venv/*.py, etc.tests/test_cli_log_level.py(25 cases) still passesManual:
dev --helpshows the flag + env-var;dev --reload-dir /tmp/extralogsWatching /tmp/extra (user); bad path β exit 1.Changeset:
.github/next-release/changeset-reload-dir.md(livekit-agents minor).π€ Generated with Claude Code