👆 Click to watch the Canvas Callback demo on YouTube
Canvas Callback is an open-source implementation that demonstrates how to transform AI chat interfaces into interactive visual workspaces using LangGraph's interrupt for human-in-the-loop workflows.
Canvas Callback showcases a powerful pattern for building collaborative AI applications that go beyond typical chat interfaces:
The project demonstrates how these patterns work together in a travel planning agent that interrupts its workflow to collect specific information through specialized UIs.
┌────────────────────────────────────────┐
│ UI Layer │
│ ┌──────────┐ ┌─────────────┐ │
│ │ Chat │◄────────►│ Canvas │ │
│ └──────────┘ └─────────────┘ │
└────────────┬───────────────┬───────────┘
│ │
▼ ▼
┌────────────────┐ ┌──────────────────┐
│ Message Handler│ │ Interrupt Handler│
└────────┬───────┘ └────────┬─────────┘
│ │
▼ ▼
┌────────────────────────────────────────┐
│ LangGraph Runtime │
│ │
│ ┌───────────┐ ┌───────────────┐ │
│ │ Agent │◄────►│ Interrupts │ │
│ └───────────┘ └───────────────┘ │
└────────────────────────────────────────┘
Canvas Callback is designed as a focused, accessible implementation to help you understand and integrate the Canvas UX pattern using LangGraph interrupts. Once you've understand these core concepts, you may want to explore LangChain's OpenCanvas for advanced features like memory systems, custom actions, and artifact versioning.
Canvas Callback's pattern can be applied to diverse domains:
git clone https://github.com/ahmad2b/canvas-callback.git
cd canvas-callback
cd web
npm install
# or
pnpm install
cd ../agent
# Install LangGraph CLI
pip install -U "langgraph-cli[inmem]"
# Install project dependencies
poetry install
# or
pip install -r requirements.txt
cp web/.env.example web/.env
cp agent/.env.example agent/.env
Add your API keys and configuration details to both .env files.
For LangGraph, you'll need a LangSmith API key which can be created from the LangSmith UI (Settings > API Keys). Add it to your agent/.env file:
LANGSMITH_API_KEY=your_api_key_here
# Terminal 1 - Frontend
cd web
npm run dev
# Terminal 2 - LangGraph Agent
cd agent
langgraph dev
When the LangGraph server starts successfully, you'll see something like:
Ready!
* API: http://localhost:2024
* Docs: http://localhost:2024/docs
* LangGraph Studio Web UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License
Join the Canvas Conversation
Exploring Canvas patterns or building human-in-the-loop AI interfaces? I'd love to hear about your projects and exchange ideas with the community.
Share Your Implementation
If you build something with these patterns, consider sharing it! Your innovations can help evolve this approach.
$ claude mcp add canvas-callback \
-- python -m otcore.mcp_server <graph>