Empty response from root_agent after AgentTool response
Hi everyone, could you please help me? I’m having an issue with my orchestrator agent using Google ADK.
I have a multi-agent system, where several subagents are being used as agent-as-tool. For a specific query, I need a sequence of tools to be executed by different agents, one after another.
However, in several cases, after a subagent (used as tool) responds successfully, the root_agent receives the function response but then returns an empty text output and stops the reasoning process.
Here’s an example:
Response from agent-as-tool:
{ "parts": [ { "function_response": { "id": "8324785784357", "name": "genericagent", "response": { "blabla": [ { "ihih": "eieie", "test": "hellouu" } ] } } } ], "role": "user" }
Root agent output:
{ "parts": [ { "text": "" } ], "role": "model" }
After this, the execution stops completely — as if the root agent lost its reasoning chain. Has anyone faced something similar? How can I ensure the orchestrator continues reasoning after each tool response?
I also noticed that the function responses are returned with the role "user". Could this be interfering with the orchestrator’s reasoning process? Wouldn’t it make more sense to distinguish tool responses from user turns — or does this not affect the flow at all?
Thanks in advance!
google-adk==1.16.0
Hello @marttinslucas,
Could you please share a minimum reproducible code example so that we can try to reproduce your issue and analyze it in detail?
i got the same issue, and this cause the error when integration with ag_ui_adk. Here the flow happend:
Master agent -> call sub agent via AgentAsTool after sub agent completed
the error happend.
Error translating ADK event: 1 validation error for TextMessageContentEvent
delta
String should have at least 1 character [type=string_too_short, input_value='', input_type=str]
For further information visit https://errors.pydantic.dev/2.12/v/string_too_short
Traceback (most recent call last):
File "D:\Work\Tasks\maestro-recruiter-agent\backend\.venv\Lib\site-packages\ag_ui_adk\event_translator.py", line 187, in translate
async for event in self._translate_text_content(
File "D:\Work\Tasks\maestro-recruiter-agent\backend\.venv\Lib\site-packages\ag_ui_adk\event_translator.py", line 352, in _translate_text_content
TextMessageContentEvent(
File "D:\Work\Tasks\maestro-recruiter-agent\backend\.venv\Lib\site-packages\pydantic\main.py", line 250, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for TextMessageContentEvent
delta
String should have at least 1 character [type=string_too_short, input_value='', input_type=str]
For further information visit https://errors.pydantic.dev/2.12/v/string_too_short
class TextMessageContentEvent(BaseEvent):
"""
Event containing a piece of text message content.
"""
type: Literal[EventType.TEXT_MESSAGE_CONTENT] = EventType.TEXT_MESSAGE_CONTENT # pyright: ignore[reportIncompatibleVariableOverride]
message_id: str
delta: str = Field(min_length=1)
Api:
"""FastAPI app exposing Google ADK agent via AG-UI protocol."""
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse
from google.adk.sessions import DatabaseSessionService
from ag_ui_adk import ADKAgent, add_adk_fastapi_endpoint
from ag_ui.core import RunAgentInput
import uvicorn
from loguru import logger
from src.logging_config import setup_logging
from pathlib import Path
from src.agents.coordinator_agent.agent import root_agent
from src.agents.coordinator_agent.config import CoordinatorAgentConfig
setup_logging()
# Configure logging to verify AG-UI state reception
logger.add("logs/adk_api.log", rotation="500 MB", retention="7 days", level="DEBUG")
cordinator_agent_config = CoordinatorAgentConfig()
app = FastAPI(title="Maestro ADK API")
# CORS for frontend
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Middleware to log incoming requests for AG-UI state verification
@app.middleware("http")
async def log_requests(request, call_next):
"""Log all incoming requests to verify AG-UI state reception."""
logger.debug(f"Incoming request: {request.method} {request.url.path}")
logger.debug(f"Headers: {dict(request.headers)}")
# Try to read and log body for POST requests
if request.method == "POST":
try:
body = await request.body()
if body:
logger.debug(f"Request body (first 500 chars): {body[:500]}")
except Exception as e:
logger.warning(f"Could not read request body: {e}")
response = await call_next(request)
logger.debug(f"Response status: {response.status_code}")
return response
# User id extractor
def user_id_extractor(input: RunAgentInput) -> str:
logger.debug(input.model_dump_json())
return input.forwarded_props.get("user_id")
# Session service
session_service = DatabaseSessionService(db_url=cordinator_agent_config.database_url)
# Wrap Google ADK agent with AG-UI adapter
adk_agent = ADKAgent(
adk_agent=root_agent,
app_name=cordinator_agent_config.app_name,
session_timeout_seconds=3600,
session_service=session_service,
user_id_extractor=user_id_extractor,
use_in_memory_services=False,
)
# Add AG-UI endpoint
add_adk_fastapi_endpoint(app, adk_agent, path="/")
@app.get("/health")
def health():
"""Health check endpoint."""
logger.info("Health check called")
return {"status": "healthy", "message": "ADK API is running"}
@app.post("/info")
@app.get("/info")
def info():
"""Info endpoint for ag-ui protocol."""
logger.info("Info endpoint called")
return {
"name": "Maestro Recruiter Agent",
"version": "1.0.0",
"description": "AI-powered recruiter agent using Google ADK",
"status": "running",
}
@app.get("/favicon.ico")
def favicon():
"""Serve favicon for ag-ui protocol."""
logger.debug("Favicon endpoint called")
favicon_path = Path(__file__).parent.parent.parent / "asset" / "favicon.ico"
if not favicon_path.exists():
logger.warning(f"Favicon not found at {favicon_path}")
return {"error": "Favicon not found"}, 404
logger.debug(f"Serving favicon from {favicon_path}")
return FileResponse(favicon_path, media_type="image/x-icon")
@app.get("/debug/state")
def debug_state():
"""Debug endpoint to verify state reception (for testing only)."""
logger.info("Debug state endpoint called")
return {
"message": "State reception debug endpoint",
"note": "Check logs/adk_api.log to verify AG-UI state reception",
"expected_state_keys": ["user:tenant_id", "user:user_id", "user:access_token"],
}
if __name__ == "__main__":
uvicorn.run("src.api.app:app", host="0.0.0.0", port=8000, reload=False)
"""Shared utilities for agent creation and configuration.
Provides common patterns and reusable components for all agent implementations.
This module centralizes configuration to ensure consistency across the agent layer.
"""
from google.adk.tools import agent_tool
# Import all specialized agents
from src.agents.job_search_agent.agent import root_agent as job_search_agent
....
def get_specialized_data_agents() -> list:
"""Get all specialized data-gathering agents as AgentTool wrappers.
Returns a standardized list of all data-gathering sub-agents wrapped
as AgentTools with skip_summarization=True. This ensures consistency
across parent agents that need access to these specialized agents.
The agents are wrapped with skip_summarization=True to avoid redundant
token consumption from result summarization, since parent agents will
aggregate and process the results themselves.
"""
return [
agent_tool.AgentTool(agent="...", skip_summarization=True),
agent_tool.AgentTool(agent="..", skip_summarization=True),
...
]
Nevermind, this happend because of GPT-5 series model. I do not know why they return empty message.
Similar issue: https://github.com/ag-ui-protocol/ag-ui/issues/337
Hello @marttinslucas,
Could you please share a minimum reproducible code example so that we can try to reproduce your issue and analyze it in detail?
I also hit this, I think it is due to the agent streaming the responses. It happens when the root agent calls an agent as a tool and it return several chunks, but only the last one is processed.
I fixed it by overwriting the AgentTool run_async:
class StreamingAgentTool(AgentTool):
async def run_async(self, *, args: dict[str, Any], tool_context: ToolContext) -> Any:
content = types.Content(
role='user',
parts=[types.Part.from_text(text=args['request'])]
)
runner = Runner(
app_name=self.agent.name,
agent=self.agent,
artifact_service=ForwardingArtifactService(tool_context),
session_service=InMemorySessionService(),
memory_service=InMemoryMemoryService(),
credential_service=tool_context._invocation_context.credential_service,
plugins=list(tool_context._invocation_context.plugin_manager.plugins),
)
state_dict = {
k: v
for k, v in tool_context.state.to_dict().items()
if not k.startswith('_adk') # Filter out adk internal states
}
session = await runner.session_service.create_session(
app_name=self.agent.name,
user_id=tool_context._invocation_context.user_id,
state=state_dict,
)
# Not only taking the last content but all the chunks of the response
chunks: list[str] = []
def iter_text_parts(parts: Iterable[Any]) -> Iterable[str]:
for p in parts or []:
# Keep empty strings "" but skip None
if hasattr(p, "text") and p.text is not None:
yield p.text
async with Aclosing(
runner.run_async(
user_id=session.user_id, session_id=session.id, new_message=content
)
) as agen:
async for event in agen:
# Forward state delta to parent session.
if event.actions.state_delta:
tool_context.state.update(event.actions.state_delta)
if event.content:
chunks.extend(iter_text_parts(event.content.parts))
merged_text = "".join(chunks)
return merged_text
Instead of the default one which is only using the text from the parts on the last event:
last_content = None
async with Aclosing(
runner.run_async(
user_id=session.user_id, session_id=session.id, new_message=content
)
) as agen:
async for event in agen:
# Forward state delta to parent session.
if event.actions.state_delta:
tool_context.state.update(event.actions.state_delta)
if event.content:
last_content = event.content
if not last_content:
return ''
merged_text = '\n'.join(p.text for p in last_content.parts if p.text)
Confirm: after test on claude model, the issue still happend, not just open ai models
Hello @marttinslucas, Could you please share a minimum reproducible code example so that we can try to reproduce your issue and analyze it in detail?
I also hit this, I think it is due to the agent streaming the responses. It happens when the root agent calls an agent as a tool and it return several chunks, but only the last one is processed.
I fixed it by overwriting the AgentTool run_async:
class StreamingAgentTool(AgentTool): async def run_async(self, *, args: dict[str, Any], tool_context: ToolContext) -> Any: content = types.Content( role='user', parts=[types.Part.from_text(text=args['request'])] ) runner = Runner( app_name=self.agent.name, agent=self.agent, artifact_service=ForwardingArtifactService(tool_context), session_service=InMemorySessionService(), memory_service=InMemoryMemoryService(), credential_service=tool_context._invocation_context.credential_service, plugins=list(tool_context._invocation_context.plugin_manager.plugins), ) state_dict = { k: v for k, v in tool_context.state.to_dict().items() if not k.startswith('_adk') # Filter out adk internal states } session = await runner.session_service.create_session( app_name=self.agent.name, user_id=tool_context._invocation_context.user_id, state=state_dict, ) # Not only taking the last content but all the chunks of the response chunks: list[str] = [] def iter_text_parts(parts: Iterable[Any]) -> Iterable[str]: for p in parts or []: # Keep empty strings "" but skip None if hasattr(p, "text") and p.text is not None: yield p.text async with Aclosing( runner.run_async( user_id=session.user_id, session_id=session.id, new_message=content ) ) as agen: async for event in agen: # Forward state delta to parent session. if event.actions.state_delta: tool_context.state.update(event.actions.state_delta) if event.content: chunks.extend(iter_text_parts(event.content.parts)) merged_text = "".join(chunks) return merged_textInstead of the default one which is only using the text from the parts on the last event:
last_content = None async with Aclosing( runner.run_async( user_id=session.user_id, session_id=session.id, new_message=content ) ) as agen: async for event in agen: # Forward state delta to parent session. if event.actions.state_delta: tool_context.state.update(event.actions.state_delta) if event.content: last_content = event.content if not last_content: return '' merged_text = '\n'.join(p.text for p in last_content.parts if p.text)
i will try this
confirm solution of @luis5tb worked. Thanks
Thank you @minhquan23102000 for sharing your fix and @minhquan23102000 for pitching in.
@marttinslucas , I hope this solution helps. I am closing this issue since we now have a resolution. If you still face any difficulties please feel free to reach out.
my solution here is kind of workaround while the AgentTool is failing. Shouldn't we fix the AgentTool to account for this instead of relying on custom class overwriting the AgentTool logic?
I agree with @luis5tb. While his workaround is definitely helpful, it seems like this still should be addressed in ADK's AgentTool itself?
@llalitkumarrr forgot to tag you. Should the issue be reopen until it is fixed at the AgentTool implementation?
We would like to analyze this issue in more detail. Could you please share the following information:
- Is this issue reproducible with Gemini models as well?
- Do you observe this issue 100% of the time?
- Could you share the code where you define the root agent and sub agents?
Yes, I was using Gemini model (2.5-flash) and it was reproduced 100% of the time. This is the definition of my root_agent:
root_agent = Agent(
model="gemini-2.5-flash",
name="planner_agent",
instruction=planner_instruction,
tools=[agent_tool_1, agent_tool_2, agent_tool_3],
planner=PlanReActPlanner()
)
Where agent_tool_X was something like:
agent_tool_1 = AgentTool(agent=agent_1)
And agent_1 is a remoteA2aAgent:
agent_1 = RemoteA2aAgent(....)
Hello @luis5tb ,
I was unable to reproduce this issue. I tested it using three sub-agents as AgentTool and everything worked as expected. However, please note that none of these tools were configured with remotea2aagent.
This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.
Hello team, what's happening for this issue? Any clean workaround?
Hello @anthonyr0ux ,
Are you using a remote agent? Kindly share the agent structure or if possible code for reproduction.
This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.
This has been automatically closed because it has been marked as stale for over 7 days.
THe same issue is happening with gemini models, we need a fix for this. Asking the prompt to continue if we get empty response does not seem to fix this Also same issue raised here: #3525 https://github.com/google/adk-python/issues/3525