Skip to content

Commit a0cd394

Browse files
author
Scion Agent
committed
docs: show proper ADK app structure, document A2A conversation lifecycle
- README now shows agent.py + adk web/run workflow (proper ADK app) - connect_agent docs explain long-running tasks and A2A conversation lifecycle - Added RemoteA2aAgent example for multi-turn follow-up after discovery - Updated toolset docstring with lifecycle notes
1 parent a044585 commit a0cd394

2 files changed

Lines changed: 54 additions & 10 deletions

File tree

contributing/samples/ardhf/README.md

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,37 @@ The core workflow is **discover → inspect → connect**:
1111

1212
1. **Discover** — search ARD registries for resources matching a natural-language query.
1313
2. **Inspect** — fetch the full artifact (agent card, skill markdown, MCP descriptor) by URL.
14-
3. **Connect** — send a message to a remote A2A agent and get a response.
14+
3. **Connect** — send a message to a remote A2A agent and get a response (which may be the start of a long-running A2A conversation).
1515

1616
## Quick Start
1717

18+
### 1. Create the agent (`agent.py`)
19+
1820
```python
1921
from google.adk import Agent
2022
from google.adk_community.tools.ardhf import AgentFinderToolset
2123

22-
agent = Agent(
23-
name="my_agent",
24-
instruction="Search for tools when you need a capability.",
24+
root_agent = Agent(
25+
name="discovery_agent",
26+
description="An agent that discovers and connects to agentic resources.",
27+
instruction="Search for agents, skills, and tools when you need a capability.",
2528
tools=[AgentFinderToolset()],
2629
)
2730
```
2831

29-
That's it — the agent now has access to all discovery tools and can search,
30-
inspect, and connect to agentic resources.
32+
### 2. Run the app
33+
34+
```bash
35+
# Interactive web UI
36+
adk web .
37+
38+
# Or run programmatically
39+
adk run .
40+
```
41+
42+
The agent is an ADK app — serve it with `adk web` for the interactive UI,
43+
or `adk run` for CLI mode. The toolset provides all discovery and connection
44+
tools automatically.
3145

3246
## Available Tools
3347

@@ -39,7 +53,7 @@ inspect, and connect to agentic resources.
3953
| `search_tools` | Search filtered to MCP servers (`application/mcp-server+json`) |
4054
| `search_spaces` | Search filtered to HuggingFace Spaces (`application/vnd.huggingface.space+json`) |
4155
| `get_agent_card` | Fetch a specific artifact (agent card, skill markdown, MCP descriptor) by URL |
42-
| `connect_agent` | Send a message to a remote A2A agent and return the response |
56+
| `connect_agent` | Send a message to a remote A2A agent — may return an immediate response or start a long-running task with its own lifecycle |
4357

4458
The `search_agents`, `search_skills`, `search_tools`, and `search_spaces`
4559
tools are convenience aliases — each calls the same core search logic with
@@ -105,6 +119,30 @@ Agent: [calls connect_agent('https://.../agent.json', 'Create a minimalist logo
105119
Agent: The image generation agent responded with: ...
106120
```
107121

122+
**Note on A2A conversations:** `connect_agent` sends a single message and
123+
collects the response, but the remote agent may return a **long-running task**
124+
with its own lifecycle (submitted → working → completed). The response you
125+
get back may be the final result or an intermediate status. This initial
126+
exchange is the **beginning of an A2A conversation** — for multi-turn
127+
interactions with a discovered agent, consider using ADK's `RemoteA2aAgent`
128+
directly with the agent card URL returned by `get_agent_card`:
129+
130+
```python
131+
from google.adk.agents.remote_a2a_agent import RemoteA2aAgent
132+
133+
# After discovering an agent via search_agents + get_agent_card:
134+
remote = RemoteA2aAgent(
135+
name="discovered_agent",
136+
agent_card="https://example.com/.well-known/agent.json",
137+
)
138+
139+
# Use as a sub-agent for ongoing A2A conversation
140+
orchestrator = Agent(
141+
name="orchestrator",
142+
sub_agents=[remote],
143+
)
144+
```
145+
108146
### Discovering HuggingFace Spaces
109147

110148
> "Find a text-to-speech Space"
@@ -244,9 +282,9 @@ fixed fixtures — no API keys or network access needed:
244282
pip install hf-agentfinder
245283
hf-agentfinder challenge serve --port 8090
246284

247-
# Terminal 2: run the sample agent against it
248-
ARDHF_REGISTRY_URL=http://127.0.0.1:8090 \
249-
adk web contributing/samples/ardhf
285+
# Terminal 2: run the sample app against it
286+
cd contributing/samples/ardhf
287+
ARDHF_REGISTRY_URL=http://127.0.0.1:8090 adk web .
250288
```
251289

252290
### Running the unit tests

src/google/adk_community/tools/ardhf/ardhf_toolset.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,12 @@ async def _connect_agent(
461461
be for an artifact with media type
462462
``application/a2a-agent-card+json``.
463463
464+
Note: The remote agent may return an immediate response or start
465+
a long-running task (submitted → working → completed). This
466+
call collects available response text, but the exchange is the
467+
beginning of an A2A conversation — for multi-turn interactions,
468+
use ``RemoteA2aAgent`` directly with the discovered agent card URL.
469+
464470
Args:
465471
agent_card_url: Full URL to the remote agent's A2A agent card
466472
(typically the ``url`` field from a search result whose

0 commit comments

Comments
 (0)