Skip to content

fix(models): avoid spurious UserWarning on tool-call responses in _build_response_log#6073

Open
syedjafri06193 wants to merge 1 commit into
google:mainfrom
syedjafri06193:fix/safe-response-text-4685
Open

fix(models): avoid spurious UserWarning on tool-call responses in _build_response_log#6073
syedjafri06193 wants to merge 1 commit into
google:mainfrom
syedjafri06193:fix/safe-response-text-4685

Conversation

@syedjafri06193

Copy link
Copy Markdown

Summary

Fixes #4685.

When the model returns a tool-call (function-call) response, resp.text internally iterates all Part objects and emits a UserWarning for every part that contains a FunctionCall instead of plain text. This warning is unhelpful noise when the caller is just building a debug log string.

  • Adds _safe_response_text(resp) before _build_response_log() that extracts text by directly iterating candidates[0].content.parts and joining only part.text values that are not None, bypassing the warning-emitting property entirely.
  • Replaces {resp.text} in _build_response_log()'s f-string with {_safe_response_text(resp)}.

Test plan

  • Invoke an agent that issues a tool call and confirm no UserWarning: there is no text part appears in logs.
  • Confirm text-only responses still produce the correct text in the debug log.
  • pytest tests/unittests/models/ passes without new failures.

🤖 Generated with Claude Code

…ild_response_log

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

google-cla Bot commented Jun 10, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot

adk-bot commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Response from ADK Triaging Agent

Hello @syedjafri06193, thank you for creating this PR!

To help us review your contribution more efficiently, please address the following items from our contribution guidelines:

  1. Contributor License Agreement (CLA): The CLA check currently shows a failure. Please visit Google's Contributor License Agreement page to sign or verify your agreement.
  2. Test Execution & Verification Evidence:
    • In your PR description, the items under the Test plan section are currently unchecked. Please run the tests, verify the fix, and update these checkboxes.
    • For bug fixes, please provide logs or a screenshot demonstrating the behavior before/after the fix is applied.
    • Please include a summary of the passed pytest results (e.g., for tests/unittests/models/) to confirm everything works as expected.

These details will save review time and help us merge your changes sooner. Thank you!

@syedjafri06193

Copy link
Copy Markdown
Author

CLA is signed (Google Individual CLA, Jun 08 2026). Requesting CLA check re-run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adk Function Call Warning

2 participants