Skip to content

Python: [A2A] First-class support for input-required user input #5937

@SergeyMenshykh

Description

@SergeyMenshykh

Context

.NET PR #5743 actually does three things in code:

  1. Tracks the A2A TaskState on the session (A2AAgentSession.TaskState, threaded through UpdateSession).
  2. In A2AAgent.CreateA2AMessage, branches on typedSession.TaskState == TaskState.InputRequired:
    • InputRequired: sets a2aMessage.TaskId = typedSession.TaskId so the reply is bound to the existing task as input.
    • Otherwise: sets a2aMessage.ReferenceTaskIds = [typedSession.TaskId] for task refinements.
  3. Surfaces the input-request message parts on AgentResponseUpdate for TaskStatusUpdateEvent via a new AgentTaskStatusExtensions.GetUserInputRequests() helper that returns the status message''s AIContent parts only when State == InputRequired.

Current Python state

python/packages/a2a/agent_framework_a2a/_agent.py:

  • The session has no equivalent task_state tracking; only task_id / context_id are kept.
  • _prepare_message_for_a2a (~L621) never sets task_id, even when the prior task was TASK_STATE_INPUT_REQUIRED, so replies are not bound to the in-flight task on the server.
  • _updates_from_task_update_event does emit parts from status.message, but it does not gate on INPUT_REQUIRED or signal to the caller that the surfaced content is an input request rather than ordinary intermediate output.

Proposed change

  • Track the current TaskState on the A2A session (mirror A2AAgentSession.TaskState).
  • In _prepare_message_for_a2a, branch on the previous task state:
    • if INPUT_REQUIRED → set a2a_message.task_id = previous_task_id;
    • else → set a2a_message.reference_task_ids = [previous_task_id] (see the companion "Link follow-up messages via reference_task_ids" issue).
  • Add a helper analogous to GetUserInputRequests that returns the status-message parts only when state == INPUT_REQUIRED, and use it when building AgentResponseUpdates for input-required status events so callers can distinguish input requests from regular intermediate content.

Metadata

Metadata

Assignees

Labels

a2aIssue relates to A2Apython

Type

No type
No fields configured for issues without a type.

Projects

Status

Planned

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions