Monitor non-blocking A2A tasks and handle input-required states
Monitor returnImmediately tasks per the A2A snapshot: tell Task from Message, track with GetTask, handle input-required and terminal states.
Prerequisites and input · Engineering checks · 1. Choose an update channel
At a glance
This note follows the A2A specification snapshot read on 2026-11-12. Sending a message is blocking by default and returns only when the task reaches a terminal or interrupted state. If the configuration sets returnImmediately to true, the operation returns right after the task is created, and the caller becomes responsible for polling, subscribing or receiving push updates. The host needs a monitoring flow: decide whether it received a Task or a Message, classify the state, resume observation after an interruption, and read the result once the task is terminal.
Runtime and applicability
- Article type
- Engineering practice
- Verified
- Applies to
- A2A Monitor non-blocking A2A tasks and handle input-required states
Execution locations and responsibilities
- A2A client and remote agent Use the workflow below to distinguish responsibilities of the caller, runtime, and external actions.
Arrows show the order of checks in the guide. Follow each step’s prerequisites, branches and stop conditions; unexecuted steps are not completed work.
When to use
- A send operation yields either a Task or a Message. A Message is for simple interactions that need no tracking; in that case
returnImmediatelyhas no effect and there is no task ID to monitor. A Task always hasidandstatus, whilecontextIdandstatus.timestampare optional, so the registry must tolerate their absence. A Message can also carrycontextId, which server messages must provide, andtaskIdappears only if a task was created. The specification also says task results belong in Artifacts, Messages should not be used to deliver task output, and not every message is guaranteed to reach the task history.
When not to use
returnImmediatelyhas no effect on direct Message responses or streaming operations, so do not use it to infer whether the server will create a task.- The specification sets no polling frequency and does not guarantee that every status message enters the task history, so the host cannot treat messages as reliable notification.
TASK_STATE_AUTH_REQUIREDis not itself authorization for any operation; the scope is defined by the implementation, the credential issuer or an extension.
Prerequisites and input
- You confirmed the interface from the Agent Card and know whether the chosen update method has a matching capability (polling needs no optional capability).
- The
messageIdin the request is unique and generated by the caller, which lets the server detect duplicate messages. - The host has chosen a polling interval and a total waiting limit; the specification gives no figures.
Engineering checks
Response shape: Task or Message — A send operation yields either a Task or a Message. A Message is for simple interactions that need no tracking; in that case returnImmediately has no effect and there is no task ID to monitor. A Task always has id and status, while contextId and status.timestamp are optional, so the registry must tolerate their absence. A Message can also carry contextId, which server messages must provide, and taskId appears only if a task was created. The specification also says task results belong in Artifacts, Messages should not be used to deliver task output, and not every message is guaranteed to reach the task history.
State classification — The terminal states are TASK_STATE_COMPLETED, TASK_STATE_FAILED, TASK_STATE_CANCELED and TASK_STATE_REJECTED. The interrupted states are TASK_STATE_INPUT_REQUIRED and TASK_STATE_AUTH_REQUIRED. TASK_STATE_SUBMITTED and TASK_STATE_WORKING mean processing continues, and TASK_STATE_UNSPECIFIED means unknown. A task returned in non-blocking mode has an in-progress state; the specification's examples include TASK_STATE_WORKING and TASK_STATE_INPUT_REQUIRED.
Update channel and reconciliation — There are three ways to get updates. Polling with GetTask works with every binding. Streaming with SubscribeToTask needs the streaming capability, and its first event is a Task reflecting the state at subscription time, which prevents information loss between GetTask and the subscription. Push notifications need the pushNotifications capability. After a disconnect and reconnect a stream may miss status update messages, so critical information cannot rest on messages alone, and the terminal result should be reconciled with GetTask. GetTask itself can return TaskNotFoundError, meaning the task does not exist or is not accessible.
1. Choose an update channel
Where: the client, before sending. Input: capabilities from the Agent Card and the host's network conditions. Action: default to polling with GetTask; plan SubscribeToTask only if streaming is true, and callbacks only if pushNotifications is true. Completion check: the host records the chosen channel and the capability it rests on. Stop: the needed capability is not declared; switch to polling or stop instead of sending first and reading the error later.
2. Send the non-blocking message
Where: the client's SendMessage call site. Input: a message with a unique messageId, and returnImmediately set to true in the configuration. Action: send and wait for the response. Completion check: the response contains exactly one of task or message. Stop: it contains neither or both, which breaks the contract and gets reported; on authentication or validation errors, stop without automatic resend.
3. Separate Task from Message
Where: the host's response dispatch. Input: the response from the previous step. Action: if it is a Message, handle it as the final direct reply and create no monitor; if it is a Task, register id and status.state, plus contextId and status.timestamp when present. Completion check: every send ends up as either a direct reply or a registered task, and absent optional fields are marked empty. Stop: the Message branch ends here, and GetTask is never called with a task ID that does not exist.
4. Track state changes
Where: the host's monitoring loop. Input: the registered task id and optionally historyLength. Action: call GetTask at the host's interval, or read subscription events, and put each status.state into in-progress, interrupted or terminal. When GetTask returns TaskNotFoundError, record inaccessible or purged and infer no terminal state. Completion check: every read has a state on record, with the timestamp when present. Stop: a terminal state moves to the last step; an interrupted state moves to the next step and monitoring is not over; if the host's waiting limit passes, or the task can no longer be read, record undecided and stop polling, and do not write it as failed since the remote state is unknown.
5. Handle input-required and auth-required, then resume monitoring
Where: the host's human or upstream interaction layer. Input: a Task in TASK_STATE_INPUT_REQUIRED and its status.message. Action: show the request to the user or upstream, then send a new message carrying the same taskId, and the contextId when the Task had one; that send is also blocking by default, so set returnImmediately again if non-blocking behavior is wanted. After handling that send's response, return to the previous step and keep monitoring the same task. For TASK_STATE_AUTH_REQUIRED, supply authorization out of band as the server describes and never treat the state itself as authorization; once credentials arrive out of band the server may continue without any follow-up message, so the host keeps a subscription, a registered notification or GetTask polling going until it observes progress. Completion check: the state is seen returning to in-progress or terminal. Stop: the user declines or cannot supply input, or the host's waiting limit passes, so the host records that and decides whether to cancel; a mismatched taskId and contextId is rejected by the server.
6. Read the result at a terminal state and end monitoring
Where: the host's result handling. Input: a terminal Task. Action: get the full state with GetTask, read output from artifacts, and record the reason separately for failed, rejected and cancelled. If GetTask returns TaskNotFoundError at this point, record inaccessible or purged and promise no result. Completion check: the result agrees with the state, and related streams are closed. Stop: after a terminal state send no more messages to the task (that returns UnsupportedOperationError) and do not subscribe again.
Task example
This is a synthetic manual walkthrough; the observations are hypothetical expectations, not verified results. Suppose the host sends a non-blocking message with returnImmediately true to a document-analysis agent. The expected response is a Task with TASK_STATE_WORKING, so the host registers the ID and starts polling with GetTask. If a later read shows TASK_STATE_INPUT_REQUIRED, the host shows the question in status.message and, after the user answers, sends a new message with the same taskId, handles the response and keeps polling the same task. When a read finally shows TASK_STATE_COMPLETED, the host takes the result from artifacts and stops polling. If a read shows TASK_STATE_AUTH_REQUIRED, the host handles authorization out of band and keeps polling until the state changes. If a different send returns a Message directly, the host shows that reply and registers no task. These steps are derived from the specification text and have not been observed on any real service.
Completion checks
- Response dispatch: every send is classified as Task or Message, no Message is monitored as a task, and an absent optional Task field is not treated as an error.
- State classification and resumption: in-progress, interrupted and terminal each have a handling branch, observation resumes after an interruption, and
TASK_STATE_UNSPECIFIEDis never treated as success. - Result reconciliation: after a terminal state the host reads
artifactsthroughGetTask, and a failed read is recorded as inaccessible or undecided rather than replaced by messages received along the way.
Verification scope
This note is based on the A2A specification snapshot read on 2026-11-12. Documentation was read only: no SDK was installed, no service was logged into, no API call was executed, and no real output exists. Observations in the walkthrough are hypothetical expectations that still need verification in a real environment.
Sources
All links are official pages; verification dates are listed per source, and links point to the version checked.