2.5 KiB
Planning Agent – LangGraph Demo
What this project does
This repository contains a minimal, fully‑working example of a LangGraph agent that first plans a task into discrete steps and then executes those steps one by one. The goal is to satisfy the exam assignment “Экзамен: Планирующий агент” from the BroJS course.
The agent:
- Uses an LLM (BroJS GPT‑OSS‑20B) to split a natural‑language task into a numbered list of actions.
- Executes each action sequentially – in this demo we simply echo the step, but you can replace it with real tool calls.
- Stops when all steps are finished and prints the accumulated results.
The code is intentionally simple yet fully typed, documented and contains three example tasks that run automatically when executing python main.py.
File structure
├── main.py – entry point with LangGraph implementation
├── requirements.txt – Python dependencies
└── README.md – this documentation
Installation
# Create a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # Windows: .\.venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Make sure you have the JOURNAL_MCP_PAT environment variable set – it is required by the BroJS LLM endpoint.
Running the demo
python main.py
You will see three tasks processed sequentially, each showing:
- The original task description
- A numbered plan generated by the LLM
- Execution results for every step
Feel free to modify examples in main.py or replace the execution node with real tool calls.
How it works (high‑level)
- State – a TypedDict holding
task, optionalplan,current_step, and accumulatedresults. - Planning node – sends the task to the LLM, expects JSON output
{"plan": ["step 1", "step 2", ...]}. - Execution node – takes the next step from
plan, records a dummy result. - Conditional edge – loops until all steps are processed.
- The graph is compiled and run with
agent.streamto capture intermediate states for pretty printing.
Extending
- Replace the execution logic with calls to real tools (e.g., web search, calculator).
- Add a verification node that asks the LLM if the step succeeded before moving on.
- Persist state using LangGraph checkpoints for long‑running tasks.
Author: Kirill Kutlahmetov – student of BroJS course (course ID: 698b49da77cb6d4d2e43ce78)