[BUG] HITL ask_user_response: the documented shape is wrong, and a malformed response leaves the task stuck in working

Đang mở
#3,313 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@suryakant-source đang làm issue này rồi.

Từ ngày 23/10/2026.

Đá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ệ
go

Hướng nghiên cứu

Start with go/api/a2a/hitl.go and docs/architecture/human-in-the-loop.md, then trace how SendMessage validates and dispatches HITL responses before task input is persisted. Check how malformed payloads affect task state and how existing tests cover both response types. Done means malformed responses are rejected while the task remains input-required, and the docs show the exact JSON shapes for both response types.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug description

Two related problems with HITL ask_user_response:

  1. The docs describe the wrong shape. docs/architecture/human-in-the-loop.md says responses carry "an answers array whose entries contain string arrays", which reads as "answers": [["Blue"]]. The type in go/api/a2a/hitl.go is:

    type AskUserAnswer struct {
    	Answer []string `json:"answer"`
    }
    

    So the wire shape is "answers": [{"answer": ["Blue"]}].

  2. A response in the documented shape strands the task instead of being rejected. The gateway accepts the message and the session moves the task to working. Decoding then fails in the runtime, but the task stays working and never settles; only CancelTask gets it out. The doc's own promise ("The server rejects responses that use the wrong task/context, omit required decisions, …") suggests malformed responses should be refused up front.

Steps to reproduce
  1. A Claude harness agent calls AskUserQuestion. The task is TASK_STATE_INPUT_REQUIRED with an ask_user_request in the status metadata.
  2. SendMessage to the same task and context, with extensions: ["https://kagent.dev/extensions/hitl/v1"] and metadata:
    {"https://kagent.dev/extensions/hitl/v1": {"type": "ask_user_response", "id": "<request id>", "answers": [["Blue"]]}}
    
Expected

An InvalidParams-style error, with the task still input-required so a corrected answer can follow.

Actual

The first call returns:

-32603 decode ask-user response: json: cannot unmarshal array into AskUserResponse.answers.0 of type a2a.AskUserAnswer

GetTask then reports TASK_STATE_WORKING indefinitely. A corrected answer ([{"answer": ["Blue"]}]) is refused with resource conflict because the task is no longer pending. The task has to be cancelled.

With the correct shape everything works: the agent resumes immediately.

Suggested fix
  • Validate the HITL payload before the input is persisted or dispatched, and reject it with the task left input-required.
  • Show the exact JSON for ask_user_response and tool_approval_response in the doc.
Environment

kagent v1.0.0-alpha17, Claude harness (Claude Code 2.1.285), A2A v1 JSON-RPC.

Ngôn ngữ chính
Go
Star
4.5k
Fork
937
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
150

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của kagent-dev/kagent

Tất cả issue của kagent-dev/kagent

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.