Skip to content

The agent that grows with you

feat(a2a): file/data Parts + push config full CRUD

Kevin (OpenClaw Bot)fe1aca577083
diff --git a/plugins/platforms/a2a/DESIGN.md b/plugins/platforms/a2a/DESIGN.md
index 71a1aa8ff35..66656d3735f 100644
--- a/plugins/platforms/a2a/DESIGN.md
+++ b/plugins/platforms/a2a/DESIGN.md
@@ -70,15 +70,24 @@ Peers resolved from `config.yaml` → `a2a_agents`, or a direct URL.
bearer token), with SSRF-guarded callback URLs.
## v1.0 wire format notes
-- Task states / roles are SCREAMING_SNAKE_CASE (`TASK_STATE_*`, `ROLE_*`).
-- Parts are member-presence discriminated (`{"text", "mediaType"}` — no
- `kind`); `extract_text` still accepts 0.3 (`kind`) and pre-0.3 (`type`)
- parts from older peers.
-- SSE events are `StreamResponse` objects (`statusUpdate` / `artifactUpdate`
- members); stream closure signals the terminal state — no `final` field.
-- `contextId` lives inside the Message (legacy top-level accepted inbound).
+- Task states / roles are SCREAMING_SNAKE_CASE (TASK_STATE_*, ROLE_*).
+- Parts are member-presence discriminated — no kind field. All three
+ Part types are supported: text (text + mediaType), file
+ (url|raw + filename + mediaType), and data (data + mediaType).
+ extract_text renders file/data Parts into the text stream (URL +
+ filename for files, JSON for data) so the agent sees them; it also
+ accepts v0.3 (kind) and pre-0.3 (type) shapes from older peers.
+ Outbound replies are still text-only — the agent produces text, and
+ file/data Parts are for inbound richness.
+- Push notification config: full CRUD — create (inline in message/send
+ via configuration.taskPushNotificationConfig, or via the create
+ method), get, list, delete. Each config has a configId and createdAt.
+ One config per task (v1.0 allows multiple; we keep one).
+- SSE events are StreamResponse objects (statusUpdate / artifactUpdate
+ members); stream closure signals the terminal state — no final field.
+- contextId lives inside the Message (legacy top-level accepted inbound).
- Timestamps are ISO 8601 with millisecond precision; Tasks carry
- `createdAt` / `lastModified`.
+ createdAt / lastModified.
- Error codes: A2A-reserved codes are used only with their spec semantics
(`-32001` TaskNotFound, `-32002` TaskNotCancelable); custom errors sit at
`-32050..-32052` (unauthorized / rate-limited / untrusted).
@@ -136,10 +145,7 @@ them (#11025 requirement). The `a2a_history` tool recalls them by context id.
## Deliberately out of scope (future, not this pass)
- **a2a-sdk / gRPC + HTTP+JSON bindings.** Only the JSONRPC binding is
served; the card advertises exactly that.
-- **File / data Parts.** Inbound non-text parts are ignored (text extracted
- from mixed messages); outbound is text-only.
-- **`tenant` field, extended Agent Card, `stateTransitionHistory`,**
- push-config get/list/delete methods.
+- **`tenant` field, extended Agent Card, `stateTransitionHistory`.**
- **True task abort:** `tasks/cancel` marks the task canceled and drops the
reply, but cannot abort the live session's in-flight turn.
- **DID / Ed25519 identity, OAuth2 scopes, x402 micropayments** (#14559
diff --git a/plugins/platforms/a2a/adapter.py b/plugins/platforms/a2a/adapter.py
index 8a5d481e73c..955557adfd2 100644
--- a/plugins/platforms/a2a/adapter.py
+++ b/plugins/platforms/a2a/adapter.py
@@ -7,7 +7,9 @@ Design (the #11025 insight, done as a plugin with zero core edits):
loop" bug class).
- Serves the A2A v1.0 Agent Card at GET /.well-known/agent.json.
- JSON-RPC at POST /: message/send, message/stream (SSE), tasks/get,
- tasks/list, tasks/cancel, tasks/subscribe, tasks/pushNotificationConfig/create.
+ tasks/list, tasks/cancel, tasks/subscribe, tasks/pushNotificationConfig/create,
+ tasks/pushNotificationConfig/get, tasks/pushNotificationConfig/list,
+ tasks/pushNotificationConfig/delete.
- Push notifications: config accepted inline in message/send
(configuration.taskPushNotificationConfig) or via the create method;
payloads are v1.0 StreamResponse objects, HMAC-signed.
@@ -204,6 +206,15 @@ class A2ARequestHandler(BaseHTTPRequestHandler):
):
self._json(200, adapter._rpc_push_config_create(req_id, params))
return
+ if method == "tasks/pushNotificationConfig/get":
+ self._json(200, adapter._rpc_push_config_get(req_id, params))
+ return
+ if method == "tasks/pushNotificationConfig/list":
+ self._json(200, adapter._rpc_push_config_list(req_id, params))
+ return
+ if method == "tasks/pushNotificationConfig/delete":
+ self._json(200, adapter._rpc_push_config_delete(req_id, params))
+ return
self._json(200, protocol.jsonrpc_error(
req_id, protocol.ERR_METHOD_NOT_FOUND, f"method not found: {method}"))
@@ -724,6 +735,43 @@ class A2AAdapter(BasePlatformAdapter):
req_id, protocol.ERR_TASK_NOT_FOUND, f"task not found: {task_id}")
return protocol.jsonrpc_result(req_id, stored)
+ def _rpc_push_config_get(self, req_id: Any, params: dict) -> dict:
+ """GetTaskPushNotificationConfig — retrieve a push config by task id."""
+ task_id = str(params.get("taskId") or "")
+ config_id = str(params.get("id") or params.get("configId") or "")
+ if not task_id:
+ return protocol.jsonrpc_error(
+ req_id, protocol.ERR_INVALID_PARAMS, "taskId required")
+ cfg = self.tasks.get_push_config(task_id, config_id)
+ if cfg is None:
+ return protocol.jsonrpc_error(
+ req_id, protocol.ERR_TASK_NOT_FOUND,
+ f"push config not found for task: {task_id}")
+ return protocol.jsonrpc_result(req_id, cfg)
+
+ def _rpc_push_config_list(self, req_id: Any, params: dict) -> dict:
+ """ListTaskPushNotificationConfigs — list push configs for a task."""
+ task_id = str(params.get("taskId") or "")
+ if not task_id:
+ return protocol.jsonrpc_error(
+ req_id, protocol.ERR_INVALID_PARAMS, "taskId required")
+ configs = self.tasks.list_push_configs(task_id)
+ return protocol.jsonrpc_result(req_id, {"configs": configs})
+
+ def _rpc_push_config_delete(self, req_id: Any, params: dict) -> dict:
+ """DeleteTaskPushNotificationConfig — remove a push config."""
+ task_id = str(params.get("taskId") or "")
+ config_id = str(params.get("id") or params.get("configId") or "")
+ if not task_id:
+ return protocol.jsonrpc_error(
+ req_id, protocol.ERR_INVALID_PARAMS, "taskId required")
+ deleted = self.tasks.delete_push_config(task_id, config_id)
+ if not deleted:
+ return protocol.jsonrpc_error(
+ req_id, protocol.ERR_TASK_NOT_FOUND,
+ f"push config not found for task: {task_id}")
+ return protocol.jsonrpc_result(req_id, {"deleted": True})
+
def _send_push_notification(self, task_id: str, context_id: str, reply: str, state: str) -> None:
"""POST a v1.0 StreamResponse payload to the task's registered callback.
diff --git a/plugins/platforms/a2a/protocol.py b/plugins/platforms/a2a/protocol.py
index 2b9ddac9f65..ca70b811fdd 100644
--- a/plugins/platforms/a2a/protocol.py
+++ b/plugins/platforms/a2a/protocol.py
@@ -196,6 +196,28 @@ def text_part(text: str) -> dict:
return {"text": text, "mediaType": "text/plain"}
+def file_part(url: str = "", raw: str = "", filename: str = "",
+ media_type: str = "application/octet-stream") -> dict:
+ """Build a v1.0 file Part.
+
+ Either ``url`` (file reference) or ``raw`` (base64-encoded bytes) must be
+ provided. Discrimination is by member presence — no ``kind`` field.
+ """
+ part: dict[str, Any] = {"mediaType": media_type}
+ if filename:
+ part["filename"] = filename
+ if url:
+ part["url"] = url
+ elif raw:
+ part["raw"] = raw
+ return part
+
+
+def data_part(data: Any, media_type: str = "application/json") -> dict:
+ """Build a v1.0 data Part (structured data, no ``kind`` field)."""
+ return {"data": data, "mediaType": media_type}
+
+
def text_message(role: str, text: str, context_id: str = "") -> dict:
"""Build an A2A v1.0 Message with a single text Part."""
msg: dict[str, Any] = {
@@ -208,12 +230,29 @@ def text_message(role: str, text: str, context_id: str = "") -> dict:
return msg
+def message_with_parts(role: str, parts: list[dict], context_id: str = "") -> dict:
+ """Build an A2A v1.0 Message with arbitrary Parts (text, file, data)."""
+ msg: dict[str, Any] = {
+ "role": role,
+ "parts": parts,
+ "messageId": uuid.uuid4().hex,
+ }
+ if context_id:
+ msg["contextId"] = context_id
+ return msg
+
+
def extract_text(message_or_params: dict) -> str:
"""Pull concatenated text from an A2A Message / Task-result / params payload.
v1.0 Parts carry a ``text`` member directly; v0.3 used ``kind: "text"``
and some pre-0.3 peers used ``type``. All three shapes put the payload in
``part["text"]``, so presence of a string ``text`` member is the test.
+
+ File and data Parts are rendered into the text stream so the agent sees
+ them: file Parts with a URL include the URL and filename; data Parts
+ include their JSON-serialised content. Raw (base64) file Parts are noted
+ but not decoded (the agent can't act on binary inline).
"""
msg = message_or_params.get("message", message_or_params)
parts = msg.get("parts", []) if isinstance(msg, dict) else []
@@ -221,9 +260,58 @@ def extract_text(message_or_params: dict) -> str:
for part in parts:
if not isinstance(part, dict):
continue
+ # v1.0 text part (member-presence discrimination)
txt = part.get("text")
if isinstance(txt, str):
chunks.append(txt)
+ continue
+ # v0.3 compatibility: kind == "text"
+ if part.get("kind") == "text" and isinstance(part.get("text"), str):
+ chunks.append(part["text"])
+ continue
+ # v1.0 file part with URL
+ url = part.get("url")
+ if isinstance(url, str) and url:
+ fname = part.get("filename") or part.get("name") or ""
+ mtype = part.get("mediaType") or part.get("mimeType") or ""
+ label = f"[file: {fname}]" if fname else "[file]"
+ chunks.append(f"{label} {url}" + (f" ({mtype})" if mtype else ""))
+ continue
+ # v0.3 file part with nested file.fileWithUri
+ v03_file = part.get("file")
+ if isinstance(v03_file, dict) and isinstance(v03_file.get("fileWithUri"), str):
+ uri = v03_file["fileWithUri"]
+ fname = v03_file.get("name") or ""
+ mtype = v03_file.get("mimeType") or ""
+ label = f"[file: {fname}]" if fname else "[file]"
+ chunks.append(f"{label} {uri}" + (f" ({mtype})" if mtype else ""))
+ continue
+ # v1.0 file part with raw bytes (base64) — note but don't decode
+ if isinstance(part.get("raw"), str):
+ fname = part.get("filename") or ""
+ mtype = part.get("mediaType") or ""
+ label = f"[file: {fname}]" if fname else "[file]"
+ size_note = f"{len(part['raw'])} bytes base64-encoded"
+ chunks.append(f"{label} {size_note}" + (f" ({mtype})" if mtype else ""))
+ continue
+ # v1.0 data part — include JSON content
+ data = part.get("data")
+ if data is not None:
+ try:
+ rendered = json.dumps(data, ensure_ascii=False, default=str)
+ except (TypeError, ValueError):
+ rendered = str(data)
+ mtype = part.get("mediaType") or "application/json"
+ chunks.append(f"[data ({mtype})]\n{rendered}")
+ continue
+ # v0.3 data part: kind == "data"
+ if part.get("kind") == "data" and part.get("data") is not None:
+ try:
+ rendered = json.dumps(part["data"], ensure_ascii=False, default=str)
+ except (TypeError, ValueError):
+ rendered = str(part["data"])
+ chunks.append(f"[data]\n{rendered}")
+ continue
return "\n".join(chunks).strip()
@@ -472,12 +560,53 @@ class TaskStore:
return None
rec["push_url"] = url
rec["push_config_id"] = "cfg-" + uuid.uuid4().hex[:12]
- return {
- "configId": rec["push_config_id"],
- "taskId": task_id,
- "createdAt": now_iso(),
- "pushNotificationConfig": {"url": url},
- }
+ return self._push_config_view(rec)
+
+ @staticmethod
+ def _push_config_view(rec: dict) -> dict:
+ """Build the JSON-RPC result for a push notification config."""
+ return {
+ "configId": rec.get("push_config_id") or "",
+ "taskId": rec["task_id"],
+ "createdAt": rec.get("created_iso", ""),
+ "pushNotificationConfig": {"url": rec.get("push_url") or ""},
+ }
+
+ def get_push_config(self, task_id: str, config_id: str = "") -> Optional[dict]:
+ """Retrieve a push notification config by task (and optional config id).
+
+ Returns the matching config or None if the task doesn't exist.
+ If ``config_id`` is provided and doesn't match, returns None.
+ """
+ with self._lock:
+ rec = self._tasks.get(task_id)
+ if not rec or not rec.get("push_url"):
+ return None
+ if config_id and rec.get("push_config_id") != config_id:
+ return None
+ return self._push_config_view(rec)
+
+ def list_push_configs(self, task_id: str) -> list[dict]:
+ """List all push notification configs for a task (currently max 1
+ per task — v1.0 allows multiple but we keep one)."""
+ with self._lock:
+ rec = self._tasks.get(task_id)
+ if not rec or not rec.get("push_url"):
+ return []
+ return [self._push_config_view(rec)]
+
+ def delete_push_config(self, task_id: str, config_id: str = "") -> bool:
+ """Remove a push notification config. Returns True if deleted, False
+ if the task or config doesn't exist."""
+ with self._lock:
+ rec = self._tasks.get(task_id)
+ if not rec or not rec.get("push_url"):
+ return False
+ if config_id and rec.get("push_config_id") != config_id:
+ return False
+ rec["push_url"] = ""
+ rec["push_config_id"] = ""
+ return True
def pop_push_url(self, task_id: str) -> str:
with self._lock:
diff --git a/tests/plugins/test_a2a_plugin.py b/tests/plugins/test_a2a_plugin.py
index 0fc42dc53c2..38612b2d17d 100644
--- a/tests/plugins/test_a2a_plugin.py
+++ b/tests/plugins/test_a2a_plugin.py
@@ -294,13 +294,76 @@ class TestV1Parts:
msg = {"role": "user", "parts": [{"type": "text", "text": "pre-0.3"}]}
assert protocol.extract_text(msg) == "pre-0.3"
- def test_extract_text_skips_non_text_parts(self):
+ def test_extract_text_renders_file_and_data_parts(self):
+ """Non-text Parts are rendered into the text stream so the agent sees them."""
msg = {"parts": [
{"url": "https://x/doc.pdf", "mediaType": "application/pdf", "filename": "doc.pdf"},
{"data": {"k": "v"}, "mediaType": "application/json"},
{"text": "the words", "mediaType": "text/plain"},
]}
- assert protocol.extract_text(msg) == "the words"
+ result = protocol.extract_text(msg)
+ # File part: URL + filename included
+ assert "https://x/doc.pdf" in result
+ assert "doc.pdf" in result
+ # Data part: JSON content included
+ assert '"k": "v"' in result
+ # Text part: included
+ assert "the words" in result
+
+ def test_extract_text_handles_v03_file_part(self):
+ """v0.3 nested file.fileWithUri shape is accepted."""
+ msg = {"parts": [
+ {"kind": "file", "file": {"fileWithUri": "https://x/img.png",
+ "name": "img.png", "mimeType": "image/png"}},
+ ]}
+ result = protocol.extract_text(msg)
+ assert "https://x/img.png" in result
+ assert "img.png" in result
+
+ def test_extract_text_handles_raw_file_part(self):
+ """v1.0 raw (base64) file part is noted but not decoded."""
+ msg = {"parts": [
+ {"raw": "aGVsbG8=", "filename": "hello.txt", "mediaType": "text/plain"},
+ ]}
+ result = protocol.extract_text(msg)
+ assert "hello.txt" in result
+ assert "base64" in result
+
+ def test_file_part_builder(self):
+ """file_part() builds a v1.0 file Part with URL or raw."""
+ fp = protocol.file_part(url="https://x/f.pdf", filename="f.pdf",
+ media_type="application/pdf")
+ assert fp["url"] == "https://x/f.pdf"
+ assert fp["filename"] == "f.pdf"
+ assert fp["mediaType"] == "application/pdf"
+ assert "kind" not in fp
+
+ # Raw variant
+ rp = protocol.file_part(raw="aGVsbG8=", filename="hello.txt",
+ media_type="text/plain")
+ assert rp["raw"] == "aGVsbG8="
+ assert rp["filename"] == "hello.txt"
+ assert "url" not in rp
+
+ def test_data_part_builder(self):
+ """data_part() builds a v1.0 data Part."""
+ dp = protocol.data_part({"key": "value"})
+ assert dp["data"] == {"key": "value"}
+ assert dp["mediaType"] == "application/json"
+ assert "kind" not in dp
+
+ def test_message_with_parts(self):
+ """message_with_parts() builds a Message with mixed Part types."""
+ msg = protocol.message_with_parts(
+ protocol.ROLE_USER,
+ [protocol.text_part("hello"), protocol.data_part({"x": 1})],
+ context_id="ctx-1",
+ )
+ assert msg["role"] == "ROLE_USER"
+ assert len(msg["parts"]) == 2
+ assert msg["parts"][0]["text"] == "hello"
+ assert msg["parts"][1]["data"] == {"x": 1}
+ assert msg["contextId"] == "ctx-1"
def test_context_id_extracted_from_message(self):
params = {"message": protocol.text_message(protocol.ROLE_USER, "x", context_id="ctx-in-msg")}
@@ -715,6 +778,118 @@ class TestTaskRpcHandlers:
resp = adapter._rpc_push_config_create(1, {"taskId": "t"})
assert resp["error"]["code"] == protocol.ERR_INVALID_PARAMS
+ def test_push_config_get_returns_stored_config(self):
+ """GetTaskPushNotificationConfig retrieves a config after create."""
+ adapter = _bare_adapter()
+ adapter.tasks.create("task-g", "ctx-g", "peer")
+ adapter._rpc_push_config_create(1, {
+ "taskId": "task-g",
+ "pushNotificationConfig": {"url": "https://example.com/hook"},
+ })
+ resp = adapter._rpc_push_config_get(1, {"taskId": "task-g"})
+ cfg = resp["result"]
+ assert cfg["pushNotificationConfig"]["url"] == "https://example.com/hook"
+ assert cfg["configId"].startswith("cfg-")
+
+ def test_push_config_get_by_config_id(self):
+ """Get with a specific configId returns the matching config."""
+ adapter = _bare_adapter()
+ adapter.tasks.create("task-g2", "ctx-g2", "peer")
+ create_resp = adapter._rpc_push_config_create(1, {
+ "taskId": "task-g2",
+ "pushNotificationConfig": {"url": "https://example.com/hook"},
+ })
+ config_id = create_resp["result"]["configId"]
+ resp = adapter._rpc_push_config_get(1, {"taskId": "task-g2", "id": config_id})
+ assert resp["result"]["configId"] == config_id
+
+ def test_push_config_get_wrong_config_id_returns_error(self):
+ """Get with wrong configId returns not-found error."""
+ adapter = _bare_adapter()
+ adapter.tasks.create("task-g3", "ctx-g3", "peer")
+ adapter._rpc_push_config_create(1, {
+ "taskId": "task-g3",
+ "pushNotificationConfig": {"url": "https://example.com/hook"},
+ })
+ resp = adapter._rpc_push_config_get(1, {"taskId": "task-g3", "id": "cfg-wrong"})
+ assert resp["error"]["code"] == protocol.ERR_TASK_NOT_FOUND
+
+ def test_push_config_get_unknown_task(self):
+ """Get for non-existent task returns not-found."""
+ adapter = _bare_adapter()
+ resp = adapter._rpc_push_config_get(1, {"taskId": "ghost"})
+ assert resp["error"]["code"] == protocol.ERR_TASK_NOT_FOUND
+
+ def test_push_config_get_requires_task_id(self):
+ """Get without taskId returns invalid-params."""
+ adapter = _bare_adapter()
+ resp = adapter._rpc_push_config_get(1, {})
+ assert resp["error"]["code"] == protocol.ERR_INVALID_PARAMS
+
+ def test_push_config_list_returns_configs(self):
+ """ListTaskPushNotificationConfigs returns all configs for a task."""
+ adapter = _bare_adapter()
+ adapter.tasks.create("task-l", "ctx-l", "peer")
+ adapter._rpc_push_config_create(1, {
+ "taskId": "task-l",
+ "pushNotificationConfig": {"url": "https://example.com/hook"},
+ })
+ resp = adapter._rpc_push_config_list(1, {"taskId": "task-l"})
+ configs = resp["result"]["configs"]
+ assert len(configs) == 1
+ assert configs[0]["pushNotificationConfig"]["url"] == "https://example.com/hook"
+
+ def test_push_config_list_empty_for_task_without_config(self):
+ """List returns empty array for a task with no push config."""
+ adapter = _bare_adapter()
+ adapter.tasks.create("task-l2", "ctx-l2", "peer")
+ resp = adapter._rpc_push_config_list(1, {"taskId": "task-l2"})
+ assert resp["result"]["configs"] == []
+
+ def test_push_config_delete_removes_config(self):
+ """DeleteTaskPushNotificationConfig removes the push config."""
+ adapter = _bare_adapter()
+ adapter.tasks.create("task-d", "ctx-d", "peer")
+ adapter._rpc_push_config_create(1, {
+ "taskId": "task-d",
+ "pushNotificationConfig": {"url": "https://example.com/hook"},
+ })
+ # Delete
+ resp = adapter._rpc_push_config_delete(1, {"taskId": "task-d"})
+ assert resp["result"]["deleted"] is True
+ # Get now fails
+ resp2 = adapter._rpc_push_config_get(1, {"taskId": "task-d"})
+ assert resp2["error"]["code"] == protocol.ERR_TASK_NOT_FOUND
+
+ def test_push_config_delete_unknown_task(self):
+ """Delete for non-existent task returns not-found."""
+ adapter = _bare_adapter()
+ resp = adapter._rpc_push_config_delete(1, {"taskId": "ghost"})
+ assert resp["error"]["code"] == protocol.ERR_TASK_NOT_FOUND
+
+ def test_push_config_delete_by_config_id(self):
+ """Delete with a specific configId only deletes the matching config."""
+ adapter = _bare_adapter()
+ adapter.tasks.create("task-d2", "ctx-d2", "peer")
+ create_resp = adapter._rpc_push_config_create(1, {
+ "taskId": "task-d2",
+ "pushNotificationConfig": {"url": "https://example.com/hook"},
+ })
+ config_id = create_resp["result"]["configId"]
+ resp = adapter._rpc_push_config_delete(1, {"taskId": "task-d2", "id": config_id})
+ assert resp["result"]["deleted"] is True
+
+ def test_push_config_delete_wrong_config_id(self):
+ """Delete with wrong configId returns not-found."""
+ adapter = _bare_adapter()
+ adapter.tasks.create("task-d3", "ctx-d3", "peer")
+ adapter._rpc_push_config_create(1, {
+ "taskId": "task-d3",
+ "pushNotificationConfig": {"url": "https://example.com/hook"},
+ })
+ resp = adapter._rpc_push_config_delete(1, {"taskId": "task-d3", "id": "cfg-wrong"})
+ assert resp["error"]["code"] == protocol.ERR_TASK_NOT_FOUND
+
# --------------------------------------------------------------------------
# End-to-end inbound round-trip (real http.server + mocked agent)
@@ -814,6 +989,102 @@ class TestInboundRoundTrip:
asyncio.run(run())
+ def test_mixed_parts_delivered_to_agent(self, monkeypatch):
+ """A message with text + file + data Parts delivers all content to the
+ agent — file URLs and data JSON are rendered into the text stream."""
+ monkeypatch.delenv("A2A_BEARER_TOKEN", raising=False)
+ monkeypatch.delenv("A2A_PEER_TOKENS", raising=False)
+
+ received = {}
+
+ def reply_fn(event):
+ received["text"] = event.text
+ return "got it"
+
+ adapter, base = _make_live_adapter(monkeypatch, reply_fn=reply_fn)
+
+ async def run():
+ assert await adapter.connect() is True
+ msg = protocol.message_with_parts(
+ protocol.ROLE_USER,
+ [
+ protocol.text_part("Please process these:"),
+ protocol.file_part(url="https://example.com/report.pdf",
+ filename="report.pdf", media_type="application/pdf"),
+ protocol.data_part({"title": "Q3", "pages": 42}, "application/json"),
+ ],
+ context_id="ctx-mixed",
+ )
+ resp = await asyncio.to_thread(_post_json, base + "/", {
+ "jsonrpc": "2.0", "id": "1", "method": "message/send",
+ "params": {"message": msg},
+ })
+ assert resp["result"]["status"]["state"] == "TASK_STATE_COMPLETED"
+ # The agent received all three parts rendered into text
+ assert "Please process these:" in received["text"]
+ assert "https://example.com/report.pdf" in received["text"]
+ assert "report.pdf" in received["text"]
+ assert "Q3" in received["text"]
+ assert "42" in received["text"]
+ await adapter.disconnect()
+
+ asyncio.run(run())
+
+ def test_push_config_crud_over_http(self, monkeypatch):
+ """Full push notification config CRUD over real HTTP."""
+ monkeypatch.delenv("A2A_BEARER_TOKEN", raising=False)
+ monkeypatch.delenv("A2A_PEER_TOKENS", raising=False)
+ adapter, base = _make_live_adapter(monkeypatch)
+
+ async def run():
+ assert await adapter.connect() is True
+ # Create a task first by sending a message (will get a task id back)
+ resp = await asyncio.to_thread(_post_json, base + "/",
+ _send_body("hello", ctx="ctx-crud"))
+ task_id = resp["result"]["id"]
+
+ # CREATE
+ r = await asyncio.to_thread(_post_json, base + "/", {
+ "jsonrpc": "2.0", "id": "2", "method": "tasks/pushNotificationConfig/create",
+ "params": {"taskId": task_id,
+ "pushNotificationConfig": {"url": "https://example.com/hook"}},
+ })
+ assert r["result"]["configId"].startswith("cfg-")
+ assert r["result"]["pushNotificationConfig"]["url"] == "https://example.com/hook"
+ config_id = r["result"]["configId"]
+
+ # GET
+ r = await asyncio.to_thread(_post_json, base + "/", {
+ "jsonrpc": "2.0", "id": "3", "method": "tasks/pushNotificationConfig/get",
+ "params": {"taskId": task_id},
+ })
+ assert r["result"]["configId"] == config_id
+
+ # LIST
+ r = await asyncio.to_thread(_post_json, base + "/", {
+ "jsonrpc": "2.0", "id": "4", "method": "tasks/pushNotificationConfig/list",
+ "params": {"taskId": task_id},
+ })
+ assert len(r["result"]["configs"]) == 1
+
+ # DELETE
+ r = await asyncio.to_thread(_post_json, base + "/", {
+ "jsonrpc": "2.0", "id": "5", "method": "tasks/pushNotificationConfig/delete",
+ "params": {"taskId": task_id},
+ })
+ assert r["result"]["deleted"] is True
+
+ # GET after delete → not found
+ r = await asyncio.to_thread(_post_json, base + "/", {
+ "jsonrpc": "2.0", "id": "6", "method": "tasks/pushNotificationConfig/get",
+ "params": {"taskId": task_id},
+ })
+ assert r["error"]["code"] == protocol.ERR_TASK_NOT_FOUND
+
+ await adapter.disconnect()
+
+ asyncio.run(run())
+
def test_unknown_method_error(self, monkeypatch):
monkeypatch.delenv("A2A_BEARER_TOKEN", raising=False)
monkeypatch.delenv("A2A_PEER_TOKENS", raising=False)