Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/google/adk/models/google_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,11 +614,23 @@ def _build_response_log(resp: types.GenerateContentResponse) -> str:
function_calls_text.append(
f'name: {func_call.name}, args: {func_call.args}'
)
# Avoid accessing resp.text directly: the genai SDK raises a UserWarning
# whenever .text is accessed on a response that contains non-text parts
# (e.g. function_call). This floods logs on every tool invocation.
# Instead, manually join only the text parts from candidates.
text_parts = []
if resp.candidates:
for candidate in resp.candidates:
if candidate.content and candidate.content.parts:
text_parts.extend(
p.text for p in candidate.content.parts if p.text is not None
)
text = ''.join(text_parts)
return f"""
LLM Response:
-----------------------------------------------------------
Text:
{resp.text}
{text}
-----------------------------------------------------------
Function calls:
{_NEW_LINE.join(function_calls_text)}
Expand Down Expand Up @@ -678,4 +690,4 @@ def _normalize_base_url_and_api_version(
normalized_base_url = urlunparse(
parsed_base_url._replace(path='/', params='', query='', fragment='')
)
return normalized_base_url, version_match.group(1)
return normalized_base_url, version_match.group(1)