package base;
import java.util.concurrent.StructuredTaskScope;
import java.util.concurrent.StructuredTaskScope.Subtask;
public class ToolCallExample {
// Tool 1: Weather API - 200ms =
static String callWeatherTool() throws InterruptedException {
Thread.sleep(200);
return "Weather: 25C";
}
// Tool 2: DB Query - 300ms
static String callDatabaseTool() throws InterruptedException {
Thread.sleep(300);
return "User: Yugi from Hyd";
}
// Tool 3: LLM call - 500ms
static String callLlmTool() throws InterruptedException {
Thread.sleep(500);
throw new RuntimeException("LLM timeout!");
}
public static void main(String[] args) throws Exception {
System.out.println("Starting 3 tools parallel...");
long start = System.currentTimeMillis();
try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
Subtask