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
20 changes: 9 additions & 11 deletions plugins/pipes/github-copilot-sdk/github_copilot_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -8133,7 +8133,15 @@ async def _fetch_byok_models(
) or self.valves.BYOK_BEARER_TOKEN
effective_models = (uv.BYOK_MODELS if uv else "") or self.valves.BYOK_MODELS

if effective_base_url:
# If user explicitly configured BYOK_MODELS, use them directly (skip API fetch)
if effective_models.strip():
model_list = [
m.strip() for m in effective_models.split(",") if m.strip()
]
await self._emit_debug_log(
f"BYOK: Using user-configured BYOK_MODELS ({len(model_list)} models)."
)
elif effective_base_url:
Comment on lines +8137 to +8144
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current logic checks effective_models.strip() to decide whether to skip the API fetch. However, if effective_models contains only delimiters (e.g., ", ,"), model_list will be empty, yet the API fetch will still be skipped because the condition is truthy. It is more robust to parse the models first and only skip the API fetch if the resulting list is non-empty.

        model_list = [m.strip() for m in effective_models.split(",") if m.strip()]
        if model_list:
            await self._emit_debug_log(
                f"BYOK: Using user-configured BYOK_MODELS ({len(model_list)} models)."
            )
        elif effective_base_url:

try:
base_url = effective_base_url.rstrip("/")
url = f"{base_url}/models"
Expand Down Expand Up @@ -8188,16 +8196,6 @@ async def _fetch_byok_models(
except Exception as e:
await self._emit_debug_log(f"BYOK: Setup error: {e}")

# Fallback to configured list or defaults
if not model_list:
if effective_models.strip():
model_list = [
m.strip() for m in effective_models.split(",") if m.strip()
]
await self._emit_debug_log(
f"BYOK: Using user-configured BYOK_MODELS ({len(model_list)} models)."
)

# Infer per-model provider from ID string (BYOK endpoints can return multi-provider lists)
byok_models = [
{
Expand Down
Loading