Examples · learn/21-concurrency · 248 of 339
agents
tin run examples/learn/21-concurrency/agents.tin/// Look up the population of a city, in millions.
tool fn population(city: string): int => match city {
"Istanbul" => 16
"Tokyo" => 14
_ => 1
}
agent Researcher { model: "mock", tools: [population] }
fn main() {
// fresh() gives each task its own conversation, so they can run at the same time
let tasks = ["Istanbul", "Tokyo", "Lima"].map(c => spawn Researcher.fresh().ask("population of '{c}'"))
for t in tasks { print(await t) }
}