Skip to content

feat(cli): add --reload-dir to dev for extra watch directories#5634

Open
korya wants to merge 1 commit intolivekit:mainfrom
korya:feat/reload-dir
Open

feat(cli): add --reload-dir to dev for extra watch directories#5634
korya wants to merge 1 commit intolivekit:mainfrom
korya:feat/reload-dir

Conversation

@korya
Copy link
Copy Markdown

@korya korya commented May 3, 2026

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 (and LIVEKIT_RELOAD_DIRS, os.pathsep-split) to dev. Resolved paths are unioned with the auto-discovered list and passed to the existing watchfiles.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())"]
Loading

Naming mirrors uvicorn's --reload-dir so muscle memory transfers.

Notes worth flagging

  • Missing path fails fast (exit 1, clear error). Silent skip would re-create the gap this PR closes.
  • PythonFilter is retained, so .git/, .venv/, __pycache__/, node_modules/, and non-.py files don't trigger reloads β€” even inside user-supplied dirs.
  • The flag does not split on commas (A,B β†’ single path). Only the env var splits on os.pathsep. Help text calls this out.
  • No allowlist gating (/, ~, paths above cwd): hard-rejecting outside cwd would break the very monorepo workflow this is for, and PythonFilter already drops the dangerous dirs.

Test plan

tests/test_reload_dir.py β€” 16 scenarios:

  • Defaults, repeated flag, env-var split, flag-overrides-env
  • Relative + ~ paths, symlink resolution
  • Missing path (flag + env) β†’ exit 1
  • CliArgs pickle round-trip
  • iTerm2 carve-out preserved (with and without --reload-dir)
  • WatchServer.run() unions auto + user paths, keeps PythonFilter
  • PythonFilter drops .git/HEAD, .venv/*.py, etc.
  • tests/test_cli_log_level.py (25 cases) still passes

Manual: dev --help shows the flag + env-var; dev --reload-dir /tmp/extra logs Watching /tmp/extra (user); bad path β†’ exit 1.

Changeset: .github/next-release/changeset-reload-dir.md (livekit-agents minor).

πŸ€– Generated with Claude Code

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>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

βœ… Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant