fix(cli): honor target_model when resolving custom providers

resolve_runtime_provider() documents target_model as the explicit model
override for mid-session switches and auxiliary slots, but the custom
provider path (_resolve_named_custom_runtime) never received it and
silently substituted the provider's configured default_model instead.

This made auxiliary slots such as auxiliary.background_review silently
run the provider's default model rather than the configured one — e.g. an
ocx-proxy slot configured for gemini-flash actually executed
cursor/claude-sonnet-5, hitting upstream rate limits.

Pass target_model through to the custom runtime resolver and prefer it
over the provider's default model in both the pooled and non-pooled
credential paths.
This commit is contained in:
王雪帆
2026-08-04 23:20:35 +08:00
committed by Teknium
parent 6d48fbed1b
commit c4871226f1
2 changed files with 79 additions and 2 deletions
+9 -2
View File
@@ -1167,7 +1167,8 @@ def _resolve_named_custom_runtime(
if pool_result:
# Propagate the model name even when using pooled credentials —
# the pool doesn't know about the custom_providers model field.
model_name = custom_provider.get("model")
# An explicit ``target_model`` wins (same rule as the non-pool path).
model_name = target_model or custom_provider.get("model")
if model_name:
pool_result["model"] = model_name
if isinstance(custom_provider.get("max_output_tokens"), int):
@@ -1228,7 +1229,13 @@ def _resolve_named_custom_runtime(
}
# Propagate the model name so callers can override self.model when the
# provider name differs from the actual model string the API expects.
if custom_provider.get("model"):
# An explicit ``target_model`` wins over the provider's configured
# default (regression: auxiliary slots / background-review resolve a
# concrete model for a custom provider and must not silently fall back
# to ``default_model``).
if target_model:
result["model"] = target_model
elif custom_provider.get("model"):
result["model"] = custom_provider["model"]
if isinstance(custom_provider.get("max_output_tokens"), int):
result["max_output_tokens"] = custom_provider["max_output_tokens"]