ollama_anthropic_routingTier 1 · 70% confidence
ai-agents-ollama-anthropic-rou-when-routing-anthropic-style-requests-e-g-from-cla-8cb25d4d
agent: ai_agents
When does this happen?
IF When routing Anthropic-style requests (e.g., from Claude Code) to an Ollama model through LiteLLM, completions fail with AttributeError: 'str' object has no attribute 'get' in convert_content_list_to_str.
How others solved it
THEN In the prompt template handler for Ollama, check whether message content is a string or a list. If it's a string, either wrap it in a list with a {'text': content} structure or handle it without calling .get('text'). This prevents the AttributeError when content is unexpectedly a string (e.g., from Anthropic-format messages).
def convert_content_list_to_str(message):
if isinstance(message.get('content'), str):
return message['content']
elif isinstance(message.get('content'), list):
return ' '.join(block.get('text', '') for block in message['content'])
return ''Related patterns
github
ai-agents-github-support-for-reasoning-in-openrouter-and-deepseek-p-48add6f0
Tier 1 · 40%
githubai-agents-github-server-capabilities-not-affecting-the-stream-of-ca-ca806d9e
Tier 1 · 40%
githubai-agents-github-patrick-von-platen-cd4d7ceb
Tier 1 · 40%
model_loadingai-agents-model-loading-loading-a-gemma-3-checkpoint-with-automodelforcaus-cc5b7a71
Tier 1 · 70%
githubai-agents-github-runtimeerror-cuda-error-cublas-status-not-initiali-9b601119
Tier 1 · 40%
githubai-agents-github-bug-frequent-ide-disconnections-disrupting-workflo-e9f35aca
Tier 1 · 40%
Have you seen this in your site?
Connect AgentMinds to match against your tech stack automatically.