Agentic AI Notebook
Back to Projects
AdvancedPhase 5 40 hours(broken down below)

AI Coding Agent

An autonomous coding agent that reads codebases, plans changes, writes code, runs tests, and self-corrects.

PythonLangGraphOpenAIDockerGit

Project walkthrough

AI Coding Agent

1 / 6

Project Goal

Autonomous agent that plans, codes, tests, and opens PRs.

  • Explore codebases with read/search tools
  • Multi-step planning with human approval
  • Apply patches and run tests in Docker sandbox
  • Self-correct on test failures, then open PR

Use ← → arrow keys or buttons to navigate the walkthrough

Time breakdown (40h)

Each phase maps to the estimated hours — follow in order for a realistic build schedule.

Repo indexer & tools

8h
  • Tree walk with file size and language detection
  • read_file, search_repo (ripgrep), list_dir tools
  • Path allowlist and .env blocklist guardrails

Planner agent

8h
  • Decompose task into ordered file-level steps
  • Human approval gate for plans >5 files
  • Persist plan in LangGraph checkpoint

Coder & patch apply

10h
  • Unified diff generation via apply_patch tool
  • Max 20 files per task enforcement
  • Structured output for patch format validation

Docker sandbox & tests

8h
  • Clone repo, apply diff, run pytest + ruff
  • Capture stderr for debugger node input
  • Max 3 retry loops on test failure

PR integration & eval

6h
  • GitHub API: create branch, commit, open PR
  • LangSmith traces for every agent step
  • Eval on 10 SWE-bench-lite tasks, track pass rate

Architecture

A LangGraph orchestrator receives tasks via CLI or webhook, builds a repo map, and routes through planner → coder → sandbox test nodes. Failed tests trigger a debugger node that reads stderr and retries with capped attempts before opening a PR for human review.

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Prerequisites

  • Strong Python and Git fundamentals
  • LangGraph state machines and checkpointing
  • Docker for sandboxed test execution
  • Understanding of ReAct / tool-calling agent patterns
  • Experience reading and modifying medium-sized codebases

Setup steps

  1. Clone a small open-source Python repo (e.g., FastAPI tutorial app)
  2. Scaffold LangGraph orchestrator with AgentState TypedDict
  3. Build tools: read_file, search_repo, apply_patch, run_terminal
  4. Create Docker sandbox image with pytest and ruff pre-installed
  5. Configure OpenAI function calling for planner and coder nodes
  6. Seed 5 small bug-fix tasks from SWE-bench-lite for eval

Features to build

  • Codebase analysis
  • Multi-step planning
  • Test execution
  • Self-correction loop

Expected result

Give the agent a GitHub issue like 'Add rate limiting to POST /login', watch it plan, patch, pass tests in Docker, and open a PR with a summary — demonstrating the full plan→code→test→review loop.

Resume bullet points

  • Built autonomous coding agent with ReAct loop and self-correction
  • Integrated tool calling for file I/O, terminal, and git operations

Interview questions

How do you prevent an AI coding agent from editing the wrong files?
Repo map + path allowlist, planner must cite target paths, max files per task, diff review before apply, and human approval on large changesets.
What happens when tests fail after a patch?
Route to a debugger node with stderr and failed test names. Retry with capped attempts (e.g., 3). Escalate to human if still failing.
Why sandbox tests instead of trusting the LLM?
LLMs hallucinate success. Only executed tests prove correctness. Sandbox also isolates destructive commands and network access.