Skip to content

acascell/lang-graph-agent

Repository files navigation

lang-graph-agent

This project is a FastAPI endpoint running lang-graph in the backend:

  • ChatOllama as the LLM
  • StateGraph with a conditional edge
  • interrupt(...) for sensitive tool approval
  • SqliteSaver as the checkpointer for persistent memory
  • main.py as the FastAPI entrypoint
  • app.py for the route
  • model.py for the request/response models

You run the API and send queries to /chat. If you keep using the same thread_id, the graph keeps the conversation memory in SQLite.

Architecture

architecture.png

Run with Docker

docker compose up -d --build

The SQLite checkpoint file is stored in ./data/checkpoints.db on the host, so memory survives container restarts.

API

Send a query:

curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -d '{
    "thread_id": "user-session-001",
    "query": "Remember that I work at Acme Corp."
  }'

Resume an interrupt:

curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -d '{
    "thread_id": "user-session-001",
    "approved": true
  }'

Notes

  • Reuse the same thread_id to keep memory.
  • A different thread_id starts a new conversation.
  • /chat handles both new questions and interrupt resumes.
  • The graph still uses conditional routing: answer directly, pause for approval, or go through tools.
  • The LangChain/LangGraph logic stays in agent/state.py, agent/graph.py, agent/nodes.py, and agent/tools.py.

About

Build agents using graphs, nodes, states, interrupt, checkpoint with LangChhain and LangGraph

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors