From 4c11a360e1cae7edd90cf5f9a6f3ad62c62b9d26 Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 21 Nov 2026 16:14:11 +0800 Subject: [PATCH] fix(runtime): give every docker sandbox the host-gateway mapping AGENTFLOW_SESSION_GATEWAY hands a native install's sandboxes a host.docker.internal URL, but --add-host host.docker.internal:host-gateway was only added for conversation and runner-login containers, so git credential fill in an SOP run sandbox failed with "lookup host.docker.internal ... no such host" and the MR node had to rediscover the docker bridge gateway on every run. Add the mapping to all sandboxes. --- CHANGELOG.md | 1 + internal/runtime/docker_cases_test.go | 4 ++-- internal/runtime/sandbox_docker.go | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11dfae5f0..192945982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Platform releases use `vX.Y.Z` tags and publish `ghcr.io/tencent/loopforge`. Loo - On macOS `/bin/bash` 3.2, a missing local image or a failed automatic mirror pull no longer aborts `./start.sh` before the official image pull. - `./start.sh` and `./start.sh pull` time `ghcr.io` and `ghcr.nju.edu.cn`. Nanjing is used only when the ghcr.io manifest digest was verified and the mirror returned the same digest; the pull is that digest, then tagged back to the name pinned in `compose.yaml`. A missing official digest, a digest mismatch, or a failed mirror pull stays on `ghcr.io`. `MIRROR=ghcr.io` forces the upstream registry; `MIRROR=` still forces that host and does not fall back. Accepting Nanjing, or setting `MIRROR`, trusts that host. The choice is not saved in `.env`. `registry-mirrors` such as `https://docker.nju.edu.cn` only accelerates Docker Hub. +- Docker sandboxes always get `--add-host host.docker.internal:host-gateway`. A native install hands every sandbox an `AGENTFLOW_SESSION_GATEWAY` URL on `host.docker.internal`, but the mapping was only added for conversation and runner-login containers, so `git credential fill` in an SOP run sandbox failed with `lookup host.docker.internal ... no such host` and the 发起 MR agent had to rediscover the docker bridge gateway on every run. The mapping now applies to all sandboxes. ## 0.4.0 — scheduled task history, an MR node in delivery SOPs and agent CLIs in conversation workspaces diff --git a/internal/runtime/docker_cases_test.go b/internal/runtime/docker_cases_test.go index f390d1a24..9aa0c3113 100644 --- a/internal/runtime/docker_cases_test.go +++ b/internal/runtime/docker_cases_test.go @@ -131,8 +131,8 @@ func TestDockerSandboxUsesRelayNetworkOnlyWhenRequested(t *testing.T) { t.Fatalf("docker create used the wrong network: %s", args) } usesGateway := strings.Contains(args, "\n--add-host\nhost.docker.internal:host-gateway\n") - if usesGateway != (tc.conversation || tc.runnerLoginRelay) { - t.Fatalf("docker create host gateway = %v for %s", usesGateway, tc.name) + if !usesGateway { + t.Fatalf("docker create missing host gateway mapping for %s: %s", tc.name, args) } }) } diff --git a/internal/runtime/sandbox_docker.go b/internal/runtime/sandbox_docker.go index c4fb30fa6..7b8ee689c 100644 --- a/internal/runtime/sandbox_docker.go +++ b/internal/runtime/sandbox_docker.go @@ -766,6 +766,11 @@ func (s *dockerSandbox) start(ctx context.Context, recreate bool) error { } } network := strings.TrimSpace(os.Getenv("AGENTFLOW_DOCKER_NETWORK")) + // Sandboxes reach a native platform through the host-gateway alias: + // AGENTFLOW_SESSION_GATEWAY hands them a host.docker.internal URL, and + // Linux daemons only resolve that name when the container carries the + // mapping. Add it for every sandbox, not only conversation relays. + args = append(args, "--add-host", "host.docker.internal:host-gateway") if s.requirements.ConversationRoot != "" || s.requirements.RunnerLoginRelay { _, relayNetwork, err := conversationDockerAccess(ctx) if err != nil { @@ -774,7 +779,6 @@ func (s *dockerSandbox) start(ctx context.Context, recreate bool) error { if relayNetwork != "" { network = relayNetwork } - args = append(args, "--add-host", "host.docker.internal:host-gateway") } if network != "" { args = append(args, "--network", network)