Skip to content

Commit 00fdd97

Browse files
Add currency agent A2A example snapshot (#23)
## Summary closes NAT-222 This PR adds the `currency_agent_a2a` example snapshot to the NVIDIA NeMo Agent Toolkit Examples repository. The example demonstrates a workflow built with the toolkit that combines an A2A currency agent with an MCP time server for currency conversion and historical exchange-rate prompts. ## Context NAT-222 tracks the `currency_agent_a2a` historical USD to EUR query failing during the toolkit's 1.7 release validation. This example depends on external services and a separately cloned third-party A2A sample server, so the README presents it as a reference integration rather than a deterministic release-validation example for the toolkit. ## Changes - Add `examples/currency_agent_a2a/README.md` with setup, usage, architecture, troubleshooting, and related-example guidance. - Add `examples/currency_agent_a2a/configs/config.yml` for the per-user ReAct workflow, A2A client, MCP time client, and NIM LLM configuration. - Add `examples/currency_agent_a2a/data/sample_queries.json` with basic, historical, and time-integrated sample prompts. - Add `examples/currency_agent_a2a/pyproject.toml` with the example package metadata and dependencies. - Use a basic conversion as the primary README smoke command, with historical prompts kept as external-service-dependent samples. - Replace docs-facing shorthand with the full product name on first mention and `toolkit` afterward. Authors: - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) Approvers: - David Gardner (https://github.com/dagardner-nv) URL: #23
1 parent 145a988 commit 00fdd97

4 files changed

Lines changed: 269 additions & 0 deletions

File tree

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<!--
2+
SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
# Currency Agent A2A Example
19+
20+
**Complexity:** Beginner
21+
22+
This is a snapshot of the NVIDIA NeMo Agent Toolkit 1.6 `currency_agent_a2a` example. It demonstrates a toolkit workflow connecting to a third-party A2A server, the LangGraph-based currency agent. The workflow acts as an A2A client to perform currency conversions and financial queries with time-based context.
23+
24+
This example is intentionally hosted in the examples repository because it depends on external services and a separately cloned A2A sample server. It is useful as a reference integration, but it is not intended to be a deterministic release-validation example for the toolkit itself.
25+
26+
## Key Features
27+
28+
- Per-user A2A client connections to external services
29+
- External A2A integration with a third-party LangGraph currency agent
30+
- Hybrid tool architecture combining A2A currency tools with MCP time services
31+
- Currency conversion with historical date context
32+
- Multi-user support through isolated session state
33+
34+
## Architecture Overview
35+
36+
```mermaid
37+
flowchart LR
38+
subgraph "Currency Agent Workflow"
39+
CW[Currency Agent Workflow]
40+
CW --> CAC[Currency A2A Client]
41+
CW --> TMC[Time MCP Client]
42+
end
43+
44+
CAC --> AP[A2A Protocol<br/>localhost:11000]
45+
AP --> LG[LangGraph Currency Agent<br/>External Service]
46+
47+
subgraph "External Currency Agent"
48+
LG --> CT[Currency Tools]
49+
end
50+
51+
style CW fill:#e1f5fe,color:#000
52+
style LG fill:#f3e5f5,color:#000
53+
style AP fill:#fff3e0,color:#000
54+
```
55+
56+
## Installation and Setup
57+
58+
### Prerequisites
59+
60+
Clone this repository and create the development environment described in the root [README](../../README.md).
61+
62+
### Set Up API Keys
63+
64+
Set your NVIDIA and OpenAI API keys as environment variables:
65+
66+
```bash
67+
export NVIDIA_API_KEY=<YOUR_API_KEY>
68+
export OPENAI_API_KEY=<YOUR_API_KEY>
69+
```
70+
71+
### Set Up External A2A Server
72+
73+
The currency agent runs as an external service using the `a2a-samples` repository:
74+
75+
```bash
76+
# Step 1: Clone the a2a-samples repository and checkout the tested revision.
77+
mkdir -p external
78+
cd external
79+
git clone https://github.com/a2aproject/a2a-samples.git
80+
cd a2a-samples
81+
git checkout eb3885f
82+
83+
# Step 2: Navigate to the LangGraph agent.
84+
cd samples/python/agents/langgraph
85+
86+
# Step 3: Set the environment variables for the currency agent.
87+
cat <<EOF > .env
88+
API_KEY=$OPENAI_API_KEY
89+
model_source=openai
90+
TOOL_LLM_URL=https://api.openai.com/v1
91+
TOOL_LLM_NAME=gpt-4o-mini
92+
EOF
93+
94+
# Step 4: Run the currency agent on port 11000.
95+
uv run app --port 11000
96+
```
97+
98+
### Install Currency Agent Client
99+
100+
From the root directory of this repository, install this example:
101+
102+
```bash
103+
uv pip install -e examples/currency_agent_a2a
104+
```
105+
106+
## Usage
107+
108+
### Verify External Server
109+
110+
First, verify the external currency agent is running:
111+
112+
```bash
113+
nat a2a client discover --url http://localhost:11000
114+
```
115+
116+
### Run the Currency Agent Client
117+
118+
In a separate terminal, run the client workflow:
119+
120+
```bash
121+
nat run --config_file examples/currency_agent_a2a/configs/config.yml \
122+
--input "What is 100 USD in EUR?"
123+
```
124+
125+
### Additional Examples
126+
127+
For historical and time-integrated prompts, see [`data/sample_queries.json`](data/sample_queries.json). Those prompts depend on the external currency agent and live currency API behavior.
128+
129+
## Per-User Workflow Architecture
130+
131+
This example uses a per-user workflow pattern because A2A clients are per-user function groups:
132+
133+
- Each user gets isolated connections to the external A2A service
134+
- Independent session state and request tracking per user
135+
136+
## Configuration Details
137+
138+
### Workflow Configuration
139+
140+
The workflow is configured to use the core per-user ReAct agent:
141+
142+
```yaml
143+
workflow:
144+
_type: per_user_react_agent
145+
tool_names:
146+
- mcp_date_time__get_current_time_mcp_tool
147+
- currency_agent
148+
llm_name: nim_llm
149+
```
150+
151+
### Tool Composition
152+
153+
The configuration demonstrates two types of tool integration:
154+
155+
1. A2A client tools through `currency_agent`
156+
2. MCP client tools through `mcp_date_time`
157+
158+
## Troubleshooting
159+
160+
### Connection Issues
161+
162+
If the external server is not running, check the agent discovery card:
163+
164+
```bash
165+
curl http://localhost:11000/.well-known/agent-card.json | jq
166+
```
167+
168+
### Port Conflicts
169+
170+
Ensure port `11000` is available for the currency agent. If needed, modify the port in both the external agent startup command and `configs/config.yml`.
171+
172+
### Timeouts
173+
174+
If queries take longer than expected, increase `task_timeout` in the A2A client configuration and check network connectivity to the external service.
175+
176+
## Related Examples
177+
178+
For deterministic A2A release validation examples owned by the toolkit, use the `math_assistant_a2a` and `math_assistant_a2a_protected` examples in the toolkit repository.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
function_groups:
17+
mcp_date_time:
18+
_type: mcp_client
19+
server:
20+
transport: stdio
21+
command: "python"
22+
args: ["-m", "mcp_server_time", "--local-timezone=America/Los_Angeles"]
23+
tool_overrides:
24+
get_current_time:
25+
alias: get_current_time_mcp_tool
26+
description: "Use this tool to get dates"
27+
include:
28+
- get_current_time_mcp_tool
29+
30+
currency_agent:
31+
_type: a2a_client
32+
url: http://localhost:11000
33+
34+
llms:
35+
nim_llm:
36+
_type: nim
37+
model_name: meta/llama-3.1-70b-instruct
38+
temperature: 0.0
39+
max_tokens: 1024
40+
41+
workflow:
42+
_type: per_user_react_agent
43+
tool_names:
44+
- mcp_date_time__get_current_time_mcp_tool
45+
- currency_agent
46+
llm_name: nim_llm
47+
verbose: true
48+
retry_parsing_errors: true
49+
max_retries: 3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:dedfc94787986facee450b914b030cf0865a0126615b44fe0baf64df74d71011
3+
size 1269
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
[build-system]
17+
build-backend = "setuptools.build_meta"
18+
requires = ["setuptools >= 64", "setuptools-scm>=8"]
19+
20+
[tool.setuptools_scm]
21+
git_describe_command = "git describe --long --first-parent"
22+
root = "../.."
23+
24+
[tool.setuptools]
25+
packages = []
26+
27+
[project]
28+
name = "nat_currency_agent_a2a"
29+
dynamic = ["version"]
30+
requires-python = ">=3.11,<3.14"
31+
description = "A2A client example demonstrating external/third-party A2A server integration"
32+
dependencies = [
33+
"nvidia-nat[a2a,mcp,test]==1.6.0",
34+
"mcp-server-time~=2025.8",
35+
]
36+
keywords = ["ai", "a2a", "protocol", "agents"]
37+
classifiers = ["Programming Language :: Python"]
38+
authors = [{ name = "NVIDIA Corporation" }]
39+
maintainers = [{ name = "NVIDIA Corporation" }]

0 commit comments

Comments
 (0)