litellm/tests/test_litellm/llms
Jared Everett 3cbb36aa13
fix(ollama): propagate done_reason='length' as finish_reason for max_tokens truncation (#25824)
* fix(ollama): propagate done_reason='length' as finish_reason for max_tokens truncation

Ollama returns done_reason='length' when a response is cut off by num_predict
(the max_tokens limit). Previously, non-streaming responses hardcoded
finish_reason='stop', and streaming used chunk.get('done_reason', 'stop')
which also defaulted to 'stop' when done_reason was absent.

This meant callers (e.g. the Anthropic pass-through adapter, which maps
OpenAI 'length' -> Anthropic 'max_tokens') could never detect truncation,
making stop_reason always appear as 'end_turn' even for cut-off responses.

Fix: read done_reason from the response JSON in the non-streaming path and
use `chunk.get('done_reason') or 'stop'` in the streaming path, so Ollama's
actual done_reason passes through to the caller unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Update test_ollama_chat_transformation.py

* Update litellm/llms/ollama/chat/transformation.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-04-16 19:03:41 +05:30
..
amazon_nova/chat
anthropic Merge remote-tracking branch 'origin/main' into worktree-foamy-jumping-coral 2026-04-15 18:29:55 -07:00
azure fix(azure/passthrough): populate standard_logging_object via logging hook 2026-04-14 08:10:39 +02:00
azure_ai Litellm ishaan april15 2 (#25828) 2026-04-15 18:42:23 -07:00
base_llm [Fix] BaseModelResponseIterator crashes on non-string stream chunks 2026-03-12 16:16:32 -07:00
baseten/chat
bedrock Merge pull request #25396 from BerriAI/litellm_bedrock-normalize-custom-tool-schema 2026-04-14 10:21:15 -07:00
bedrock_mantle
black_forest_labs fix(tests): update BFL image generation tests for new signature 2026-03-13 00:20:52 +00:00
bytez/chat
chat Litellm fix update bedrock models (#24947) 2026-04-01 19:22:54 -07:00
chatgpt
cohere
cometapi/chat
compactifai
custom_httpx Litellm ishaan april15 2 (#25828) 2026-04-15 18:42:23 -07:00
dashscope feat(dashscope): preserve cache_control for explicit prompt caching (#25331) 2026-04-08 21:32:04 -07:00
databricks
datarobot
deepgram
deepinfra
docker_model_runner
featherless_ai/chat
fireworks_ai Fix cicd fialing tests 2026-03-19 16:32:35 +05:30
gemini feat(gemini): Veo Lite pricing, size→resolution, usage video_resolution for cost tiers 2026-04-08 19:50:50 +05:30
github_copilot
heroku
hosted_vllm
huggingface
jina_ai/embedding
lemonade
litellm_proxy build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00
llamafile/chat
lm_studio
manus
meta_llama
minimax
mistral Merge pull request #23818 from BerriAI/litellm_oss_staging_03_17_2026 2026-03-21 14:54:39 -07:00
moonshot fix(moonshot): preserve reasoning_content on Pydantic Message objects in multi-turn tool calls (#23828) 2026-03-21 00:09:17 +05:30
nebius
novita/chat
nscale/chat
oci Litellm ishaan march30 (#24887) (#25151) 2026-04-04 14:44:07 -07:00
ocr
ollama fix(ollama): propagate done_reason='length' as finish_reason for max_tokens truncation (#25824) 2026-04-16 19:03:41 +05:30
openai Merge pull request #25463 from BerriAI/litellm_oss_staging_04_09_2026 2026-04-13 17:25:53 -07:00
openai_like merge: resolve conflicts between main and litellm_oss_staging_03_11_2026 2026-03-12 09:38:31 -03:00
openrouter fix(openrouter): strip LiteLLM prefix when proxy sets custom_llm_provider 2026-03-27 20:35:17 +05:30
ovhcloud
perplexity merge: resolve conflicts between main and litellm_oss_staging_03_11_2026 2026-03-12 09:38:31 -03:00
pg_vector/vector_stores
publicai
ragflow/chat
recraft
runwayml
s3_vectors
sagemaker feat: add sagemaker_nova provider for Amazon Nova models on SageMaker (#21542) 2026-03-14 15:10:01 -07:00
sambanova
sap Litellm oss staging 04 02 2026 p1 (#25055) 2026-04-08 21:37:10 -07:00
snowflake Merge main and resolve Snowflake test conflict 2026-03-30 18:06:37 -07:00
stability
vercel_ai_gateway
vertex_ai fix(vertex): strip version suffix from model name in count_tokens requests (#25800) 2026-04-16 19:03:40 +05:30
volcengine
voyage/rerank
wandb
watsonx
xai [Staging] - Ishaan March 17th (#23903) 2026-03-18 15:09:01 -07:00
zai
test_cache_control_and_reasoning.py
test_file_search_responses.py fix double-billing issue 2026-03-18 12:47:42 +05:30
test_lifecycle_fix.py
test_oom_fixes.py