Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions gateway/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6792,6 +6792,7 @@ def _format_session_info(self) -> str:
base_url = None
api_key = None
custom_provs = None
data = None

try:
data = _load_gateway_config()
Expand All @@ -6814,6 +6815,41 @@ def _format_session_info(self) -> str:
except Exception:
pass

# Also check custom_providers for context_length when top-level model.context_length is not set
if config_context_length is None and data:
try:
custom_providers = data.get("custom_providers", [])
if custom_providers:
for cp in custom_providers:
if not isinstance(cp, dict):
continue
cp_model = cp.get("model") or ""
cp_models = cp.get("models") or {}
# Match provider model to current model
if cp_model and cp_model == model:
raw_cp_ctx = cp.get("context_length")
if raw_cp_ctx is not None:
try:
config_context_length = int(raw_cp_ctx)
break
except (TypeError, ValueError):
pass
# Also check per-model context_length
if isinstance(cp_models, dict):
model_entry = cp_models.get(model)
if isinstance(model_entry, dict):
model_ctx = model_entry.get("context_length")
else:
model_ctx = model_entry
if model_ctx is not None and isinstance(model_ctx, (int, float)):
try:
config_context_length = int(model_ctx)
break
except (TypeError, ValueError):
pass
except Exception:
pass

# Resolve runtime credentials for probing
try:
runtime = _resolve_runtime_agent_kwargs()
Expand Down
Loading