Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

A2aAgentExecutor sends the raw exception text to the A2A caller when the run fails

未關閉 適合新手
#7,385 2 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 4 天內回覆

@sanketpatil06 已經在處理了。

開始於 2026年10月5日。

  • #7402 來自 @AbQaadir —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
84/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
api, backend

研究方向

先從 a2a/executor/a2a_agent_executor.py 和 a2a/executor/a2a_agent_executor_impl.py 中的兩個例外處理路徑開始,然後執行隨附的 ASGI 重現。確認失敗的工作會傳回一般訊息或由伺服器選擇的訊息,不包含原始例外的詳細資訊,同時完整例外仍可在伺服器記錄中取得。

由索引模型根據 Issue 內容生成。

描述

a2a request clarification

🔴 Required Information

Describe the Bug:

When the agent run raises, A2aAgentExecutor.execute ends the task with a TASK_STATE_FAILED status whose message is str(e) (make_text_part(str(e)) in a2a/executor/a2a_agent_executor.py, and the same line in a2a_agent_executor_impl.py). Whatever the exception says goes to the A2A caller verbatim.

Some exceptions say a lot. LiteLLM's APIConnectionError, for one, embeds the Python traceback in its message, so the caller receives the server's file paths:

litellm.APIConnectionError: litellm.APIError: LiteLLM: provider returned a response with no 'choices'. ...
Traceback (most recent call last):
  File "<server venv>/lib/python3.12/site-packages/litellm/llms/openai/openai.py", line 900, in acompletion
    final_response_obj = convert_to_model_response_object(
...

When the caller is an ADK RemoteA2aAgent, that text then reaches the calling agent's event stream as a plain text part (#6708), so its end user reads it as the agent's answer. That is how we found it: a user of one of our agents got the traceback above as a reply.

The server already logs the exception with exc_info=True on the line before, so the caller does not need the detail.

Steps to Reproduce:

  1. pip install "google-adk[a2a]==2.11.0" "a2a-sdk[http-server]==1.2.1"
  2. Run the script below. It serves an ADK A2aAgentExecutor in process over httpx.ASGITransport, with a model that raises, and sends one SendMessage. It needs no network or credentials.
repro.py
"""What an A2A caller receives when the served ADK agent's run raises."""

import asyncio
import json
import logging
import warnings

import httpx
from a2a.server.request_handlers import DefaultRequestHandler
from a2a.server.routes import add_a2a_routes_to_fastapi, create_jsonrpc_routes
from a2a.server.tasks import InMemoryTaskStore
from a2a.types import AgentCapabilities, AgentCard, AgentInterface
from fastapi import FastAPI
from google.adk.a2a.executor.a2a_agent_executor import A2aAgentExecutor
from google.adk.agents import LlmAgent
from google.adk.models.base_llm import BaseLlm
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService

warnings.filterwarnings("ignore")
logging.disable(logging.CRITICAL)


class FailingModel(BaseLlm):  # stands in for a provider error
    async def generate_content_async(self, llm_request, stream=False):
        raise RuntimeError(
            "provider rejected the call: Traceback (most recent call last):\n"
            '  File "/srv/agent/.venv/lib/python3.12/site-packages/provider/client.py", line 900'
        )
        yield


async def main():
    card = AgentCard(
        name="agent",
        description="agent",
        version="1",
        capabilities=AgentCapabilities(streaming=True),
        default_input_modes=["text/plain"],
        default_output_modes=["text/plain"],
        supported_interfaces=[
            AgentInterface(url="http://agent.test/a2a", protocol_binding="JSONRPC")
        ],
    )
    agent = LlmAgent(name="agent", model=FailingModel(model="fake"), instruction="x")
    executor = A2aAgentExecutor(
        runner=Runner(
            app_name="app",
            agent=agent,
            session_service=InMemorySessionService(),
            auto_create_session=True,
        )
    )
    app = FastAPI()
    add_a2a_routes_to_fastapi(
        app,
        jsonrpc_routes=create_jsonrpc_routes(
            DefaultRequestHandler(executor, InMemoryTaskStore(), card), rpc_url="/a2a"
        ),
    )
    async with httpx.AsyncClient(
        transport=httpx.ASGITransport(app=app), base_url="http://agent.test"
    ) as client:
        response = await client.post(
            "/a2a",
            headers={"A2A-Version": "1.0"},
            json={
                "jsonrpc": "2.0",
                "id": 1,
                "method": "SendMessage",
                "params": {
                    "message": {
                        "messageId": "m1",
                        "role": "ROLE_USER",
                        "parts": [{"text": "hello"}],
                    }
                },
            },
        )
    status = response.json()["result"]["task"]["status"]
    print(json.dumps(status, indent=2))


asyncio.run(main())

Expected Behavior:

The failed status carries a generic message, or one the server chooses, and the exception's details stay in the server's log. ADK already has a path for a chosen message: convert_event_to_a2a_events turns an event with error_code into a TASK_STATE_FAILED status carrying the event's error_message, or DEFAULT_ERROR_MESSAGE. Only an exception that escapes the run takes the str(e) path.

Observed Behavior:

{
  "state": "TASK_STATE_FAILED",
  "message": {
    "messageId": "5f89d64d-db72-4846-a968-c014801f3870",
    "role": "ROLE_AGENT",
    "parts": [
      {
        "text": "provider rejected the call: Traceback (most recent call last):\n  File \"/srv/agent/.venv/lib/python3.12/site-packages/provider/client.py\", line 900"
      }
    ]
  },
  "timestamp": "2026-10-02T20:45:29.502125Z"
}

Environment Details:

  • ADK Library Version (pip show google-adk): 2.11.0, with a2a-sdk 1.2.1. Both make_text_part(str(e)) lines are unchanged on main.
  • Desktop OS: macOS
  • Python Version (python -V): 3.12.12

Model Information:

  • Are you using LiteLLM: Yes in production, where the exception came from. No in the reproduction, which uses a BaseLlm that raises.
  • Which model is being used: Gemini through a LiteLLM proxy in production, N/A for the reproduction.

🟡 Optional Information

Regression:

Not known.

Related:

  • #6708: on the client side, RemoteA2aAgent passes a failed task's status message on as ordinary content.
  • #7248 / #7251: on the client side, a failed task never closes a task-mode delegation.
主要語言
Python
星號
21.9k
分支
4.2k
平均合併
3 天 16 小時
30 天內合併 PR
6

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

google/adk-python 的其他 Issue

查看 google/adk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。