Conversation
Contributor
Author
|
Replaces the duplicate-work question on #7315 — @chelsealong, this is the PR I mentioned there. |
1wos
force-pushed
the
fix/a2a-no-exception-text-to-peer
branch
from
September 27, 2026 14:07
5617fec to
417feb1
Compare
Both executors put str(e) into the failed task status message, so any file path, hostname or credential carried by an exception raised inside the run reached the peer that made the request. Log the exception in full against a short error id and send the peer a fixed summary carrying only that id. Set ADK_A2A_DEBUG_ERRORS=1 to append the exception text when debugging locally. The existing impl test asserted the exception text was present; it now asserts it is absent. Fixes google#7315
1wos
force-pushed
the
fix/a2a-no-exception-text-to-peer
branch
from
September 27, 2026 14:09
417feb1 to
a9d501c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
A2aAgentExecutorpublishes raw exception text to the peer, bypassing theafter_agentinterceptor #73152. Or, if no issue exists, describe the change:
Problem:
Both executors put
str(e)into the failed task status message published to thepeer:
src/google/adk/a2a/executor/a2a_agent_executor.py:167src/google/adk/a2a/executor/a2a_agent_executor_impl.py:168The
except Exceptionwraps the whole of_handle_request, so it covers everyfailure inside the run — model calls, tool calls, database access, file I/O — and
forwards whatever those exceptions carry. Driving the existing failure path with
exceptions of a kind a real run raises:
A peer that only sent the agent a question receives the server's filesystem
layout, an internal host and port, a database password and part of an API key.
after_agentlooks like the place to redact this, and its docstring says it coversfailed terminal events (
config.py:75-79). That holds for a failure the runproduces itself:
error_eventbecomesfinal_eventand passes throughexecute_after_agent_interceptorsata2a_agent_executor_impl.py:249. It does nothold here, because the
exceptblock enqueues its own event directly after theexception has abandoned
_handle_request.Solution:
ADK_A2A_DEBUG_ERRORS=1appends the exception text, for local debugging.The helper lives in
executor/utils.py, which both executors already import forthe interceptor helpers, so neither file grows a private copy.
With the exception text no longer leaving the process, routing this event through
execute_after_agent_interceptorsbecomes a consistency question rather than amitigation. I left it out because
executor_contextis built inside thetry(
a2a_agent_executor_impl.py:107) and does not exist when the failure comes fromrequest_converteror_resolve_session, so covering it properly means hoistingthat construction. Happy to do it here if you would prefer.
Testing Plan
Unit Tests:
test_execute_with_exception_handlingintests/unittests/a2a/executor/test_a2a_agent_executor_impl.pyasserted that theexception text was present in the peer's message. It now asserts that the text is
absent and the fixed summary is present.
Three tests added:
test_execute_failure_message_omits_exception_textin both executors' testfiles — raises
FileNotFoundErroron/srv/secrets/sa-key.jsonand asserts thepath is absent and the whole message matches
Agent execution failed. (error_id: [0-9a-f]{8}).test_execute_failure_message_includes_detail_when_opted_in— assertsADK_A2A_DEBUG_ERRORS=1puts the exception text back.Reverting the change in either executor makes these tests fail.
Manual End-to-End (E2E) Tests:
Not a live deployment — I drove the failure path through the executor with the
repo's own test harness on main and on this branch, raising
FileNotFoundErroron a credentials path and capturing both the peer message and the log record.
On main, the peer receives the path:
On this branch the peer gets the id only, and the detail is in the log against
that same id, with the traceback attached:
With
ADK_A2A_DEBUG_ERRORS=1:Checklist
Additional context
pre-commit runpasses on all five touched files, includingruff,isort,pyink,codespelland the ADK compliance checks.The error id is 8 hex characters from
uuid4, which is enough to find one requestin a log without being a value anyone would treat as a secret.
Behavior change worth knowing: a peer that previously parsed the failure text to
learn why a request failed now only gets the id. That is the point of the change,
but it is visible.