Skip to content

Commit b2e2d7b

Browse files
committed
docs: address Gemini Code Assist bot review feedback
- Update llm_response.py docstring to use 'underlying model providers' instead of specifically 'LiteLLM' for better generalization - Add explanatory comment for tool_calls->STOP mapping: - FinishReason.TOOL_CALL enum does not exist in google-genai - Tool calls are normal completion (STOP is semantically correct) - Consistent with Gemini native behavior (lite_llm.py:910) Addresses bot feedback: - Make docstring more general about finish_reason sources - Clarify why tool_calls maps to STOP (not a different enum)
1 parent 83272ed commit b2e2d7b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/google/adk/models/lite_llm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,15 @@
6565
_EXCLUDED_PART_FIELD = {"inline_data": {"data"}}
6666

6767
# Mapping of LiteLLM finish_reason strings to FinishReason enum values
68+
# Note: tool_calls/function_call map to STOP because:
69+
# 1. FinishReason.TOOL_CALL enum does not exist (as of google-genai 0.8.0)
70+
# 2. Tool calls represent normal completion (model stopped to invoke tools)
71+
# 3. Gemini native responses use STOP for tool calls (see lite_llm.py:910)
6872
_FINISH_REASON_MAPPING = {
6973
"length": types.FinishReason.MAX_TOKENS,
7074
"stop": types.FinishReason.STOP,
71-
"tool_calls": types.FinishReason.STOP,
72-
"function_call": types.FinishReason.STOP,
75+
"tool_calls": types.FinishReason.STOP, # Normal completion with tool invocation
76+
"function_call": types.FinishReason.STOP, # Legacy function call variant
7377
"content_filter": types.FinishReason.SAFETY,
7478
}
7579

src/google/adk/models/llm_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class LlmResponse(BaseModel):
8181
finish_reason: Optional[types.FinishReason] = None
8282
"""The finish reason of the response.
8383
84-
Always a types.FinishReason enum. LiteLLM string values are mapped to
85-
corresponding enum values (with fallback to OTHER for unknown values).
84+
Always a types.FinishReason enum. String values from underlying model providers
85+
are mapped to corresponding enum values (with fallback to OTHER for unknown values).
8686
"""
8787

8888
error_code: Optional[str] = None

0 commit comments

Comments
 (0)