A minimal LangGraph example that powers an RPG-style chatbot. Each user turn is:
- summarized into a running campaign recap,
- classified into a message type (exploration, combat, or social interaction),
- routed to a specialized agent that responds in that mode.
- Structured classification with Pydantic (
MessageClassifier) - Persistent state across turns (messages, type, summary)
- Conditional routing to specialized agents
- Concise session summary updated every turn
- Python 3.13+
- A Google Gemini API key (set in
.envasGEMINI_API_KEY)
# from the repo root
uv syncCreate a .env file in the project root:
GEMINI_API_KEY=YOUR_KEY_HEREpython src/main.pyType messages at the prompt. Use exit to quit.
summarize_turnmaintains a compact session summaryclassify_messageuses structured output to pick a message typeroutersends the flow to one of three agents- Each agent responds with domain-specific guidance
.
├── src/
│ └── main.py
├── pyproject.toml
└── README.md
- The model is set to
gemini-2.5-flashinsrc/main.py. Adjust if needed. - The summary is printed each turn; comment it out if noisy.