Skip to content

Case study

Coding Agent

A LangGraph Coding Agent

A LangGraph coding agent I built: it reads, summarises and writes files from plain-English requests, and asks for approval before every write.

Own build: what this status meansSelf-built · personal project, not client work

Why no client names or numbers?

Built by VelvoAI, an independent AI systems studio. One engineer scopes and writes every system.

A terminal session of the coding agent: it reads a file, proposes a write, and asks for approval before writing
A real session in the terminal

The brief

The problem and the build

01

The problem

A coding assistant that can write files can also overwrite the wrong one, so the real problem is giving a model file access without giving it the final say.

02

The solution

Built a command-line coding assistant in the style of Claude Code as a LangGraph state machine: it reads, partially reads, summarises and writes files from plain-English requests, and every write passes through an approval step where the user can approve, reject or edit the change.

Before
File changes decided by the model alone
After
Every write shown first and applied only on approval, with a backup kept

Built with

The stack and what it demonstrates

Stack

  • LangGraph
  • OpenAI
  • Python
  • Rich
  • Pydantic
Coding Agent · how a request is handled
  1. 01Take the request

    A plain-English request is typed at the prompt, with history to navigate.

  2. 02Route to a tool

    A routing node picks read, partial read, summarise or write.

  3. 03Run the file tool

    Paths are sanitised and inputs validated before any file is touched.

  4. 04Ask before writing

    A write stops at an approval node: approve, reject or edit, with a backup kept.

  5. 05Stream the answer

    The response node streams the reply token by token, rendered with Rich.

The hard part

What made it harder than it looks

  • A model with write access can overwrite the wrong file, so no write could happen on the model's say-so alone
  • File paths come from free text, so every operation had to stay inside safe paths and be validated before it ran
  • A request like "read first 10 lines of large_file.py" needs partial reads, by lines, characters or a range, not just whole files

Architecture

How it was built

A request typed at the prompt enters a LangGraph state machine. A routing node decides which tool it needs and sends it to the matching node: read a file, read part of one by lines, characters or a range, summarise one, or write one. Paths are sanitised and inputs validated before anything touches the disk, and errors are caught and recovered from rather than ending the session. A write does not run directly: it goes to a request_approval node that shows the change and waits, and only on approval does the approved-write node keep a backup of the existing file and write the new content. Every path ends at a response node that streams the answer back token by token, rendered in the terminal with Rich, on OpenAI models through langchain-openai.

A decision

Approval is a node, not an instruction

The easy way to make an agent careful is to tell it, in the prompt, to ask before writing. That leaves the decision with the model, which can ignore it. Here the write path runs through an explicit approval node in the graph, so there is no route to the disk that skips the user: the change is shown, the user approves, rejects or edits it, and the model cannot write a file without the user saying yes.

My part

What I built

All of it. My own project: the graph, the tools, the approval flow, the CLI and the tests. The code is private.

Written by
Usman Ali, Founder
Last reviewed

Next step

Ready to scale operations without more busywork?

Bring the workflow, lead leak, reporting gap or knowledge bottleneck. You talk to the engineer who would build it, and leave knowing what it would take to ship.

Book a call

Free, no obligation.