Build Your Own Coding Agent in Python (It Fixes Real Code — Behind an Approval Gate)
Build your own coding agent — in one Python file, with three tools and one rule that makes it safe to use: it cannot change a single line of code until a human approves the change . In this tutorial we build the agent on the Gemini API's function-calling loop, point it at a real project with a real failing test, and watch it find the bug, propose the fix, stop at the approval gate, and — only after a yes — apply it and prove the suite green. Then it prints its own bill. Every step has its own real screenshot, taken from the run you are reading about. Versions used in this tutorial Python 3.12 google-genai 3.0.0 (the Gemini SDK, pinned) and pytest 9.2.0 (pinned) Model: gemini-3.8-flash — rate card verified on Google's official pricing page on 2026-11-07: $0.75 per 1M input tokens, $3.75 per 1M output tokens (Standard tier, in effect through Dec 31, 2026); a free tier exists Companion code: topic-09-coding-agent in the Visual Studio Learn code repo Step 0 — Setup from zer...