Skip to content

LangGraph apps

Stillbox runs your LangGraph graph inside your own small web app. It doesn’t run LangChain’s own server (the “Agent Server” behind langgraph dev and langgraph up); a project with only langgraph.json needs the few lines below.

Your graph’s state between runs (its checkpoints) goes in a Postgres database you own, through LangGraph’s MIT-licensed Postgres checkpointer. The sandbox can sleep between requests without losing a conversation.

requirements.txt:

fastapi
uvicorn[standard]
langgraph
langgraph-checkpoint-postgres
psycopg[binary,pool]

main.py:

import os
from contextlib import asynccontextmanager
from fastapi import FastAPI
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
from agent import builder # your StateGraph, not yet compiled
@asynccontextmanager
async def lifespan(app: FastAPI):
async with AsyncPostgresSaver.from_conn_string(os.environ["DATABASE_URL"]) as saver:
await saver.setup() # creates the checkpoint tables the first time
app.state.graph = builder.compile(checkpointer=saver)
yield
app = FastAPI(lifespan=lifespan)
@app.get("/health")
async def health():
return {"ok": True}
@app.post("/threads/{thread_id}/runs")
async def run(thread_id: str, payload: dict):
config = {"configurable": {"thread_id": thread_id}}
return await app.state.graph.ainvoke(payload, config)

Put DATABASE_URL in an environment as a secret delivered inside the sandbox (your organization must allow secrets inside sandboxes), with the repository, then:

Terminal window
stillbox deploy --environment <environment id> --health /health

Stillbox sees FastAPI and starts uvicorn main:app. Each POST /threads/<id>/runs continues that thread.

Model calls go through your sandbox’s model settings, as agents’ do: the base address and placeholder key are in the app’s environment variables. Add an approval step with harnessd approval "what you're about to do" from a tool, and the run waits for a person’s yes.