refactor(websearch): trim the comments on the provider-qualify helper

This commit is contained in:
Priyansh Nandwana 2026-09-05 13:00:50 +05:30
parent c45c594a1b
commit f287132412
2 changed files with 3 additions and 9 deletions

View file

@ -30,13 +30,10 @@ def is_codex_user_agent(user_agent: str) -> bool:
def qualify_provider_stripped_model(model: str, custom_llm_provider: str) -> str:
"""
Put the provider prefix back on a model an agentic follow-up re-dispatches with.
"""Put the provider prefix back on a provider-stripped model.
Handlers are handed the provider-stripped model, and for providers that route through
a sub-path (``bedrock/mantle/...``, ``openrouter/openai/...``) that remainder still
holds a slash. Treating any slash as "already qualified" drops the prefix and leaves a
string no provider can be resolved from.
A sub-path provider (``bedrock/mantle/...``) leaves a slash in the remainder, so
treating any slash as "already qualified" would drop the prefix.
"""
if not custom_llm_provider or model.startswith(f"{custom_llm_provider}/"):
return model

View file

@ -418,12 +418,9 @@ class TestQualifyProviderStrippedModel:
@pytest.mark.parametrize(
"model,provider,expected",
[
# the reported case: bedrock's OpenAI-compatible sub-path
("mantle/anthropic.claude-sonnet-5", "bedrock", "bedrock/mantle/anthropic.claude-sonnet-5"),
("invoke/anthropic.claude-v2", "bedrock", "bedrock/invoke/anthropic.claude-v2"),
# another provider whose stripped model keeps a slash
("openai/gpt-4o", "openrouter", "openrouter/openai/gpt-4o"),
# the ordinary case still works
("gpt-4o", "openai", "openai/gpt-4o"),
("claude-sonnet-4-5", "anthropic", "anthropic/claude-sonnet-4-5"),
],