Tin

Examples · learn/23-replay · 262 of 339

calc

run: --replay tests/tapes/agents-05-claude.json

examples/learn/23-replay/calc.tintin run examples/learn/23-replay/calc.tin
// run: --replay tests/tapes/agents-05-claude.json
/// Add two integers and return the sum.
tool fn add(a: int, b: int): int => a + b

/// Multiply two integers and return the product.
tool fn multiply(a: int, b: int): int => a * b

agent Calculator {
  system: "You are a calculator. Use the tools for all arithmetic. Reply with just the number."
  tools: [add, multiply]
  on toolCall(name, input) => print("  call {name} {input}")
}

fn main() {
  let answer: int = Calculator("What is (17 + 25) * 3?")
  print("(17 + 25) * 3 = {answer}")
}