evals: AgentConfig.from_agent raises AttributeError for workflow / non-LlmAgent root agents (no 'tools' field)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Bắt đầu với _get_tool_declarations_from_agent và AgentConfig.from_agent trong vertexai/_genai/types/evals.py, sau đó so sánh với bản sao phản chiếu trong agentplatform/_genai/types/evals.py. Chạy bản tái hiện SequentialAgent và kiểm tra các đường dẫn run_inference và AgentInfo.load_from_agent. Được xem là hoàn tất khi các root của workflow không còn phát sinh AttributeError, không báo cáo tool nào ở root và vẫn đệ quy vào sub_agents.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
google-cloud-aiplatform: 1.156.0google-adk: 2.2.0- Python: 3.12
Summary
vertexai.types.evals.AgentConfig.from_agent() raises AttributeError when the root agent is a workflow / non-LlmAgent agent — i.e. any BaseAgent subclass such as SequentialAgent, ParallelAgent, LoopAgent, or a custom BaseAgent. Those agents do not define a tools field; only LlmAgent does.
_get_tool_declarations_from_agent reads agent.tools directly (no default), whereas the sibling fields in from_agent (description, instruction, sub_agents) all use getattr(agent, ..., default). As a result, introspection fails before any inference runs, which makes client-side eval impossible for any multi-agent system whose root is an orchestrator.
This affects every public entry point that introspects a live agent:
client.evals.run_inference(agent=...)→AgentConfig.from_agent(agent)types.evals.AgentInfo.load_from_agent(agent=...)→AgentData.get_agents_map(agent)→AgentConfig.from_agent(agent)
Reproduction
from google.adk.agents import LlmAgent, SequentialAgent
from vertexai import types
leaf = LlmAgent(name="step", model="gemini-2.5-flash", instruction="do a step")
wf = SequentialAgent(name="pipeline", sub_agents=[leaf])
types.evals.AgentConfig.from_agent(wf)
Actual behavior
Traceback (most recent call last):
File ".../vertexai/_genai/types/evals.py", line 128, in from_agent
tools=AgentConfig._get_tool_declarations_from_agent(agent),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../vertexai/_genai/types/evals.py", line 86, in _get_tool_declarations_from_agent
for tool in agent.tools:
^^^^^^^^^^^
File ".../pydantic/main.py", line 1042, in __getattr__
raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'SequentialAgent' object has no attribute 'tools'
The same failure occurs via client.evals.run_inference(agent=wf) and types.evals.AgentInfo.load_from_agent(agent=wf), since both reach AgentConfig.from_agent.
Expected behavior
from_agent should treat a missing tools field as "no tools", consistent with how it already handles instruction and sub_agents. A workflow root with LlmAgent leaves should produce an AgentConfig with empty tools for the root and recurse into sub_agents normally.
Suggested fix
In _get_tool_declarations_from_agent (vertexai/_genai/types/evals.py, and the mirrored agentplatform/_genai/types/evals.py copy), iterate over a guarded value:
for tool in getattr(agent, "tools", None) or []:
...
This mirrors the existing getattr(...) usage for the other fields in from_agent.
Related
Distinct from #6861 / #6862, which addressed a TypeError for toolset elements within tools (e.g. McpToolset). Here the tools attribute is absent entirely. Both point at the same fragile extraction path.
Workaround
Inject an empty list before introspection:
if not hasattr(root_agent, "tools"):
object.__setattr__(root_agent, "tools", [])
- Ngôn ngữ chính
- Python
- Star
- 907
- Fork
- 467
- Merge trung bình
- 1 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 44
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 googleapis/python-aiplatform
-
Protobuf 7.35.1+ support Đang mởapi: vertex-ai
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
googleapis/python-aiplatform#7132 ·
-
api: vertex-ai
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
googleapis/python-aiplatform#7097 · 1 bình luận ·
-
CustomContainerTrainingJob.run drops max_wait_duration=0 instead of requesting indefinite DWS wait Đang mởapi: vertex-ai
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
googleapis/python-aiplatform#7067 · 1 bình luận ·
-
api: vertex-ai
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
googleapis/python-aiplatform#6877 ·
-
api: vertex-ai
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
googleapis/python-aiplatform#6822 · 2 reaction ·
Tất cả issue của googleapis/python-aiplatform
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
use-agent-os/agent-os#3314 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
BasedHardware/omi#15662 · 1 bình luận ·
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
AiursoftWeb/AnduinOS-2#19 ·