adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

A2A artifact delivery interceptor exists but is never enabled by default

Open Venseven opened this issue 7 months ago • 3 comments

Summary

include_artifacts_in_a2a_event_interceptor was added in commit e63d991 to allow artifact delivery on the A2A path. However it is opt-in only — A2aAgentExecutorConfig.execute_interceptors defaults to None, and fast_api.py constructs A2aAgentExecutor with no config.

As a result, agents that save artifacts during a run (via artifact_service.save_artifact) have no way to deliver them to A2A callers without patching internal ADK code. Issue #3630 was closed as resolved but the fix is incomplete.

Reproduction

  1. Build an agent that calls artifact_service.save_artifact() during a run
  2. Call the agent via A2A message/send or message/stream
  3. Observe: no TaskArtifactUpdateEvent is emitted — event.actions.artifact_delta is silently dropped

Root cause

In fast_api.py:

agent_executor = A2aAgentExecutor(
    runner=create_a2a_runner_loader(app_name),
    # no config passed — execute_interceptors defaults to None
)

In config.py:

execute_interceptors: Optional[list[ExecuteInterceptor]] = None
# interceptor exists but never wired

Proposed fix

Default execute_interceptors to [include_artifacts_in_a2a_event_interceptor] in A2aAgentExecutorConfig:

from .interceptors.include_artifacts_in_a2a_event import include_artifacts_in_a2a_event_interceptor

execute_interceptors: list[ExecuteInterceptor] = dataclasses.field(
    default_factory=lambda: [include_artifacts_in_a2a_event_interceptor]
)

This is a non-breaking change — the interceptor is a no-op when artifact_delta is empty or artifact_service is None. Users who want to opt out can pass execute_interceptors=[] explicitly.

Relates to

Closes #3630 (actually)

Venseven avatar Apr 17 '26 22:04 Venseven

Hi! I'd like to work on this.

The fix looks straightforward — two small changes:

  1. In A2aAgentExecutorConfig, default execute_interceptors to include include_artifacts_in_a2a_event_interceptor:
from .interceptors.include_artifacts_in_a2a_event import include_artifacts_in_a2a_event_interceptor

execute_interceptors: list[ExecuteInterceptor] = dataclasses.field(
    default_factory=lambda: [include_artifacts_in_a2a_event_interceptor]
)
  1. In fast_api.py, pass a config to A2aAgentExecutor (or rely on the updated default).

As noted in the issue, this is a non-breaking change since the interceptor is a no-op when artifact_delta is empty or artifact_service is None. Users who want to opt out can still pass execute_interceptors=[] explicitly.

I'd add unit tests covering the artifact delivery path via A2A. Would a PR in this direction be welcome?

nileshpatil6 avatar Apr 19 '26 19:04 nileshpatil6

@Venseven As a workaround worth trying: default execute_interceptors in A2aAgentExecutorConfig using a lazy Field(default_factory=...) with a local import inside the factory to break the circular import between config.py and include_artifacts_in_a2a_event.py.

Could you verify if that resolves it on your end and run your artifact delivery tests against it before moving forward with the PR?

surajksharma07 avatar Apr 20 '26 12:04 surajksharma07

Closing this issue due to inactivity for more than 14 days.

llalitkumarrr avatar May 19 '26 08:05 llalitkumarrr