fix: route all agent loopback calls through internal_api_base() helper (#3322)

#2753 made the agent loopback base port-configurable but only for
_COOKBOOK_BASE in tool_implementations. Several other in-process loopback
calls still hardcoded http://localhost:7000 and broke off port 7000:
cookbook_serve_lifecycle (model-endpoints x2, shell/exec), builtin_actions
(model/serve), task_routes (calendar x3), and the gallery/email calls in
tool_implementations.

Extract the resolution (ODYSSEUS_INTERNAL_BASE / APP_PORT / 7000 fallback,
127.0.0.1 to avoid IPv6 ambiguity) into core.constants.internal_api_base()
and route every call site through it. Rename the now-misnamed _COOKBOOK_BASE
to _INTERNAL_BASE since it serves gallery/email/calendar/serve too. Adds a
test for the resolver plus a regression guard against reintroducing the
literal.

Part of #2752.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kenny Van de Maele
2026-06-07 23:22:09 +02:00
committed by GitHub
parent d85c5e335e
commit 76c1f42ab0
6 changed files with 116 additions and 53 deletions
+2 -1
View File
@@ -12,6 +12,7 @@ from typing import Tuple
from src.auth_helpers import owner_filter
from core.platform_compat import IS_WINDOWS, find_bash
from core.constants import internal_api_base
logger = logging.getLogger(__name__)
@@ -2118,7 +2119,7 @@ async def action_cookbook_serve(
try:
async with httpx.AsyncClient(timeout=30) as client:
r = await client.post("http://localhost:7000/api/model/serve",
r = await client.post(f"{internal_api_base()}/api/model/serve",
json=body, headers=headers)
data = r.json() if r.content else {}
except Exception as e: