The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Name comfy-agent without a version in agent_requirements.txt (CORE-692) (#17454)
Christian Byrnefb2b26fdac50
diff --git a/agent_requirements.txt b/agent_requirements.txtindex a4cca7397..90cae1ac6 100644--- a/agent_requirements.txt+++ b/agent_requirements.txt@@ -1 +1 @@-comfy-agent==0.0.0.dev0+comfy-agentdiff --git a/app/agent_host.py b/app/agent_host.pyindex 9db531b0f..726db94bf 100644--- a/app/agent_host.py+++ b/app/agent_host.py@@ -48,14 +48,16 @@ def load() -> bool:entry_points = {ep.name: ep for ep in importlib.metadata.entry_points(group=ENTRY_POINT_GROUP)}if PROTOCOL not in entry_points:# Some comfy-agent is installed (other protocols present) -> "update";- # nothing there -> "install".+ # nothing there -> "install". The file names the package without a+ # version, so only `-U` moves an old or placeholder install.+ req = os.path.join(os.path.dirname(os.path.abspath(folder_paths.__file__)), "agent_requirements.txt")+ install = f'pip install -U -r "{req}"'if entry_points:- logging.warning(f"The installed comfy-agent offers agent protocols {sorted(entry_points)}; this ComfyUI needs {PROTOCOL}. Update comfy-agent to use the agent.")+ logging.warning(f"The installed comfy-agent offers agent protocols {sorted(entry_points)}; this ComfyUI needs {PROTOCOL}. Update it with `{install}` to use the agent.")_failure = {"state": "failed", "reason": "outdated"}emit_event("agent_error", reason="outdated")else:- req = os.path.join(os.path.dirname(os.path.abspath(folder_paths.__file__)), "agent_requirements.txt")- logging.warning(f"`--enable-agent` was passed but the comfy-agent package is not installed, so the agent is disabled. Its requirements are in {req}.")+ logging.warning(f"`--enable-agent` was passed but the comfy-agent package is not installed, so the agent is disabled. Install it with `{install}`.")_failure = {"state": "failed", "reason": "package_missing"}emit_event("package_missing")_publish_flag()diff --git a/tests-unit/agent_requirements_test.py b/tests-unit/agent_requirements_test.pynew file mode 100644index 000000000..80b5a2609--- /dev/null+++ b/tests-unit/agent_requirements_test.py@@ -0,0 +1,32 @@+"""agent_requirements.txt is read by ComfyUI Desktop as well as by pip.++Desktop's agent version override (Comfy-Org/Comfy-Desktop,+src/main/lib/agentRequirementsOverride.ts) rewrites the agent line on each+launch and refuses the whole override, frontend pin included, for any line+that is not a bare name or `name==version`. A bare `comfy-agent` is what lets+it apply any rollout version, and it never downgrades an installed agent.+"""++import os+import re++REQUIREMENTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "agent_requirements.txt")+DESKTOP_LINE = re.compile(r"^\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*(?:==\s*([^\s;#]+))?\s*(?:#.*)?$")+++def _lines():+ with open(REQUIREMENTS, encoding="utf-8") as f:+ return [line for line in f.read().splitlines() if line.strip() and not line.lstrip().startswith("#")]+++def test_every_line_is_one_desktop_can_override():+ assert _lines()+ for line in _lines():+ assert DESKTOP_LINE.match(line), f"Desktop refuses its agent override for {line!r}"+++def test_the_agent_is_never_pinned():+ # An exact pin downgrades a newer agent on `pip install -r`, and Desktop+ # refuses a rollout version that is not newer than it.+ agent = [line for line in _lines() if DESKTOP_LINE.match(line).group(1) == "comfy-agent"]+ assert agent == ["comfy-agent"]diff --git a/tests-unit/app_test/agent_host_test.py b/tests-unit/app_test/agent_host_test.pyindex aa463d8a6..aa79dc5c0 100644--- a/tests-unit/app_test/agent_host_test.py+++ b/tests-unit/app_test/agent_host_test.py@@ -297,3 +297,17 @@ def test_start_runs_the_host_off_the_event_loop(monkeypatch):loop.run_until_complete(asyncio.wait_for(_until(lambda: agent_host._host.started), 5))finally:loop.close()++[email protected]("eps", [{}, {"v9": FakeHost}])+def test_the_install_hint_upgrades_from_agent_requirements(monkeypatch, caplog, eps):+ # agent_requirements.txt names the package without a version, so a plain+ # `pip install -r` leaves an old or placeholder comfy-agent in place.+ # Quoted: Windows profile paths often contain spaces.+ root = os.path.join(os.path.abspath(os.sep), "Users", "First Last", "ComfyUI")+ monkeypatch.setattr(folder_paths, "__file__", os.path.join(root, "folder_paths.py"))+ _entry_points(monkeypatch, eps)+ with caplog.at_level(logging.WARNING):+ agent_host.load()+ req = os.path.join(root, "agent_requirements.txt")+ assert any(f'pip install -U -r "{req}"' in r.getMessage() for r in caplog.records)