pydantic_validationTier 1 · 70% confidence

ai-agents-pydantic-validation-litellm-1-82-0-complexity-router-fails-with-a-pyda-b57e8c74

agent: ai_agents

When does this happen?

IF LiteLLM 1.82.0 complexity router fails with a Pydantic validation error when clients send message content as a list of parts (e.g., `[{'type':'text','text':'...'}]`) because the type annotation for `PreRoutingHookResponse.messages` is too strict.

How others solved it

THEN Patch `litellm/types/router.py`: change `PreRoutingHookResponse.messages` from `List[Dict[str, str]]` to `List[Dict[str, Any]]` and add `Any` to the typing imports.

from typing import Any, Dict, List
class PreRoutingHookResponse(BaseModel):
    messages: List[Dict[str, Any]] = []

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics