You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Runner.run_async runs an LlmAgent with neither new_message nor invocation_id instead of raising ValueError #7934
Describe the Bug: Runner.run_async documents "Raises: ValueError: ... If both invocation_id and new_message are None.", and _run_with_trace has that check ("Running an agent requires either a new_message or an invocation_id ..."). But when the root agent is an LlmAgent, run_async takes the _run_node_async branch first and returns before reaching the check. So the run starts with no user message and calls the model with empty contents.
Steps to Reproduce:
pip install google-adk==2.13.0
Run the script below. It uses a recording model, so no API key is needed.
Expected Behavior: ValueError, as documented, before the model is called.
Observed Behavior:
No error; the model is called once with no contents.
Environment Details:
ADK Library Version (pip show google-adk): 2.13.0, and main at 95d8610
Desktop OS: Linux
Python Version (python -V): 3.12
Model Information:
Are you using LiteLLM: No
Which model is being used: a BaseLlm subclass that records its calls (any model shows it)
Additional Context:
In runners.py the if isinstance(self.agent, LlmAgent): branch (and the BaseNode one after it) return before _run_with_trace, where the check is. Moving the check before those branches covers them all.
Hi! I was able to reproduce this locally on ADK 2.13.0. In Runner.run_async, the LlmAgent branch routes into _run_node_async and returns early before reaching the new_message/invocation_id check in _run_with_trace, resulting in calling the model with empty contents instead of raising ValueError.
I'd like to work on this and submit a PR with unit tests. Could you please assign this to me?
@yifanxiong272. Reproduced this on 2.13.0 and on current main for both an LlmAgent and a Workflow root while a BaseAgent root still raises. In 1.x every root raised so this looks like it came in with the 2.x node path.
@mohitdixit02 one thing on #7936: a few existing tests run with new_message=None on purpose to re-run over the session history (test_llm_agent_include_contents.py and two in test_compaction_runner_e2e.py) and they fail with the check moved to the top as-is.
As a workaround, raising only when there’s no new_message, no invocation_id and the session has no events kept those tests green and still raised for the empty case. Could you both check if that works on your side?
Before #7936 goes for review please give it a full run of the runner, include_contents and compaction tests and add a case for a session that already has history.
I've updated the check in #7936 to inspect not session.events before raising when new_message and invocation_id are absent.
Full runs of test_runners.py, test_compaction_runner_e2e.py, and test_llm_agent_include_contents.py are all fine, and I've added a unit test covering run_async execution over existing session history with new_message=None.
Activity
mohitdixit02 commentedon Nov 2, 2026
Hi! I was able to reproduce this locally on ADK 2.13.0. In
Runner.run_async, theLlmAgentbranch routes into_run_node_asyncand returns early before reaching thenew_message/invocation_idcheck in_run_with_trace, resulting in calling the model with empty contents instead of raisingValueError.I'd like to work on this and submit a PR with unit tests. Could you please assign this to me?
surajksharma07 commentedon Nov 2, 2026
@yifanxiong272. Reproduced this on 2.13.0 and on current main for both an LlmAgent and a Workflow root while a BaseAgent root still raises. In 1.x every root raised so this looks like it came in with the 2.x node path.
@mohitdixit02 one thing on #7936: a few existing tests run with new_message=None on purpose to re-run over the session history (test_llm_agent_include_contents.py and two in test_compaction_runner_e2e.py) and they fail with the check moved to the top as-is.
As a workaround, raising only when there’s no new_message, no invocation_id and the session has no events kept those tests green and still raised for the empty case. Could you both check if that works on your side?
Before #7936 goes for review please give it a full run of the runner, include_contents and compaction tests and add a case for a session that already has history.
fix(runner): permit run_async without new_message when session has hi…
mohitdixit02 commentedon Nov 3, 2026
@surajksharma07
Checked on my end and that works cleanly.
I've updated the check in #7936 to inspect
not session.eventsbefore raising whennew_messageandinvocation_idare absent.Full runs of
test_runners.py,test_compaction_runner_e2e.py, andtest_llm_agent_include_contents.pyare all fine, and I've added a unit test coveringrun_asyncexecution over existing session history withnew_message=None.Pushed the update to the PR branch!