Skip to content
AgenticAIWiki
  1. Learn
  2. Part 7
  3. 38. Agent interoperability and A2A
  4. 38.4

Lesson 38.4 · 4 of 7 · 5 min read · Reviewed 24 Nov 2026

Tasks, messages and artifacts in A2A

By the end, you can

  • Describe A2A tasks, messages, parts and artifacts.
  • Follow a task through its states.

A2AAgent-to-agent protocol (A2A): An open protocol for agents built by different vendors to discover each other and exchange tasks. runs over HTTP. The examples here use its JSON-RPC 2.0 binding, the same style as MCPModel Context Protocol (MCP): An open protocol that standardises how AI applications connect to tools, data and prompts through servers.. Version 1.0 of the spec defines three equivalent protocol bindings, and an agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done. card lists which ones an agent supports:

Binding Looks like Good for
JSON-RPC 2.0 SendMessage, GetTask as JSON-RPC methods The most common choice; easy to debug
gRPC The same operations as typed RPCs High-volume service-to-service traffic
HTTP+JSON REST-style paths such as /message:send and /tasks/{id} Teams and gateways that prefer plain REST

Version 1.0 also renamed things you’ll meet in older code: methods such as message/send became SendMessage, and task states became enum values such as TASK_STATE_INPUT_REQUIRED. Requests carry an A2A-Version header. The concepts below are unchanged.

The building blocks

  • Task: one piece of work, with an id and a state.
  • Message: a turn from the client or the remote agent, made of parts.
  • Part: text, a file, or structured JSON data.
  • Artifact: an output the task produces, also made of parts.

A task’s life

submitted -> working -> completed
                 \-> input-required -> (client replies) -> working
                 \-> failed / canceled / rejected

input-required is what makes A2A different from a tool call: the remote agent can stop and ask, and the client answers in a follow-up message on the same task.

An exchange

  1. Client sends a message: “Book a double room in Alfama, 12-15 March, under 150 EUR.”
  2. Remote agent creates a task, state working.
  3. It needs more: state input-required, message “Which name should the booking be under?”
  4. Client replies on the same task.
  5. State completed, with an artifact: the booking confirmation as JSON.

Key points

  • A task is the unit of work, with an id and a state such as submitted, working, input-required, completed or failed.
  • Messages carry the conversation, made of parts: text, files or structured data.
  • Artifacts are the outputs a task produces, such as a booking confirmation or a report.
Hands-on labRuns in the Playground

Drive an A2A task through its states

Model an A2A task as a state machine with messages, an input-required pause and a final artifact.

You will have: A Task class that enforces legal state changes and a printed hotel-booking exchange ending in a JSON artifact.

Steps

  1. Read the allowed transitions: submitted to working; working to input-required, completed, failed or canceled; input-required back to working.
  2. Write Task.move(state) to refuse any transition not in the table.
  3. Record every message as a list of parts, such as a text part or a data part.
  4. Play the booking exchange: request, working, a question, the client's reply on the same task, then completed with an artifact.
  5. Try an illegal move, completed back to working, and print the error.

Done when

  • The task id stays the same from the first message to the artifact.
  • The history shows input-required followed by working again.
  • Moving a completed task back to working is refused.

Open in the Playground No API key needed.

Starter code (Python)
ALLOWED = {
    "submitted": {"working"},
    "working": {"input-required", "completed", "failed", "canceled"},
    "input-required": {"working", "canceled"},
}

class Task:
    def __init__(self, task_id):
        self.id, self.state, self.history, self.messages, self.artifacts = task_id, "submitted", ["submitted"], [], []
    def move(self, new):
        # TODO: refuse transitions not in ALLOWED; otherwise record and change state
        self.state = new
        self.history.append(new)
    def add_message(self, role, text=None, data=None):
        # TODO: store {"role": role, "parts": [...]} with a text part and/or a data part
        pass

t = Task("task-301")
t.add_message("client", text="Book a double room in Alfama, 12-15 March, under 150 EUR a night")
t.move("working")
# TODO: ask for the guest name (input-required), take the reply, then complete with an artifact
print("history:", t.history)
Show a solution
ALLOWED = {
    "submitted": {"working"},
    "working": {"input-required", "completed", "failed", "canceled"},
    "input-required": {"working", "canceled"},
}

class Task:
    def __init__(self, task_id):
        self.id, self.state, self.history, self.messages, self.artifacts = task_id, "submitted", ["submitted"], [], []
    def move(self, new):
        if new not in ALLOWED.get(self.state, set()):
            raise ValueError(f"invalid transition {self.state} -> {new}")
        self.state = new
        self.history.append(new)
    def add_message(self, role, text=None, data=None):
        parts = ([{"kind": "text", "text": text}] if text else []) + ([{"kind": "data", "data": data}] if data else [])
        self.messages.append({"role": role, "parts": parts})

t = Task("task-301")
t.add_message("client", text="Book a double room in Alfama, 12-15 March, under 150 EUR a night")
t.move("working")
t.move("input-required")
t.add_message("agent", text="Which name should the booking be under?")
t.add_message("client", text="Ada Lovelace")
t.move("working")
t.artifacts.append({"name": "booking", "parts": [{"kind": "data", "data": {"ref": "LX-4410", "guest": "Ada Lovelace", "nights": 3}}]})
t.move("completed")
print("task:", t.id, "history:", " -> ".join(t.history))
print("messages:", len(t.messages), "artifact:", t.artifacts[0]["parts"][0]["data"])
try:
    t.move("working")
except ValueError as e:
    print("refused:", e)
Quick checkA remote agent needs the traveller's passport country before it can continue. What task state fits?
How sure are you?
Pick an answer and how sure you are