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

オープン
#3,313 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@suryakant-source がすでに取り組んでいます。

2026年10月23日 から。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Go
スター
4.5k
フォーク
937
平均マージ
1日 10時間
マージ済み PR(30日)
150

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

kagent-dev/kagent のほかの issue

kagent-dev/kagent の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。