Skip to content

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

a2aUsage: [Issues, PRs], Target: A2ApythonUsage: [Issues, PRs], Target: Python

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions