`load_mcp_resource`: only one MCP server's resources reach the model when one response reads from two toolsets
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/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
- ai-infra-agents
Hướng nghiên cứu
Start in LoadMcpResourceTool._append_resources_to_llm_request in the load_mcp_resource tool module, which only inspects llm_request.contents[-1] for its function response. Run the minimal reproduction from the issue: two tools answering in one response should both insert their resource text. Done when both POLICY TEXT and CALENDAR TEXT appear. A fix is already open in pull request 8348, so check it 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:
An agent has two McpToolsets, both with use_mcp_resources=True. When the model calls both resource tools in the same response, only the first toolset's resource text is inserted into the next request. The second call still returns "resource contents temporarily inserted and removed...", so nothing signals the loss and the model answers as if the second resource were empty.
LoadMcpResourceTool._append_resources_to_llm_request looks for its function response only in llm_request.contents[-1], and appends each resource it reads as a new Content at the end. Parallel function responses are merged into one content, and every tool's process_llm_request runs on the same request in turn. After the first tool appends Resource <name> is:, contents[-1] is no longer the function-response content, so the second tool finds nothing.
tool_name_prefix does not avoid it: the miss is positional, not by name. Without a prefix both tools are named load_mcp_resource, so the first one additionally tries to read the other server's resource from its own server (see Logs).
Steps to Reproduce:
- Install
google-adk[mcp] - Run the code under "Minimal Reproduction Code" (no model and no MCP server needed)
- Only the first server's resource is printed
Expected Behavior:
Both resources are inserted: ['Resource policy is:', 'POLICY TEXT', 'Resource calendar is:', 'CALENDAR TEXT']
Observed Behavior:
['Resource policy is:', 'POLICY TEXT']
No error or stack trace.
Environment Details:
- ADK Library Version (pip show google-adk): 2.15.1. Same result on 2.12.0, 2.14.1 and 2.15.0;
mainhad the samecontents[-1]check on 2026-11-25 - Desktop OS: Linux
- Python Version (python -V): 3.13.7
Model Information:
- Are you using LiteLLM: N/A (the reproduction calls no model)
- Which model is being used: N/A
🟡 Optional Information
Regression:
Not that I know of.
Logs:
Only without tool_name_prefix (remove the line that sets a.name, b.name):
Failed to read MCP resource 'calendar': 'calendar'
Screenshots / Video:
N/A
Additional Context:
Possible fix: before checking the last content, skip the trailing Resource ... is: contents that other resource tools appended to this same request. Searching the whole history for the function response instead would re-insert the resource on later turns.
f199858e ("match tool response by name instead of assuming first part") fixed the neighbouring case of several responses in one content.
Minimal Reproduction Code:
import asyncio
from google.adk.models.llm_request import LlmRequest
from google.adk.tools.load_mcp_resource_tool import LoadMcpResourceTool
from google.genai import types
from mcp import types as mt
class Server:
def __init__(self, docs):
self.docs = docs
async def list_resources(self, readonly_context=None):
return list(self.docs)
async def read_resource(self, name, readonly_context=None):
return [mt.TextResourceContents(uri=f"doc://{name}", text=self.docs[name])]
async def main():
a = LoadMcpResourceTool(Server({"policy": "POLICY TEXT"}))
b = LoadMcpResourceTool(Server({"calendar": "CALENDAR TEXT"}))
a.name, b.name = "a_load_mcp_resource", "b_load_mcp_resource" # as tool_name_prefix would
def response(tool, names):
return types.Part(
function_response=types.FunctionResponse(
name=tool.name, response={"resource_names": names, "status": "x"}
)
)
request = LlmRequest(
contents=[
types.Content(
role="user",
parts=[response(a, ["policy"]), response(b, ["calendar"])],
)
]
)
for tool in (a, b):
await tool._append_resources_to_llm_request(
tool_context=None, llm_request=request
)
print([p.text for c in request.contents[1:] for p in c.parts if p.text])
asyncio.run(main())
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 ·