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
This commit is contained in:
amoussa1229 2026-07-09 18:14:58 +00:00
parent 2a35f89aad
commit b0276a732a
4 changed files with 8 additions and 3 deletions

View file

@ -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(),
],

View file

@ -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"

View file

@ -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",

View file

@ -595,7 +595,7 @@ function LLMGatewaySection() {
<div className="divide-y divide-border">
<SettingsRow
label="Route through the gateway"
description="Inherit uses the LANGSMITH_GATEWAY_ENABLED deployment default. OpenAI, Anthropic, Fireworks, and Google Gemini are routed; other providers call the provider directly."
description="Inherit uses the LANGSMITH_GATEWAY_ENABLED deployment default. OpenAI, Anthropic, Fireworks, and Google Gemini are routed through the gateway. Bedrock (AWS) calls the provider directly and is not routed; other providers not listed also call the provider directly."
control={
<Select
value={mode}