Skip to content

fix: github_copilot_sdk.py - prioritize BYOK_MODELS over API fetch when explicitly configured#71

Merged
Fu-Jie merged 1 commit into
Fu-Jie:mainfrom
silenceroom:specify-byok-models
May 10, 2026
Merged

fix: github_copilot_sdk.py - prioritize BYOK_MODELS over API fetch when explicitly configured#71
Fu-Jie merged 1 commit into
Fu-Jie:mainfrom
silenceroom:specify-byok-models

Conversation

@silenceroom
Copy link
Copy Markdown
Contributor

@silenceroom silenceroom commented May 10, 2026

Summary

  • Prioritize BYOK_MODELS over API fetch when explicitly configured — if a user sets BYOK_MODELS, the plugin now uses that list directly and skips the /models API call to BYOK_BASE_URL
  • Remove the now-redundant fallback block that parsed BYOK_MODELS only after API fetch failed

Behavior Change

Scenario Before After
Only BYOK_BASE_URL set API fetch API fetch
Both set API fetch first, fallback to BYOK_MODELS on failure BYOK_MODELS first, API fetch skipped
Neither set Empty list Empty list

Breaking change for users who have both BYOK_BASE_URL and BYOK_MODELS configured: the dynamic model list from API fetch will no longer be used. If you want the API-fetched list, clear BYOK_MODELS.

Test Plan

  • Configure only BYOK_BASE_URL — verify models are fetched via API as before
  • Configure both BYOK_MODELS and BYOK_BASE_URL — verify BYOK_MODELS takes precedence

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

此拉取请求修改了 _fetch_byok_models 函数,通过在尝试 API 获取之前优先检查并解析用户配置的 BYOK_MODELS,优化了模型加载逻辑。审查建议改进对 effective_models 的校验逻辑,因为仅使用 .strip() 可能无法处理仅包含分隔符的字符串,建议先解析列表并根据解析后的结果是否为空来决定是否跳过 API 获取。

Comment on lines +8137 to +8144
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:
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:

@Fu-Jie Fu-Jie merged commit 20df9d3 into Fu-Jie:main May 10, 2026
1 check failed
@silenceroom silenceroom deleted the specify-byok-models branch May 11, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants