Skip to content

Fix empty agent response in ADK agent when tools are used#62

Merged
richardkiene merged 2 commits into
mainfrom
fix/adk-empty-response
Jan 26, 2026
Merged

Fix empty agent response in ADK agent when tools are used#62
richardkiene merged 2 commits into
mainfrom
fix/adk-empty-response

Conversation

@richardkiene
Copy link
Copy Markdown
Contributor

@richardkiene richardkiene commented Jan 25, 2026

Summary

Two-part fix for empty agent responses:

  1. ADK Agent: Capture text from all events with text content, not just events marked as is_final_response(). When tools are used, the response text may come in earlier events.

  2. Synthetic User: When agent returns empty response, ask for clarification ("I didn't receive a response. Could you try again?") instead of passing empty content to the LLM - which would confuse it and trigger the fallback "Thanks" message that masks the bug.

Root Cause

Part 1: ADK Agent

The ADK agent's send_message method checked event.is_final_response() before extracting text. When an ADK agent calls tools, the actual response text may NOT be in the final event.

Part 2: Synthetic User

When the synthetic user LLM received an empty agent message, it got confused and returned an empty response. The code then defaulted to "Thanks, that answers my question." - masking the bug.

Test plan

  • Unit tests pass (260 tests)
  • Linting passes (ruff check)
  • Type checking passes (mypy)
  • Added tests for empty agent response handling
  • Manual testing: Re-run scenarios that had empty responses in reports

Capture text from all events with text content, not just events marked
as final response. When ADK agent uses tools, the response text may come
in events that are not marked as final, causing empty response strings.
When the agent returns an empty response, have the synthetic user ask
for clarification instead of passing empty content to the LLM which
would confuse it and cause it to return empty, triggering the fallback
"Thanks" message that masks the bug.
@richardkiene richardkiene merged commit 67e967c into main Jan 26, 2026
3 checks passed
@richardkiene richardkiene deleted the fix/adk-empty-response branch January 26, 2026 19:20
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.

1 participant