You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This sample demonstrates how to use `DynamicAgentRequestHandler` to create a server that can dynamically route to different agents based on the URL path.
4
+
5
+
The server provides two working example agents:
6
+
-**Calculator Agent**: Performs basic math operations like "2 + 2" or "10 * 5"
7
+
-**Weather Agent**: Provides fake weather data for major cities (London, Paris, Tokyo, New York, Sydney)
The `DynamicAgentRequestHandler` inspects the incoming URL and dynamically determines:
27
+
1. Which agent card to return
28
+
2. Which task store to use
29
+
3. Which agent executor to run
30
+
31
+
This allows a single route setup (`/agents`) to handle multiple different agent behaviors without needing separate route configurations for each agent.
32
+
33
+
## Testing the Agents
34
+
35
+
### Using the CLI Client
36
+
37
+
The easiest way to test the agents is using the built-in CLI client:
38
+
39
+
```bash
40
+
# Test the calculator agent
41
+
npm run sample:cli -- http://localhost:3000/agents/calculator/
42
+
# Try typing: 1 + 1
43
+
44
+
# Test the weather agent
45
+
npm run sample:cli -- http://localhost:3000/agents/weather/
46
+
# Try typing: whats weather in tokyo
47
+
```
48
+
49
+
### Using curl or HTTP clients
50
+
51
+
You can also test the agents using curl or any HTTP client:
result=`The weather in ${foundCity.charAt(0).toUpperCase()+foundCity.slice(1)} is currently ${temp}°C and ${conditions}. (This is fake data for demonstration purposes!)`;
119
+
}else{
120
+
result="I can provide weather information! Try asking about the weather in London, Paris, Tokyo, New York, or Sydney.";
0 commit comments