Skip to content

fix: avoid litellm provider-name collision for custom OpenAI-compatib…#223

Merged
pikann merged 1 commit into
masterfrom
fix/avoid-litellm-provider-name-collision
Jun 25, 2026
Merged

fix: avoid litellm provider-name collision for custom OpenAI-compatib…#223
pikann merged 1 commit into
masterfrom
fix/avoid-litellm-provider-name-collision

Conversation

@pikann

@pikann pikann commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Agents configured with a freeform/self-hosted LLM provider name crashed on every real invocation with:

litellm.APIConnectionError: sequence item 0: expected str instance, list found

Reported in #221, but the upstream-litellm default_pt() theory in that issue doesn't hold up — I reproduced the call path locally and the openai/<model> passthrough handles multi-block message content fine.

Root cause

build_llm() decided whether to route a provider through the OpenAI-compatible passthrough by checking provider 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 built model_str = "custom/<model>". litellm's native custom handler then does:

prompt = " ".join([message["content"] for message in messages])

which throws exactly the reported TypeError once any message has multi-block content (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 internal provider_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.

Fixes #221

Test plan

  • pytest — 85 passed, 3 skipped (unrelated e2e)
  • ruff check clean
  • Reproduced the original crash locally with litellm.completion(model="custom/...", ...) and confirmed the fix routes it through openai/... instead

@pikann pikann merged commit a46150a into master Jun 25, 2026
7 checks passed
@pikann pikann deleted the fix/avoid-litellm-provider-name-collision branch June 25, 2026 17:11
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.

Custom-provider agent LLM calls fail in build_llm() — litellm default_pt() crash on multi-block content (related to #214)

1 participant