A hands-on walkthrough of building a tool-calling agent in Python from scratch, without a framework. The agent uses OpenAI's API, calls real public APIs (Nominatim for geocoding, Open-Meteo for weather), validates tool arguments with JSON Schema, returns compact tool payloads, and handles model request failures gracefully. The tutorial emphasizes inspectability: every tool call, argument, result, and error is captured in a transcript and optionally logged to Weights & Biases Weave for tracing. A preflight verify mode lets you test the Python layer before spending API tokens. The core lesson is to understand the raw message loop before adopting an agent framework or MCP.
Table of contents
The run should answer four questionsWhat a tool calling agent actually doesThe message loop this article exposesWhy start without a frameworkCreate one folder and set up the environmentSave the complete runnable scriptRun a preflight check before spending tokensRun the agent against real APIsRun one messy promptAdd a Weave traceHow the script maps to the agent loopReliability starts where the loop is visibleWhere this leaves the agentSelected Sources33 Impressions1 Comment