mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
fix(agentic): preserve cross-provider follow-up overrides
This commit is contained in:
parent
a1ea01c6f1
commit
3011431d41
3 changed files with 16 additions and 5 deletions
|
|
@ -171,7 +171,12 @@ async def _execute_chat_completion_agentic_plan(
|
|||
raise ValueError("Agentic loop plan missing patched messages")
|
||||
|
||||
full_model_name = patch.model or model
|
||||
if custom_llm_provider and not full_model_name.startswith(f"{custom_llm_provider}/"):
|
||||
known_providers: Final = getattr(litellm, "provider_list", [])
|
||||
has_provider_prefix: Final = (
|
||||
full_model_name.startswith(f"{custom_llm_provider}/")
|
||||
or ("/" in full_model_name and full_model_name.split("/", 1)[0] in known_providers)
|
||||
)
|
||||
if custom_llm_provider and not has_provider_prefix:
|
||||
full_model_name = f"{custom_llm_provider}/{full_model_name}"
|
||||
|
||||
optional_params_for_followup: Final = {**optional_params, **patch.optional_params}
|
||||
|
|
|
|||
|
|
@ -5494,7 +5494,12 @@ class BaseLLMHTTPHandler:
|
|||
raise ValueError("Agentic loop plan missing patched messages")
|
||||
|
||||
full_model_name = patch.model or model
|
||||
if custom_llm_provider and not full_model_name.startswith(f"{custom_llm_provider}/"):
|
||||
known_providers: Final = getattr(litellm, "provider_list", [])
|
||||
has_provider_prefix: Final = (
|
||||
full_model_name.startswith(f"{custom_llm_provider}/")
|
||||
or ("/" in full_model_name and full_model_name.split("/", 1)[0] in known_providers)
|
||||
)
|
||||
if custom_llm_provider and not has_provider_prefix:
|
||||
full_model_name = f"{custom_llm_provider}/{full_model_name}"
|
||||
|
||||
optional_params_for_followup: Final = dict(optional_params)
|
||||
|
|
|
|||
|
|
@ -25,8 +25,9 @@ from litellm.types.utils import ModelResponse
|
|||
("zai-org/GLM-5.3-Flash", "hosted_vllm", "hosted_vllm/zai-org/GLM-5.3-Flash"),
|
||||
("hosted_vllm/zai-org/GLM-5.3-Flash", "hosted_vllm", "hosted_vllm/zai-org/GLM-5.3-Flash"),
|
||||
("hosted_vllm/zai-org/GLM-5.3-Flash", "", "hosted_vllm/zai-org/GLM-5.3-Flash"),
|
||||
("openai/gpt-4o", "hosted_vllm", "openai/gpt-4o"),
|
||||
),
|
||||
ids=("organization-model", "already-prefixed", "no-provider"),
|
||||
ids=("organization-model", "already-prefixed", "no-provider", "cross-provider"),
|
||||
)
|
||||
async def test_agentic_followup_preserves_provider_prefix(
|
||||
execution_path: Literal["http", "sdk"],
|
||||
|
|
@ -75,8 +76,8 @@ async def test_agentic_followup_preserves_provider_prefix(
|
|||
)
|
||||
)
|
||||
|
||||
assert isinstance(response, ModelResponse)
|
||||
assert response.model == expected_model.removeprefix("hosted_vllm/")
|
||||
followup.assert_awaited_once()
|
||||
assert followup.await_args is not None
|
||||
assert followup.await_args.kwargs["model"] == expected_model
|
||||
assert isinstance(response, ModelResponse)
|
||||
assert response.model == expected_model.split("/", 1)[1]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue