Skip to content

fix: Enable state context in AgentExecutor#1273

Open
hemasekhar-p wants to merge 1 commit into
google:mainfrom
hemasekhar-p:a2a-drops-state-fix
Open

fix: Enable state context in AgentExecutor#1273
hemasekhar-p wants to merge 1 commit into
google:mainfrom
hemasekhar-p:a2a-drops-state-fix

Conversation

@hemasekhar-p

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
During Agent-to-Agent (A2A) communication, AgentExecutor.java triggers execution by invoking a 4-argument overload of runner.runAsync(). This specific signature in Runner.java hardcodes stateDelta to null, completely discarding any custom state or metadata passed during the interaction instead of properly propagating it to the session history

Solution:
To fix this issue, updated the AgentExecutor to extract the metadata from the RequestContext and directly invoking the 5-argument version of runAsync.

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Checklist

  • I have read the CONTRIBUTING.md document.
  • My pull request contains a single commit.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

@hemasekhar-p

Copy link
Copy Markdown
Contributor Author

@anFatum, Could you please review this PR.

Comment thread a2a/src/main/java/com/google/adk/a2a/executor/AgentExecutor.java Outdated
@hemasekhar-p hemasekhar-p force-pushed the a2a-drops-state-fix branch 4 times, most recently from 2afd942 to a0de26a Compare June 30, 2026 06:00
@krwc

krwc commented Jul 1, 2026

Copy link
Copy Markdown

Before this can go in, I dug into the Python ADK A2A executor (our reference implementation) to check the intended behavior, and I think this change needs a rethink on what gets propagated and how.

In Python ADK, the equivalent of this execute() step is convert_a2a_request_to_agent_run_request(), which builds the args for runner.run_async():
https://github.com/google/adk-python/blob/main/src/google/adk/a2a/converters/request_converter.py#L100-L118

custom_metadata = {}
if request.metadata:
    custom_metadata[A2A_METADATA_KEY] = request.metadata   # the caller's metadata
...
return AgentRunRequest(
    ...
    run_config=RunConfig(custom_metadata=custom_metadata),  # NOTE: no state_delta is passed here
)

So Python:

  • propagates the caller's incoming request.metadata, and
  • carries it via RunConfig.custom_metadata (which the runner then stamps onto
    each event's custom_metadata).
  • it leaves state_delta unset.

This PR on the other hand, puts framework-generated taskId/contextId into stateDelta (session state) which appears to be a completely different thing. We should align Java with Python ADK.

@krwc krwc added the waiting on reporter Waiting for reaction by reporter. Failing that, maintainers will eventually closed it as stale. label Jul 1, 2026
@krwc krwc self-requested a review July 1, 2026 13:13
@krwc krwc removed the needs review label Jul 2, 2026
@hemasekhar-p hemasekhar-p force-pushed the a2a-drops-state-fix branch from a0de26a to d8df357 Compare July 2, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting on reporter Waiting for reaction by reporter. Failing that, maintainers will eventually closed it as stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A2A communication drops state context by invoking 4-argument runner.runAsync

3 participants