diff --git a/src/google/adk/models/lite_llm.py b/src/google/adk/models/lite_llm.py index 79182d7b0a..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, @@ -490,7 +493,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 +503,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." ) ), ], 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." )