From 47a102446a3a04dde484cad94ca7e5e1cc9ec1e5 Mon Sep 17 00:00:00 2001 From: Krishna Date: Thu, 29 Jan 2026 16:39:01 +0530 Subject: [PATCH 1/5] Update request handling text for clarity --- src/google/adk/models/lite_llm.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/google/adk/models/lite_llm.py b/src/google/adk/models/lite_llm.py index 79182d7b0a..a7b50130ef 100644 --- a/src/google/adk/models/lite_llm.py +++ b/src/google/adk/models/lite_llm.py @@ -490,7 +490,7 @@ def _append_fallback_user_content_if_missing( content.parts = [] content.parts.append( types.Part.from_text( - text="Handle the requests as specified in the System Instruction." + text="Handle the incoming request according to the provided requirements." ) ) return @@ -500,8 +500,7 @@ def _append_fallback_user_content_if_missing( parts=[ types.Part.from_text( text=( - "Handle the requests as specified in the System" - " Instruction." + "Handle the incoming request according to the provided requirements." ) ), ], From c1eea2d39baee301e6901c1ca05869756e50d3d3 Mon Sep 17 00:00:00 2001 From: Krishna Date: Thu, 29 Jan 2026 16:41:24 +0530 Subject: [PATCH 2/5] Update test assertion message content --- tests/unittests/models/test_litellm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unittests/models/test_litellm.py b/tests/unittests/models/test_litellm.py index 2ebbc5dfe8..598cb0356b 100644 --- a/tests/unittests/models/test_litellm.py +++ b/tests/unittests/models/test_litellm.py @@ -979,14 +979,14 @@ async def test_generate_content_async_adds_fallback_user_message( ] assert any( message.get("content") - == "Handle the requests as specified in the System Instruction." + == "Handle the incoming request according to the provided requirements." for message in user_messages ) assert ( sum(1 for content in llm_request.contents if content.role == "user") == 1 ) assert llm_request.contents[-1].parts[0].text == ( - "Handle the requests as specified in the System Instruction." + "Handle the incoming request according to the provided requirements." ) From ef7e376ca9f58e8d0482fe1aa1d51e86fb35f656 Mon Sep 17 00:00:00 2001 From: Krishna Date: Thu, 29 Jan 2026 16:54:19 +0530 Subject: [PATCH 3/5] Update comments for finish reason mapping --- src/google/adk/models/lite_llm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/google/adk/models/lite_llm.py b/src/google/adk/models/lite_llm.py index a7b50130ef..9d7ddc74b7 100644 --- a/src/google/adk/models/lite_llm.py +++ b/src/google/adk/models/lite_llm.py @@ -98,6 +98,9 @@ # 1. FinishReason.TOOL_CALL enum does not exist (as of google-genai 0.8.0) # 2. Tool calls represent normal completion (model stopped to invoke tools) # 3. Gemini native responses use STOP for tool calls (see lite_llm.py:910) +# 4. Mapping tool-related finish reasons to STOP preserves backward +# compatibility with existing ADK consumers that assume STOP +# indicates a successful, non-error completion. _FINISH_REASON_MAPPING = { "length": types.FinishReason.MAX_TOKENS, "stop": types.FinishReason.STOP, From 50e43883d5945815e15ce8143dd97ed5908249f7 Mon Sep 17 00:00:00 2001 From: Krishna Date: Thu, 29 Jan 2026 17:13:49 +0530 Subject: [PATCH 4/5] Replace hardcoded text with fallback variable --- src/google/adk/models/lite_llm.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/google/adk/models/lite_llm.py b/src/google/adk/models/lite_llm.py index 9d7ddc74b7..6801c7f04e 100644 --- a/src/google/adk/models/lite_llm.py +++ b/src/google/adk/models/lite_llm.py @@ -134,6 +134,10 @@ "before a response was recorded)." ) +_FALLBACK_USER_CONTENT_TEXT = ( + "Handle the incoming request according to the provided requirements." +) + _LITELLM_IMPORTED = False _LITELLM_GLOBAL_SYMBOLS = ( "ChatCompletionAssistantMessage", @@ -492,21 +496,13 @@ def _append_fallback_user_content_if_missing( if not parts: content.parts = [] content.parts.append( - types.Part.from_text( - text="Handle the incoming request according to the provided requirements." - ) + types.Part.from_text(text=_FALLBACK_USER_CONTENT_TEXT) ) return llm_request.contents.append( types.Content( role="user", - parts=[ - types.Part.from_text( - text=( - "Handle the incoming request according to the provided requirements." - ) - ), - ], + parts=[types.Part.from_text(text=_FALLBACK_USER_CONTENT_TEXT)], ) ) From 0a24a15659b07ee51441a05329f41dbc2bfe63a5 Mon Sep 17 00:00:00 2001 From: Krishna Date: Thu, 29 Jan 2026 17:14:12 +0530 Subject: [PATCH 5/5] Update test to use fallback user content text --- tests/unittests/models/test_litellm.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/unittests/models/test_litellm.py b/tests/unittests/models/test_litellm.py index 598cb0356b..add0db1f9b 100644 --- a/tests/unittests/models/test_litellm.py +++ b/tests/unittests/models/test_litellm.py @@ -25,6 +25,7 @@ import warnings from google.adk.models.lite_llm import _content_to_message_param +from google.adk.models.lite_llm import _FALLBACK_USER_CONTENT_TEXT from google.adk.models.lite_llm import _FILE_ID_REQUIRED_PROVIDERS from google.adk.models.lite_llm import _FINISH_REASON_MAPPING from google.adk.models.lite_llm import _function_declaration_to_tool_param @@ -978,16 +979,13 @@ async def test_generate_content_async_adds_fallback_user_message( message for message in kwargs["messages"] if message["role"] == "user" ] assert any( - message.get("content") - == "Handle the incoming request according to the provided requirements." + message.get("content") == _FALLBACK_USER_CONTENT_TEXT for message in user_messages ) assert ( sum(1 for content in llm_request.contents if content.role == "user") == 1 ) - assert llm_request.contents[-1].parts[0].text == ( - "Handle the incoming request according to the provided requirements." - ) + assert llm_request.contents[-1].parts[0].text == _FALLBACK_USER_CONTENT_TEXT litellm_append_user_content_test_cases = [