Workflow RequestInput: an object answer with a field named result is unwrapped, so the workflow can never resume
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue nà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
- 55/100
Hướng nghiên cứu
The answer is unwrapped by _unwrap_response, called from _reconstruct_node_states in src/google/adk/workflow/utils/_rehydration_utils.py. Run the reproduction in the issue to see the WorkflowDataError, then read how the schema is checked in that path. Done when a {"result": "pass"} answer to a schema with a result field resumes the workflow, and the existing tests in tests/unittests/workflow/utils/test_rehydration_utils.py, including the non-JSON text rejection case, still pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
When a Workflow node pauses with RequestInput(response_schema=SomeModel) and the model has a field named result, a correct answer can never resume the workflow. The answer {"result": "pass"} is unwrapped to "pass" (the shape a plain text reply arrives in) and then rejected as "not a valid dictionary". Every retry fails the same way.
result is a common field name for review, check or approval answers.
Reproduction
Run on current main (4e3aff79):
import asyncio
from typing import Literal
from google.adk import Workflow
from google.adk.events import RequestInput
from google.adk.runners import Runner
from google.adk.sessions.in_memory_session_service import InMemorySessionService
from google.genai import types
from pydantic import BaseModel
class Review(BaseModel):
result: Literal["pass", "fail"]
def ask(node_input: str):
return RequestInput(interrupt_id="q", message="review", response_schema=Review)
def after(node_input: Review):
return f"review {node_input.result}"
async def main():
ss = InMemorySessionService()
wf = Workflow(name="wf", edges=[("START", ask, after)])
async def turn(msg):
r = Runner(app_name="app", node=wf, session_service=ss, auto_create_session=True)
return [e async for e in r.run_async(user_id="u", session_id="s1", new_message=msg)]
await turn(types.Content(role="user", parts=[types.Part(text="hi")]))
answer = types.FunctionResponse(id="q", name="adk_request_input", response={"result": "pass"})
try:
for e in await turn(types.Content(role="user", parts=[types.Part(function_response=answer)])):
print(e.author, "output=", e.output)
except Exception as ex:
print("EXC", type(ex).__name__, ex)
asyncio.run(main())
Actual
EXC WorkflowDataError Validation failed for interrupt q: Validation failed for object schema: 1 validation error for DynamicModel
Input should be a valid dictionary or instance of DynamicModel [type=model_type, input_value='pass', input_type=str]
Expected
after output= review pass
Cause
_reconstruct_node_states in src/google/adk/workflow/utils/_rehydration_utils.py always passes the answer through _unwrap_response, which turns {"result": x} into x. That is right for a text reply, which arrives as {"result": "<text>"}, but wrong when the schema itself declares a result property.
Proposed fix
Keep the answer as sent when the schema is an object that declares a result property, unless the answer is a text reply whose JSON parses to an object ({"result": '{"result": "fail"}'} still works as now). The change is limited to schemas that declare result:
- An object schema without a
resultfield behaves as now; a text reply that is not JSON is still rejected. - A
resultfield that holds an object (result: dict[str, int]answered with{"result": {"k": 1}}) also works now; onmainit fails the same way.
There are regression tests in tests/unittests/workflow/utils/test_rehydration_utils.py: the result cases fail on main and pass with the fix, and the negative case guards against accepting non-JSON text. The rehydration and HITL workflow tests pass (171).
Related: #8359 (optional fields losing their schema defaults in the same answer path). It changes different lines of the same file, and the two fixes merge cleanly.
I used an AI coding assistant (Claude) to find and analyse this; I reproduced it and checked the fix myself.
I've tested a fix with a regression test: https://github.com/chaitanya0305/adk-python/compare/main...chaitanya0305:adk-python:fix/resume-object-schema-result-field. If this is accepted, I'll open the PR straight away.
- 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 ·