RemoteA2aAgent(mode="task"): two calls to the same remote agent in one model turn send both requests to the first task and fail the second
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- backend, distributed-systems
Hướng nghiên cứu
Start by reading RemoteA2aAgent._construct_message_parts_from_session and _create_a2a_request_for_user_function_response, along with flows/llm_flows/context/_fencing.py and the related fixes in #6831 and #6844. Run the minimal reproduction against the supported versions to confirm both request paths. Done means each parallel call sends only its own request and the second call starts a new task instead of resuming the first.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🔴 Required Information
Describe the Bug:
When the coordinator's model calls the same remote task agent (RemoteA2aAgent(mode="task")) twice in one turn, as parallel function calls, ADK runs the two delegations one after the other and builds each A2A request from session history. Two things go wrong:
-
The first task's request carries both requests.
RemoteA2aAgent._construct_message_parts_from_sessionfinds the coordinator's event with the two function calls, and_is_other_agent_replyis true for it, so_present_other_agent_message(flows/llm_flows/context/_fencing.py) renders both calls as text. The sibling-call filter further down the same method (part.function_call.id != task_scope) only sees text parts by then and has nothing to skip. The remote agent is asked for both reports in its first task. -
The second task is sent as a resume of the first. After the first task completes, ADK synthesizes its function response as an event authored by
"user"and it is the last event in the session when the second task starts.RemoteA2aAgent._create_a2a_request_for_user_function_responseaccepts it (events[-1].author == "user", andfind_matching_function_callfinds the coordinator's two-call event, which holds the id), and sends a message carrying the function response for call 1 to the remote agent. The remote agent has no such call and rejects it. Without any other part in the request:Function call not found for function response ids: {'adk-...'}. Ensure each function response ID matches an existing function call in the session history.When the same request also carries text parts (for instance, an interceptor adding earlier results as context), the remote runner's
_validate_new_messagerefuses it first:Message cannot contain both function responses and text. Function responses resume an existing invocation while text starts a new one.The second task fails, and the coordinator's model gets the error text as the task's result.
This is related to, but not the same shape as, #6831 / #6844 (a completed delegation's function response sent to a different peer): that fix renders a historical function response as text inside _construct_message_parts_from_session; here the failing path is _create_a2a_request_for_user_function_response, which runs before it and treats the same-agent response as a resume, and the first defect is in how the coordinator's multi-call event is rendered.
Steps to Reproduce:
pip install "google-adk[a2a]==2.11.0"(or 2.14.1)- Save the script under "Minimal Reproduction Code" and run it.
- It builds the session ADK has when the second of two same-turn calls to the task agent starts, and asks
RemoteA2aAgentwhat it would send.
Expected Behavior:
- The request of the task started by call
c-0contains only callc-0's request, not the sibling'sc-1. - The task started by call
c-1is sent as a new task: the user-authored function response forc-0answers a call this agent's earlier task already completed, it is not a pause the remote agent raised.
Observed Behavior:
1) request of the FIRST delegation (call c-0, 'Revenue 0'):
: <<<BEGIN_QUOTED_AGENT_CONTENT>>> {'request': 'Revenue 0'}
: <<<BEGIN_QUOTED_AGENT_CONTENT>>> {'request': 'Revenue 1'}
2) SECOND delegation (call c-1) treats the response to c-0 as a resume:
sends a function response
With real served agents, the second task fails with one of the two errors above.
Environment Details:
- ADK Library Version (pip show google-adk): 2.11.0; the code involved is unchanged in 2.14.1 (same output from the script)
- Desktop OS: macOS
- Python Version (python -V): 3.12
Model Information:
- Are you using LiteLLM: No
- Which model is being used: any; the defect is in request construction, not model-dependent
🟡 Optional Information
Regression:
Not checked.
Additional Context:
Workaround in a RemoteA2aAgent subclass: override _construct_message_parts_from_session and _create_a2a_request_for_user_function_response to call super() with a context whose session events have each coordinator event holding several function calls, one of which has id == ctx.isolation_scope, replaced by a copy that keeps only that call. Both defects go away: each task's request holds its own call only, and the earlier task's function response no longer matches a call in the session.
Minimal Reproduction Code:
from types import SimpleNamespace
from google.adk.agents.remote_a2a_agent import RemoteA2aAgent
from google.adk.events.event import Event
from google.genai import types
def event(author, *parts, role="model", **kw):
return Event(
author=author,
invocation_id="inv-1",
content=types.Content(role=role, parts=list(parts)),
**kw,
)
def call(call_id, request):
return types.Part(
function_call=types.FunctionCall(
id=call_id, name="reporting", args={"request": request}
)
)
def ctx_for(events, scope):
return SimpleNamespace(
session=SimpleNamespace(id="s1", app_name="app", user_id="u", events=events),
app_name="app",
user_id="u",
invocation_id="inv-1",
branch=None,
isolation_scope=scope,
)
peer = RemoteA2aAgent(
name="reporting", agent_card="http://127.0.0.1:9/card.json", mode="task"
)
asked = event("user", types.Part(text="Revenue"), role="user")
coordinator = event("orchestrator", call("c-0", "Revenue 0"), call("c-1", "Revenue 1"))
parts, _ = peer._construct_message_parts_from_session(
ctx_for([asked, coordinator], "c-0")
)
print("1) request of the FIRST delegation (call c-0, 'Revenue 0'):")
for part in parts:
text = (part.text or str(part.data)).replace("\n", " ")
print(" ", text.split("<<<END_QUOTED_AGENT_CONTENT>>>")[0][-60:])
first_response = event(
"user",
types.Part(
function_response=types.FunctionResponse(
id="c-0", name="reporting", response={"output": "report A"}
)
),
role="user",
)
resume = peer._create_a2a_request_for_user_function_response(
ctx_for([asked, coordinator, first_response], "c-1")
)
print("2) SECOND delegation (call c-1) treats the response to c-0 as a resume:")
print(" ", "sends a function response" if resume is not None else "no resume")
How often has this issue occurred?:
- Always (100%)
- Ngôn ngữ chính
- Python
- Star
- 22.3k
- Fork
- 4.4k
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/adk-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
google/adk-python#8360 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
google/adk-python#8359 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Can pin to litellm version be changed?Có thể đã có người làm @llalitkumarrr đã nhận 10 ngày trước. Đang mởmodels
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
google/adk-python#8129 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
OpenAPI tools ignore operation- and path-level server overridesCó thể đã có người làm @sanketpatil06 đã nhận 14 ngày trước. Đang mởtools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
google/adk-python#8064 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Two docstrings in openapi_tool document parameters the signatures do not acceptCó thể đã có người làm @surajksharma07 đã nhận 17 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
google/adk-python#8024 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của google/adk-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
vllm-project/vllm#70030 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TigreGotico/tugaphone#408 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
gke-labs/kube-agents#7308 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
t: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 3 ngày
-
chore
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
lugassawan/swe-workbench#841 ·