The core loop
A tool-calling agent is not one model call. It is a loop: ask the model, inspect the response, run any requested tool, send the tool result back, then ask again.
The model decides what tool to request from the tools you gave it. Your code executes the tool and controls what result goes back.
Who does what
The model emits a structured tool call, such as search_notes with arguments. Your app checks the name, parses the arguments, runs the matching function, and records the result.