From b0276a732a01ae059e03105c84097216bc4a7f25 Mon Sep 17 00:00:00 2001 From: amoussa1229 <166072409+amoussa1229@users.noreply.github.com> Date: Thu, 9 Jul 2026 18:14:58 +0000 Subject: [PATCH] fix: downgrade gateway not-routed log to debug, add Bedrock UI note, add sanitizer parity - Downgrade logger.warning to logger.debug in gateway_overrides for not-routed providers and missing API key (Bedrock is the default provider in this fork, so these are expected steady states) - Add Bedrock to the LLMGatewaySection route-toggle description so admins know it is not routed through the gateway - Add SanitizeOpenAIResponsesMiddleware to chat.py for parity with server.py and reviewer.py - Restore the Bedrock region comment in model.py that explains the AWS_REGION / AWS_DEFAULT_REGION precedence Refs #138 --- agent/chat.py | 2 ++ agent/utils/gateway.py | 4 ++-- agent/utils/model.py | 3 +++ ui/src/routes/admin.tsx | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/agent/chat.py b/agent/chat.py index dd4be7cc..132f83d8 100644 --- a/agent/chat.py +++ b/agent/chat.py @@ -33,6 +33,7 @@ from .dashboard.team_settings import get_effective_gateway_enabled, get_team_def from .middleware import ( ExcludeToolsMiddleware, SanitizeFireworksMessagesMiddleware, + SanitizeOpenAIResponsesMiddleware, SanitizeThinkingBlocksMiddleware, SanitizeToolInputsMiddleware, ToolErrorMiddleware, @@ -153,6 +154,7 @@ async def get_chat_agent(config: RunnableConfig) -> Pregel: ModelCallLimitMiddleware(run_limit=CHAT_MODEL_CALL_LIMIT, exit_behavior="end"), ToolErrorMiddleware(), ExcludeToolsMiddleware(excluded=_EXCLUDED_TOOLS), + SanitizeOpenAIResponsesMiddleware(), SanitizeFireworksMessagesMiddleware(), SanitizeThinkingBlocksMiddleware(), ], diff --git a/agent/utils/gateway.py b/agent/utils/gateway.py index d0a43070..065e6edb 100644 --- a/agent/utils/gateway.py +++ b/agent/utils/gateway.py @@ -102,14 +102,14 @@ def gateway_overrides(model_id: str) -> dict[str, object] | None: provider = _provider_of(model_id) path = _GATEWAY_PROVIDER_PATHS.get(provider) if path is None: - logger.warning( + logger.debug( "LangSmith gateway enabled but provider %r is not routed; calling it directly", provider, ) return None api_key = _langsmith_api_key() if not api_key: - logger.warning( + logger.debug( "LangSmith gateway enabled but no LANGSMITH_GATEWAY_API_KEY or " "LANGSMITH_API_KEY(_PROD) is set; " "calling the provider directly" diff --git a/agent/utils/model.py b/agent/utils/model.py index 825fa6a4..1313663c 100644 --- a/agent/utils/model.py +++ b/agent/utils/model.py @@ -94,6 +94,9 @@ def make_model(model_id: str, *, use_gateway: bool | None = None, **kwargs: Unpa model_kwargs["base_url"] = OPENAI_RESPONSES_WS_BASE_URL model_kwargs["use_responses_api"] = True elif model_id.startswith("bedrock_converse:"): + # Resolve region with the same precedence validate_local_dev_llm_config + # accepts (AWS_REGION or AWS_DEFAULT_REGION), so the validated value + # is the one actually used. model_kwargs.setdefault( "region_name", os.environ.get("AWS_REGION") or os.environ.get("AWS_DEFAULT_REGION") or "us-east-1", diff --git a/ui/src/routes/admin.tsx b/ui/src/routes/admin.tsx index 74d4a0a5..7ec9b2b4 100644 --- a/ui/src/routes/admin.tsx +++ b/ui/src/routes/admin.tsx @@ -595,7 +595,7 @@ function LLMGatewaySection() {