A2A communication drops state context by invoking 4-argument runner.runAsync
Description
During Agent-to-Agent (A2A) communication, AgentExecutor.java triggers execution by calling runner.runAsync. However, it uses the 4-argument signature. Looking at Runner.java, this specific overload explicitly hardcodes /* stateDelta= */ null, completely dropping any custom state or metadata passed during the interaction.
To support agents that pass metadata or state deltas to guide downstream processing, AgentExecutor should extract this context and pass it into the 5-argument version of runAsync.
Code Reference
- The Call Site (AgentExecutor.java) AgentExecutor invokes the 4-argument method inside the execute pipeline:
return runner.runAsync(
getUserId(ctx),
session.id(),
content,
agentExecutorConfig.runConfig()); // <-- ISSUE: Invokes 4-arg variant
- The Root Cause Overload (Runner.java) In Runner.java, the 4-argument variant forces the state delta to be null:
public Flowable<Event> runAsync(
String userId, String sessionId, Content newMessage, RunConfig runConfig) {
return runAsync(userId, sessionId, newMessage, runConfig, /* stateDelta= */ null); // <-- ISSUE: Hardcoded null
}
Expected Behavior
AgentExecutor should extract the incoming state/metadata from the RequestContext ctx (or the incoming Message) and invoke the 5-argument version of runAsync so that the stateDelta is properly propagated into the session history.
Hi @anastasiiapeleshok-festcloud, Thank you for reporting this issue. I have tried to reproduce this issue using the latest version but was unable to observe the reported behavior. Could you please try with the Latest version 1.4.0 and if you are observing the same, Could you please share the repro steps and a minimal reproducible example along with the error logs? having this information will help us to investigate further and provide a solution.
Hi @anastasiiapeleshok-festcloud, Thank you for reporting this issue. I have tried to reproduce this issue using the latest version but was unable to observe the reported behavior. Could you please try with the Latest version
1.4.0and if you are observing the same, Could you please share the repro steps and a minimal reproducible example along with the error logs? having this information will help us to investigate further and provide a solution.
Hi @hemasekhar-p,
Thank you for looking into this! I realize my initial description might not have been clear enough.
To clarify, this issue doesn't produce any error logs or exceptions, which is likely why you couldn't observe it via standard reproduction attempts. Instead, it is a silent logical bug where data is being dropped at the code level.
I've attached two screenshots from the codebase (which is still present in the latest version) that highlight the exact execution path:
AgentExecutor.java (Screenshot 1): Starting at line 216, the execute method calls runner.runAsync(...). It only passes 4 arguments (userId, sessionId, content, runConfig).
Runner.java (Screenshot 2): Starting at line 365, the 4-argument runAsync overload acts as a wrapper. It calls the 5-argument method but explicitly hardcodes /* stateDelta= */ null as the final parameter.
Because AgentExecutor relies on this 4-argument wrapper, any stateDelta or metadata passed during Agent-to-Agent communication is instantly dropped and overwritten by that hardcoded null. It never reaches the underlying session processing.
To fix this, AgentExecutor needs to be updated to extract the state/metadata from the RequestContext, and directly invoke the 5-argument version of runAsync so the context is preserved.
Let me know if this helps clarify the problem.
Hi @anastasiiapeleshok-festcloud, Thank you for the detailed information. I have created this PR to resolve this problem. hope this PR will resolve your issue?
Hello, @anastasiiapeleshok-festcloud. We decided to go with the approach that aligns the functionality with ADK Python.
Instead of writing a2a:task_id / a2a:context_id into session state, AgentExecutor now routes the incoming request metadata (ctx.getParams().metadata()) into RunConfig.customMetadata under the a2a_metadata key and leaves the state delta null. This mirrors ADK Python a2a/converters/request_converter.py:
A2A_METADATA_KEY = 'a2a_metadata'(L31),custom_metadata[A2A_METADATA_KEY] = request_metadata(L104),run_config=RunConfig(custom_metadata=custom_metadata)(L120;state_deltadefaults toNone(L42) and is never forwarded (a2a_agent_executor.py L211).
The issue has been resolved in commit 410ff81 and will be included in the next release.