import { LlmAgent, FunctionTool }
from '@google/adk';
import { z } from 'zod';
const getWeather = new FunctionTool({
name: 'get_weather',
description: 'Get weather for a city.',
parameters: z.object({
city: z.string(),
}),
execute: async (args: { city: string }) => ({
city: args.city,
temp_c: 22,
condition: 'Clear',
}),
});
const agent = new LlmAgent({
name: 'weather_agent',
model: 'gemini-2.5-flash',
instruction: 'You are helpful.',
tools: [getWeather],
});
// ADK runner / InMemoryRunner / session...
const runner = new InMemoryRunner(agent);
const session = await runner.sessionService
.createSession({ appName: 'test' });
const events = runner.runAgent(
session.id, 'Weather in Tokyo?',
);
for await (const event of events) {
console.log(event);
}
|
import { LlmAgent, FunctionTool }
from '@google/adk';
import { z } from 'zod';
import { AgentRuntime } from '@io-orkes/conductor-javascript/agents';
// ^^^ add agentspan import
const getWeather = new FunctionTool({
name: 'get_weather',
description: 'Get weather for a city.',
parameters: z.object({
city: z.string(),
}),
execute: async (args: { city: string }) => ({
city: args.city,
temp_c: 22,
condition: 'Clear',
}),
});
const agent = new LlmAgent({
name: 'weather_agent',
model: 'gemini-2.5-flash',
instruction: 'You are helpful.',
tools: [getWeather],
});
// ^^^ agent + tools are identical
const runtime = new AgentRuntime();
const result = await runtime.run(
// ^^^ runtime.run() instead of ADK runner
agent,
'Weather in Tokyo?',
);
result.printResult();
await runtime.shutdown();
|