From 967df77e531be3db3eca3967482d1099bc8b407b Mon Sep 17 00:00:00 2001 From: Ilker Manap Date: Mon, 12 Oct 2026 23:28:22 +0200 Subject: [PATCH] The agent hands the gate the repository a node loads its weights by MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sf3d's first jobs failed with a 401 from stabilityai/stable-fast-3d. The weights were on the node, and the gate links them into the Hugging Face cache when told the repository — but the agent passed on only the custom nodes, so nothing was linked and the node went to the network for a gated repository. Co-Authored-By: Claude Opus 5.5 (1M context) --- internal/agent/engines/comfyui.go | 17 +++++++++++++---- internal/agent/engines/comfyui_test.go | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/internal/agent/engines/comfyui.go b/internal/agent/engines/comfyui.go index a434e8c..d92e9b7 100644 --- a/internal/agent/engines/comfyui.go +++ b/internal/agent/engines/comfyui.go @@ -124,10 +124,15 @@ func (c *ComfyUI) Commands(s ShardSpec) ([]Command, error) { if s.APIKey != "" { env["LLMGW_ENGINE_KEY"] = s.APIKey } - // A model's custom nodes, which only the catalog sets — a profile's env - // may not name the variable — and so taken before baseEnv drops it. - if nodes := p.Env[comfyNodesEnv]; nodes != "" { - env[comfyNodesEnv] = nodes + // A model's custom nodes and the repository a node loads its weights by, + // which only the catalog sets — a profile's env may not name them — and + // so taken before baseEnv drops them. Without the repository the gate + // links no Hugging Face cache, and sf3d's node went to the network for + // its gated repository and was refused with a 401. + for _, k := range []string{comfyNodesEnv, comfyHFRepoEnv} { + if v := p.Env[k]; v != "" { + env[k] = v + } } return []Command{{Name: "comfyui", Path: bin, Args: args, Env: materializeEnv(env)}}, nil } @@ -135,3 +140,7 @@ func (c *ComfyUI) Commands(s ShardSpec) ([]Command, error) { // comfyNodesEnv is the custom nodes the catalog gives a ComfyUI model, as // JSON; catalog.NodesEnv and comfy.NodesEnv by the same name. const comfyNodesEnv = "LLMGW_COMFYUI_NODES" + +// comfyHFRepoEnv is the repository a custom node loads the weights by name +// from; catalog.HFRepoEnv and comfy.HFRepoEnv by the same name. +const comfyHFRepoEnv = "LLMGW_COMFYUI_HF_REPO" diff --git a/internal/agent/engines/comfyui_test.go b/internal/agent/engines/comfyui_test.go index ea92818..cd915c9 100644 --- a/internal/agent/engines/comfyui_test.go +++ b/internal/agent/engines/comfyui_test.go @@ -33,6 +33,25 @@ func TestComfyUIRunsBehindTheGateWithItsKeyOutOfSight(t *testing.T) { } } +func TestTheGateIsToldTheNodesAndTheRepositoryTheCatalogGives(t *testing.T) { + // The repository was dropped on the way: sf3d's node went to the network + // for its gated repository, with no cache linked, and got a 401. + c := &ComfyUI{cfg: ComfyUIConfig{Dir: "/opt/comfyui"}} + cmds, err := c.Commands(ShardSpec{ + ReplicaID: "r-sf3d-1", HTTPPort: 8100, BindAddr: "10.0.0.147", GPUIndices: []int{0}, + Profile: Profile{Name: "p", Engine: "comfyui", ModelPath: "/w/sf3d/", ServedModelName: "sf3d", + Env: map[string]string{comfyNodesEnv: `[{"repo":"x"}]`, comfyHFRepoEnv: "stabilityai/stable-fast-3d"}}, + }) + if err != nil || len(cmds) != 1 { + t.Fatalf("%v %v", cmds, err) + } + for _, want := range []string{comfyNodesEnv + `=[{"repo":"x"}]`, comfyHFRepoEnv + "=stabilityai/stable-fast-3d"} { + if !slices.Contains(cmds[0].Env, want) { + t.Errorf("%q not in the gate's environment", want) + } + } +} + func TestComfyUIRunsOnOneCard(t *testing.T) { c := &ComfyUI{} if err := c.Validate(Profile{Name: "p", ModelPath: "/w", TP: 2}, h100(2)); err == nil {