Skip to content

Commit a947e5f

Browse files
committed
Add documentation about A2A metadata usage
It can be used for model, provider and vector store selection
1 parent 2152ec3 commit a947e5f

2 files changed

Lines changed: 68 additions & 2 deletions

File tree

docs/a2a_protocol.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,67 @@ curl -X POST http://localhost:8090/a2a \
523523

524524
> **Important:** The `contextId` must be placed inside the `message` object, not at the `params` level. This is required by the A2A protocol specification for the server to correctly identify and continue the conversation.
525525

526+
### Message Metadata
527+
528+
A2A messages support an optional `metadata` field that can be used to pass additional parameters to control request routing and behavior. The following metadata fields are supported:
529+
530+
| Field | Type | Description |
531+
|-------|------|-------------|
532+
| `model` | `string` | Specify the LLM model to use for this request (e.g., `"gpt-4"`, `"llama3.1"`) |
533+
| `provider` | `string` | Specify the LLM provider to use (e.g., `"openai"`, `"watsonx"`) |
534+
| `vector_store_ids` | `list[string]` | Specify which vector stores to query for RAG. If not provided, all available vector stores are queried |
535+
536+
#### Example: Using Metadata
537+
538+
```bash
539+
curl -X POST http://localhost:8090/a2a \
540+
-H "Authorization: Bearer $TOKEN" \
541+
-H "Content-Type: application/json" \
542+
-d '{
543+
"jsonrpc": "2.0",
544+
"id": "1",
545+
"method": "message/send",
546+
"params": {
547+
"message": {
548+
"messageId": "msg-001",
549+
"role": "user",
550+
"parts": [
551+
{"type": "text", "text": "What is a deployment in OpenShift?"}
552+
],
553+
"metadata": {
554+
"model": "llama3.1",
555+
"provider": "together",
556+
"vector_store_ids": ["ocp_docs", "knowledge_base"]
557+
}
558+
}
559+
}
560+
}'
561+
```
562+
563+
#### Python Example with Metadata
564+
565+
```python
566+
payload = {
567+
"jsonrpc": "2.0",
568+
"id": "1",
569+
"method": "message/send",
570+
"params": {
571+
"message": {
572+
"messageId": "msg-001",
573+
"role": "user",
574+
"parts": [{"type": "text", "text": "Explain pods"}],
575+
"metadata": {
576+
"model": "gpt-4",
577+
"provider": "openai",
578+
"vector_store_ids": ["kubernetes_docs"]
579+
}
580+
}
581+
}
582+
}
583+
```
584+
585+
> **Note:** If `model` and `provider` are not specified in metadata, the default model and provider configured in the service will be used. If `vector_store_ids` is not specified, all available vector stores will be queried for RAG.
586+
526587
### Example: Python Client
527588

528589
```python

src/app/endpoints/a2a.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,15 @@ async def _process_task_streaming( # pylint: disable=too-many-locals
281281
preview = user_input[:200] + ("..." if len(user_input) > 200 else "")
282282
logger.info("Processing A2A request: %s", preview)
283283

284-
# Extract routing metadata from context
284+
# Extract routing metadata from A2A message context.
285+
# Supported metadata fields (see docs/a2a_protocol.md for details):
286+
# - model: LLM model to use (e.g., "gpt-4", "llama3.1")
287+
# - provider: LLM provider to use (e.g., "openai", "watsonx")
288+
# - vector_store_ids: list of vector store IDs for RAG queries
285289
metadata = context.message.metadata if context.message else {}
286290
model = metadata.get("model") if metadata else None
287291
provider = metadata.get("provider") if metadata else None
292+
vector_store_ids = metadata.get("vector_store_ids") if metadata else None
288293

289294
# Resolve conversation_id from A2A contextId for multi-turn
290295
a2a_context_id = context_id
@@ -307,7 +312,7 @@ async def _process_task_streaming( # pylint: disable=too-many-locals
307312
no_tools=False,
308313
generate_topic_summary=True,
309314
media_type=None,
310-
vector_store_ids=None,
315+
vector_store_ids=vector_store_ids,
311316
)
312317

313318
# Get LLM client and select model

0 commit comments

Comments
 (0)