Skip to content

BUG: AG-UI-ADK middle ware. ValueError: Both invocation_id and new_message are None when message_batch is None #735

@minhquan23102000

Description

@minhquan23102000

Environment

  • Package: ag_ui_adk
  • ADK: google.adk
  • Python: 3.12

Bug Description

runner.run_async() raises ValueError when both invocation_id and new_message are None. This occurs intermittently when there's no message_batch and no user messages to process.


Error Log

Background execution error: Both invocation_id and new_message are None.

Traceback (most recent call last):
  File "...\ag_ui_adk\adk_agent.py", line 1232, in _run_adk_in_background
    async for adk_event in runner.run_async(**run_kwargs):
  File "...\google\adk\runners.py", line 443, in run_async
    async for event in agen:
  File "...\google\adk\runners.py", line 382, in _run_with_trace
    raise ValueError('Both invocation_id and new_message are None.')
ValueError: Both invocation_id and new_message are None.

Root Cause

In adk_agent.py_run_adk_in_background:

# Line 1080
user_message = await self._convert_latest_message(input, unseen_messages) if message_batch else None

# Line 1186-1188 (else branch)
else:
    new_message = user_message  # Can be None

# Line 1225-1232
run_kwargs = {
    "user_id": user_id,
    "session_id": input.thread_id,
    "new_message": new_message,  # None
    "run_config": run_config
    # invocation_id is NOT included
}
async for adk_event in runner.run_async(**run_kwargs):  # Raises error

Condition:

  1. message_batch = Noneuser_message = None
  2. active_tool_results = None or empty
  3. Falls to else branch → new_message = None
  4. invocation_id not in run_kwargs
  5. ADK receives both as None → raises error

Suggested Fix

Add validation before calling runner.run_async():

# Before line 1225
if new_message is None:
    logger.warning(
        f"No new_message to process for thread {input.thread_id}, skipping ADK execution"
    )
    await event_queue.put(None)  # Signal completion
    return

Affected File

ag_ui_adk/adk_agent.py ~ line 1225


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions