Skip to content

feat(proxy): add --reload flag for uvicorn hot reload (dev only) - #25901

Merged
ryan-crabbe-berri merged 3 commits into
litellm_internal_stagingfrom
litellm_feat-add-reload-flag-proxy
Apr 20, 2026
Merged

feat(proxy): add --reload flag for uvicorn hot reload (dev only)#25901
ryan-crabbe-berri merged 3 commits into
litellm_internal_stagingfrom
litellm_feat-add-reload-flag-proxy

Conversation

@ryan-crabbe-berri

@ryan-crabbe-berri ryan-crabbe-berri commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds an opt-in --reload CLI flag to litellm proxy that enables uvicorn's file-watching hot reload for local development.
  • Off by default. No env var, so it can't be set accidentally via Docker/k8s manifests in prod.
  • Only affects the uvicorn run path. --run_gunicorn and --run_hypercorn paths are untouched. Production deployments that don't pass the flag are unaffected.

Implementation

Three changes in litellm/proxy/proxy_cli.py (10 lines added, 0 removed):

  1. @click.option("--reload", is_flag=True, default=False, ...) decorator on run_server.
  2. reload: bool parameter in run_server signature.
  3. if reload: uvicorn_args["reload"] = True before the uvicorn.run(...) call.

Test plan

  • litellm --help shows the new --reload flag with help text.
  • Started proxy with --reload: uvicorn logged Started reloader process [55701] using StatReload.
  • Touched litellm/proxy/proxy_server.py: reloader logged StatReload detected changes ... Reloading..., old worker shut down, new worker came up with a different PID and reached Application startup complete.
  • Default behavior (no flag) is unchanged — uvicorn_args only gets reload=True when the user explicitly opts in.
  • CI passes.

Opt-in CLI flag, off by default, no env var. Only affects the uvicorn
run path; gunicorn/hypercorn paths and prod (which doesn't pass the
flag) are unaffected.
@vercel

vercel Bot commented Apr 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 16, 2026 8:54pm

Request Review

@greptile-apps

greptile-apps Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds an opt-in --reload CLI flag to the litellm proxy that enables uvicorn's built-in file-watching hot reload, intended for local development use only. The change is minimal (10 lines), correctly scoped to the uvicorn path only (behind the if run_gunicorn is False and run_hypercorn is False guard), and off by default.

Confidence Score: 5/5

Safe to merge — the change is off by default and correctly scoped to the uvicorn path only, with no risk to production deployments.

All remaining findings are P2 (the num_workers guard suggestion, already raised in a prior review). The core implementation is minimal, correct, and non-breaking.

No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/proxy_cli.py Adds --reload click option and corresponding reload: bool parameter; conditionally sets uvicorn_args["reload"] = True within the uvicorn-only code path. Change is minimal and correctly scoped.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["litellm --reload"] --> B{"run_gunicorn or run_hypercorn?"}
    B -- Yes --> C["gunicorn / hypercorn path — reload ignored"]
    B -- No --> D{"reload flag set?"}
    D -- Yes --> E["uvicorn_args reload = True"]
    D -- No --> F["uvicorn_args unchanged"]
    E --> G{"num_workers > 1?"}
    G -- Yes --> I["uvicorn raises ValueError"]
    G -- No --> J["StatReload watcher starts — hot reload active"]
    F --> H["uvicorn.run — normal startup"]
Loading

Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile

@yuneng-berri
yuneng-berri self-requested a review April 16, 2026 23:04
@codecov

codecov Bot commented Apr 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/proxy/proxy_cli.py 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ryan-crabbe-berri
ryan-crabbe-berri merged commit ea12bae into litellm_internal_staging Apr 20, 2026
97 of 99 checks passed
@ryan-crabbe-berri
ryan-crabbe-berri deleted the litellm_feat-add-reload-flag-proxy branch April 20, 2026 15:48
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…-flag-proxy

feat(proxy): add --reload flag for uvicorn hot reload (dev only)
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.

2 participants