Skip to content

labdmitriy/build-your-own-coding-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Your Own Coding Agent From Scratch

Build a coding agent from scratch in 13 iterative steps — from a bare Gemini API call to a fully functional coding agent deployed on Modal with Telegram integration, persistent memory, and sandboxed execution.

View the presentation for a visual walkthrough of the entire build.

Credits

This project is based on the outstanding work by Ivan Leo and Hugo Bowne-Anderson:

I discovered this material through Hugo's workshop and was inspired to rebuild it as a structured tutorial. Huge thanks to both Hugo and Ivan for making this knowledge accessible.

What this repo adds

The original repo contains the code in two parallel tracks (article directories and a workshop folder). This version reorganizes and extends it:

  • Unified 13-step progression — single clean sequence from 01_first_api_call to 13_cloud_deploy, each step self-contained and independently runnable
  • Cloud deployment in the tutorial — Step 13 brings Modal sandbox deployment into the learning path
  • Dynamic tool rewriting works in cloud — bidirectional sync between the Modal sandbox and the host agent, so the agent can genuinely extend its own tools even when deployed remotely
  • Sandbox persistence connected — the SaveEnvironment tool's filesystem images are actually used when restoring sandboxes (three-tier restore: process snapshot → saved filesystem image → fresh base)
  • Deploy/teardown scripts for every step — each step from 09 onward can be independently started and stopped with a single command
  • No secrets in the repo — proper .env.template and .gitignore
  • Presentation included — a visual walkthrough of the entire 13-step build

Steps

Step Concept
01 First API call — Gemini + tool declaration
02 Tool execution — execute and feed result back
03 Agentic loop — chain multiple tool calls
04 Tool factory — AgentTool base class + Pydantic
05 Full toolset — Read, Write, Edit, Bash
06 Hot reload — self-extending agent
07 Hooks — event system + Rich output
08 HTTP server — FastAPI endpoint
09 Telegram — webhook integration
10 Sessions — SQLite persistence
11 Compaction — memory summarization
12 Guardrails — system prompt + tool budget
13 Cloud deploy — Modal sandbox + snapshots

Prerequisites

Setup

  1. Clone and install dependencies:
git clone https://github.com/labdmitriy/build-your-own-coding-agent.git
cd build-your-own-coding-agent
uv sync
  1. Configure environment variables:
cp .env.template .env

Edit .env and fill in:

Variable Required for How to get
GOOGLE_API_KEY All steps Google AI Studio — create a Gemini API key
TELEGRAM_BOT_TOKEN Steps 09+ BotFather — create a bot and copy the token
TELEGRAM_CHAT_ID Steps 09+ Send any message to your bot, then visit https://api.telegram.org/bot<TOKEN>/getUpdates to find your chat ID
  1. For steps 09–12 (Telegram via ngrok):

Install ngrok, sign up for a free account, and authenticate:

ngrok config add-authtoken <your-token>
  1. For step 13 (Modal cloud deploy):

Install the Modal CLI and authenticate:

uv run modal setup

Running a step

Each step is self-contained:

uv run python steps/01_first_api_call/agent.py
uv run python steps/06_hot_reload/agent.py

Steps 09–12 use deploy.sh / teardown.sh to start and stop the Telegram webhook:

cd steps/09_telegram
bash deploy.sh     # starts uvicorn + ngrok, registers webhook
bash teardown.sh   # stops processes, clears webhook

Step 13 uses the same pattern for Modal cloud deployment:

cd steps/13_cloud_deploy
bash deploy.sh     # creates Modal secrets, deploys server + worker, registers webhook
bash teardown.sh   # clears webhook, stops apps, deletes Modal resources

Related reading

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors