
Agents in 60 lines of python : Part 2
Tools = Dict When ChatGPT says "Used browser" or Claude says "Running search" — what's actually happening? The LLM can't run code. But it can say "call add with a=10, b=5 " — a structured request. Your code executes it. That's the whole trick. Tools are functions in a dictionary. The LLM picks which one to call. The concept The LLM decides. Your code executes. A message goes in. The LLM either returns a tool call (a structured request with a function name and arguments) or plain text. If it's a tool call, your code looks it up and runs it. If not, you return the text directly. One dict. One lookup. One call. The registry Step one: build a dictionary of callables. Every key is a tool name. Every value is the function that runs it. tools = { " add " : lambda a , b : a + b , " upper " : lambda text : text . upper (), } Lambda, function, class method — anything that takes arguments and returns a value. That's your tool registry. You also describe these tools for the LLM using JSON Schema,
Continue reading on Dev.to Tutorial
Opens in a new tab


