proxy: qualify reload_includes with absolute config path

Address Greptile review on PR #27274. When the --config file lives
outside cwd, reload_includes previously stored only the basename, which
meant uvicorn/watchfiles would also reload on edits to any same-named
file inside cwd. Use the absolute config path as the include pattern in
that case so only the actual proxy config triggers a restart.

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-05-06 03:31:58 +00:00
parent 04432e2a2c
commit c01d7a6f5a
No known key found for this signature in database
37 changed files with 12 additions and 2 deletions

View file

@ -188,7 +188,14 @@ class ProxyInitializationHelpers:
if config_dir and config_dir != cwd:
reload_dirs.append(config_dir)
options["reload_dirs"] = reload_dirs
options["reload_includes"] = ["*.py", os.path.basename(config_abs)]
# Qualify the config-file pattern with its directory so only the
# specific config file (not any same-named file in cwd) triggers a
# reload when config_dir != cwd.
if config_dir and config_dir != cwd:
config_include = config_abs
else:
config_include = os.path.basename(config_abs)
options["reload_includes"] = ["*.py", config_include]
return options
@staticmethod

View file

@ -161,7 +161,10 @@ class TestProxyInitializationHelpers:
assert opts["reload"] is True
assert opts["reload_dirs"] == [str(cwd_dir), str(elsewhere)]
assert opts["reload_includes"] == ["*.py", "proxy.yaml"]
# When config lives outside cwd, the reload_includes entry must be the
# absolute path so that a same-named file in cwd does not trigger an
# unintended reload.
assert opts["reload_includes"] == ["*.py", str(config_file)]
@patch("asyncio.run")
@patch("builtins.print")