The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(a2a): scope A2A_PUBLIC_URL per multiplex profile
EloquentBrush0x8c58e4f97651
diff --git a/plugins/platforms/a2a/adapter.py b/plugins/platforms/a2a/adapter.pyindex bdb1b5fb8a5..79fbe9fe912 100644--- a/plugins/platforms/a2a/adapter.py+++ b/plugins/platforms/a2a/adapter.py@@ -179,8 +179,13 @@ class A2ARequestHandler(BaseHTTPRequestHandler):"""A2A_PUBLIC_URL > X-Forwarded-Host / Host (scheme from X-Forwarded-Proto) > "" (bind host).Empty means "caller has no info, fall back to bind host". See #41711.++ A2A_PUBLIC_URL is read from ``self.adapter`` (captured at construction time, inside profile+ scope) rather than os.getenv here: do_GET/do_POST run on ThreadingHTTPServer's per-connection+ OS threads, which never inherit the profile scope contextvar, so a secondary multiplex+ profile's own A2A_PUBLIC_URL would otherwise resolve to the default profile's env value."""- explicit = os.getenv("A2A_PUBLIC_URL", "").strip()+ explicit = self.adapter._public_urlif explicit:return explicithost = (self.headers.get("X-Forwarded-Host", "") or self.headers.get("Host", "")).split(",")[0].strip()@@ -271,6 +276,10 @@ class A2AAdapter(BasePlatformAdapter):configured_toolsets = list(extra.get("advertised_toolsets") or []) or _get_scoped_secret("A2A_ADVERTISED_TOOLSETS", "").split(",")self._advertised_toolsets = [t.strip() for t in configured_toolsets if str(t).strip()]self._active_profile = _active_profile_name()+ # Captured here (construction runs inside _profile_runtime_scope), not read at request time:+ # do_GET/do_POST run on ThreadingHTTPServer's per-connection OS threads, which never inherit+ # the profile scope contextvar (same class as A2A_PORT above).+ self._public_url = _get_scoped_secret("A2A_PUBLIC_URL", "").strip()self._agents = self._load_served_agents(extra)self._httpd: Optional[ThreadingHTTPServer] = Noneself._server_thread = self._watchdog_thread = None # type: Optional[threading.Thread]diff --git a/tests/plugins/test_a2a_plugin.py b/tests/plugins/test_a2a_plugin.pyindex 4dcd1870f2b..959d12caa5f 100644--- a/tests/plugins/test_a2a_plugin.py+++ b/tests/plugins/test_a2a_plugin.py@@ -1660,6 +1660,7 @@ _A2A_ENV_VARS = ("A2A_AGENT_NAME","A2A_ADVERTISED_TOOLSETS","A2A_AGENT_DESCRIPTION",+ "A2A_PUBLIC_URL",)@@ -1699,6 +1700,7 @@ def default_profile_env(monkeypatch):monkeypatch.setenv("A2A_AGENT_NAME", "default-profile-agent")monkeypatch.setenv("A2A_ADVERTISED_TOOLSETS", "default-only-toolset")monkeypatch.setenv("A2A_AGENT_DESCRIPTION", "Default profile's own agent.")+ monkeypatch.setenv("A2A_PUBLIC_URL", "https://default-profile.example.com/")class TestMultiplexConstructionScope:@@ -1721,6 +1723,10 @@ class TestMultiplexConstructionScope:assert adapter._agents[""]["description"] == ("Hermes Agent — a general-purpose agent reachable over A2A.")+ # _public_url was captured at construction time via a bare os.getenv, missed by the+ # scoped retrofit the sibling fields above already got.+ assert adapter._public_url != "https://default-profile.example.com/"+ assert adapter._public_url == ""def test_default_profile_unscoped_keeps_env_precedence(self, monkeypatch, default_profile_env@@ -1739,3 +1745,4 @@ class TestMultiplexConstructionScope:assert adapter.port == 9111assert adapter.agent_name == "default-profile-agent"assert adapter._agents[""]["description"] == "Default profile's own agent."+ assert adapter._public_url == "https://default-profile.example.com/"