Skip to content

Commit 3421bf3

Browse files
committed
Allow to configure A2A protocol version from the AgentCard
1 parent 1404846 commit 3421bf3

3 files changed

Lines changed: 76 additions & 6 deletions

File tree

docs/a2a_protocol.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Create a separate `agent_card.yaml` file with the agent card configuration:
8686
# agent_card.yaml
8787
name: "Lightspeed AI Assistant"
8888
description: "An AI assistant for OpenShift and Kubernetes"
89+
protocolVersion: "0.3.0" # A2A protocol version (default: "0.3.0")
8990
provider:
9091
organization: "Red Hat"
9192
url: "https://redhat.com"
@@ -128,6 +129,7 @@ customization:
128129
agent_card_config:
129130
name: "My AI Assistant"
130131
description: "An AI assistant for helping with various tasks"
132+
protocolVersion: "0.3.0" # A2A protocol version (default: "0.3.0")
131133
provider:
132134
organization: "My Organization"
133135
url: "https://myorg.example.com"
@@ -266,7 +268,7 @@ The agent card describes the agent's capabilities:
266268
"version": "1.0.0",
267269
"url": "https://example.com/a2a",
268270
"documentation_url": "https://example.com/docs",
269-
"protocol_version": "0.2.1",
271+
"protocol_version": "0.3.0",
270272
"provider": {
271273
"organization": "Red Hat",
272274
"url": "https://redhat.com"
@@ -298,6 +300,8 @@ The agent card describes the agent's capabilities:
298300
}
299301
```
300302

303+
**Note:** The `protocol_version` field can be configured via the `protocolVersion` setting in your agent card configuration (see [Agent Card Configuration](#agent-card-configuration) section above).
304+
301305
## How the Executor Works
302306

303307
### A2AAgentExecutor
@@ -710,7 +714,16 @@ Check logs for entries from `app.endpoints.handlers` logger.
710714

711715
## Protocol Version
712716

713-
This implementation supports A2A protocol version **0.2.1**.
717+
The A2A protocol version can be configured in the agent card configuration file using the `protocolVersion` field. If not specified, it defaults to **0.3.0**.
718+
719+
To set a specific protocol version, add it to your agent card configuration:
720+
721+
```yaml
722+
# In agent_card.yaml or customization.agent_card_config
723+
protocolVersion: "0.3.0"
724+
```
725+
726+
The protocol version is included in the agent card response and indicates which version of the A2A protocol specification the agent implements.
714727

715728
## References
716729

src/app/endpoints/a2a.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def get_lightspeed_agent_card() -> AgentCard:
584584
default_input_modes=config.get("defaultInputModes", ["text/plain"]),
585585
default_output_modes=config.get("defaultOutputModes", ["text/plain"]),
586586
capabilities=capabilities,
587-
protocol_version="0.2.1",
587+
protocol_version=config.get("protocolVersion", "0.3.0"),
588588
security=config.get("security", [{"bearer": []}]),
589589
security_schemes=config.get("security_schemes", {}),
590590
)
@@ -845,6 +845,6 @@ async def a2a_health_check() -> dict[str, str]:
845845
"status": "healthy",
846846
"service": "lightspeed-a2a",
847847
"version": __version__,
848-
"a2a_sdk_version": "0.2.1",
849-
"timestamp": datetime.now().isoformat(),
848+
"a2a_sdk_version": "0.3.4",
849+
"timestamp": datetime.now(timezone.utc).isoformat(),
850850
}

tests/unit/app/endpoints/test_a2a.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def test_get_agent_card_with_config(
352352
assert agent_card.name == "Test Agent"
353353
assert agent_card.description == "A test agent"
354354
assert agent_card.url == "http://localhost:8080/a2a"
355-
assert agent_card.protocol_version == "0.2.1"
355+
assert agent_card.protocol_version == "0.3.0" # Default protocol version
356356

357357
# Check provider
358358
assert agent_card.provider is not None
@@ -367,6 +367,63 @@ def test_get_agent_card_with_config(
367367
assert agent_card.capabilities is not None
368368
assert agent_card.capabilities.streaming is True
369369

370+
def test_get_agent_card_with_custom_protocol_version(
371+
self, mocker: MockerFixture
372+
) -> None:
373+
"""Test getting agent card with custom protocol version."""
374+
config_dict: dict[Any, Any] = {
375+
"name": "test",
376+
"service": {
377+
"host": "localhost",
378+
"port": 8080,
379+
"auth_enabled": False,
380+
"base_url": "http://localhost:8080",
381+
},
382+
"llama_stack": {
383+
"api_key": "test-key",
384+
"url": "http://test.com:1234",
385+
"use_as_library_client": False,
386+
},
387+
"user_data_collection": {},
388+
"mcp_servers": [],
389+
"customization": {
390+
"agent_card_config": {
391+
"name": "Test Agent",
392+
"description": "A test agent",
393+
"protocolVersion": "0.2.1", # Custom protocol version
394+
"provider": {
395+
"organization": "Test Org",
396+
"url": "https://test.org",
397+
},
398+
"skills": [
399+
{
400+
"id": "test-skill",
401+
"name": "Test Skill",
402+
"description": "A test skill",
403+
"tags": ["test"],
404+
"inputModes": ["text/plain"],
405+
"outputModes": ["text/plain"],
406+
}
407+
],
408+
"capabilities": {
409+
"streaming": True,
410+
"pushNotifications": False,
411+
"stateTransitionHistory": False,
412+
},
413+
}
414+
},
415+
"authentication": {"module": "noop"},
416+
"authorization": {"access_rules": []},
417+
"a2a_state": {},
418+
}
419+
cfg = AppConfig()
420+
cfg.init_from_dict(config_dict)
421+
mocker.patch("app.endpoints.a2a.configuration", cfg)
422+
423+
agent_card = get_lightspeed_agent_card()
424+
425+
assert agent_card.protocol_version == "0.2.1" # Custom version used
426+
370427
def test_get_agent_card_without_config_raises_error(
371428
self,
372429
setup_minimal_configuration: AppConfig, # pylint: disable=unused-argument

0 commit comments

Comments
 (0)