fix: avoid litellm provider-name collision for custom OpenAI-compatib…#223
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Agents configured with a freeform/self-hosted LLM provider name crashed on every real invocation with:
Reported in #221, but the upstream-litellm
default_pt()theory in that issue doesn't hold up — I reproduced the call path locally and theopenai/<model>passthrough handles multi-block message content fine.Root cause
build_llm()decided whether to route a provider through the OpenAI-compatible passthrough by checkingprovider not in litellm.provider_list. That list is litellm's internal provider registry, which reserves generic-sounding names —custom,vllm,huggingface,petals, etc. — for its own non-chat, non-OpenAI-compatible handlers.A user setting up a self-hosted endpoint naturally types
"custom"into Paca's freeform "Custom…" provider field. Since"custom"is already a registered litellm provider,build_llm()skipped the OpenAI passthrough and builtmodel_str = "custom/<model>". litellm's nativecustomhandler then does:which throws exactly the reported
TypeErroronce any message has multi-blockcontent(the normal shape once there's a system prompt + skills).Fix
Route based on Paca's own provider catalog (
data/llm_models.json, the same list backing the frontend provider dropdown) instead of litellm's internalprovider_list. Any provider name outside that catalog — regardless of whether it happens to collide with a litellm-reserved name — now always gets the OpenAI-compatible passthrough.src/llm_catalog.py, shared byroutes/llm.pyandagent/builder.pyso both agree on what counts as "known."build_llm()(previously untested), including the exact"custom"collision from Custom-provider agent LLM calls fail in build_llm() — litellm default_pt() crash on multi-block content (related to #214) #221.Fixes #221
Test plan
pytest— 85 passed, 3 skipped (unrelated e2e)ruff checkcleanlitellm.completion(model="custom/...", ...)and confirmed the fix routes it throughopenai/...instead