A multi-agent LeetCode learning system built on Google ADK and A2A: parse a problem, decide whether it is already known, solve it with specialized agents, and persist the result into an Obsidian-backed knowledge base.
Don't just solve problems β learn patterns. Build your world model.
This repo is intentionally shaped as a learning system, not just a coding assistant:
- Hybrid orchestration: a policy layer chooses between cache reuse, similar-problem search, explanation, or a fresh solve
- Deterministic execution where it matters:
Parser -> Architect -> Coder -> Librarianfor new problems - Distributed agent ecosystem: each worker is available as an A2A service with its own Agent Card
- Developer tooling: ADK Web workspace, agent inspection CLI, health checks, and protocol-aware debugging
- Persistent memory: Obsidian + ChromaDB make the system stateful instead of disposable
I built this project to learn LeetCode more efficiently and to avoid treating every problem as a blank slate.
The idea is simple:
- break solving into specialized steps instead of one giant prompt
- reuse prior knowledge when a problem has already been solved
- search for similar problems and patterns before writing code from scratch
- persist clean notes, pattern links, and solution metadata for later review
- build a personal "world model" of algorithmic patterns over time
The goal is not only to get an answer. The goal is to get:
- a correct solution
- a pattern-level explanation
- a reusable note
- a growing map of what I already know and what I still need to practice
# First time only β copy and fill in your API key
copy .env.example .env
# Solve a problem (local mode, fast)
.\start.ps1
# Distributed A2A mode β opens agent server window, then interactive solver
.\start.ps1 -a2a
# Full dev mode β A2A servers + ADK Web UI + CLI solver
.\start.ps1 -dev
# Other commands
.\start.ps1 -stats # pattern mastery dashboard
.\start.ps1 -init # initialize vault + ChromaDB
.\start.ps1 -test # run test suite
.\start.ps1 -help # show all optionsDev mode opens 3 windows automatically:
- Window 1 β A2A agent servers with uvicorn logs per agent
- Window 2 β ADK Web UI at
http://localhost:8000using a curated.adk/apps/workspace- Window 3 β Interactive solver in the current terminal
Important: ADK Web only shows invocations started inside the browser UI. The terminal solver is useful for quick runs, but it does not automatically appear as an ADK Web invocation.
User
β
π Parser
β
π§ Policy Layer
βββ already_solved
βββ explain_existing
βββ search_similar
βββ solve_new
β
π§ Architect β π» Coder β π Librarian
The interesting part is not just that there are multiple agents, but that the system has two layers:
- a smart routing layer that decides whether to reuse knowledge or do new work
- a deterministic execution layer for the critical path when a fresh solve is needed
In distributed mode, the working agents run as independent A2A services with their own HTTP endpoints and Agent Cards. The orchestrator consumes them through RemoteA2aAgent.
What each box does:
ParserAgentextracts structured problem data from the raw LeetCode prompt: title, difficulty, constraints, examples, keywords, and data structures.A2APolicyAgentis the decision layer. It checks whether the problem is already known, whether similar problems exist, and whether the system should explain, reuse, or solve from scratch.search_vault_problemsis the semantic search tool over the existing knowledge base, used to find related solved problems and shared patterns.lookup_problem_noteis the exact-cache lookup tool, used to answer βhave we already solved this exact problem?βA2ARouteExecutoris the branch handoff point. If the policy decidessolve_new, it forwards execution into the deterministic solving workflow.A2ASolveWorkflowis the fixed execution path for new problems, kept sequential on purpose so the core solve flow is reliable and easy to debug.ArchitectAgentidentifies the best-fit algorithmic patterns for the parsed problem and can register new patterns when the existing registry is not enough.CoderAgentturns the chosen patterns into working Python solutions with complexity analysis and approach explanations.LibrarianAgentpersists the result into the vault, updates pattern notes and statistics, refreshes the dashboard, and makes the system stateful over time.
- Agent Card Discovery β Each agent exposes
/.well-known/agent-card.jsondescribing its capabilities - RemoteA2aAgent β The distributed orchestrator creates proxy agents pointing to each Agent Card URL
- A2A Protocol β Communication happens over HTTP using the standard A2A message format
- Hybrid Routing β the policy layer chooses the route;
solve_newdelegates to a deterministic remote workflow
| Agent | Port | Role |
|---|---|---|
| π Parser | 10001 | Extracts title, difficulty, constraints, data structures, keywords |
| π§ Policy | β | Chooses already_solved, solve_new, search_similar, or explain_existing |
| π§ Architect | 10002 | Identifies 1-3 algorithmic patterns with confidence scores |
| π» Coder | 10003 | Generates Python solutions with time/space complexity |
| π Librarian | 10004 | Writes Obsidian notes, updates pattern stats, manages knowledge graph |
| π― Orchestrator | β | Distributed ADK entrypoint that consumes A2A services via RemoteA2aAgent |
The individual worker services are wrapped with to_a2a() and expose their capabilities via Agent Card.
20+ algorithmic patterns with keywords, template code, and metadata. The system dynamically registers new patterns when the Architect discovers ones outside the core registry β the World Model grows as you solve more problems.
| Pattern | Category | Pattern | Category |
|---|---|---|---|
| Two Pointers | Array | Top K Elements | Heap |
| Sliding Window | Array | K-way Merge | Heap |
| Fast & Slow Pointers | Linked List | Dynamic Programming | DP |
| Merge Intervals | Array | Topological Sort | Graph |
| Cyclic Sort | Array | Monotonic Stack | Stack |
| In-place Linked List Reversal | Linked List | Union Find | Graph |
| BFS | Tree/Graph | Trie | String |
| DFS | Tree/Graph | Greedy | Optimization |
| Two Heaps | Heap | Modified Binary Search | Search |
| Backtracking | Recursion | Bitwise XOR | Bit Manipulation |
- Python 3.11+
- A Google Gemini API key (free tier works)
- Obsidian with the Dataview plugin (for the dashboard)
# Clone
git clone https://github.com/matnabru/leetcode-world.git
cd leetcode-world
# Create virtual environment
python -m venv .venv
.venv\Scripts\activate
# Install runtime dependencies
pip install -e .
# Optional but recommended for running tests and linting
pip install -e .[dev]
# Configure (add your GOOGLE_API_KEY)
copy .env.example .env
# Initialize vault structure + seed ChromaDB
.\start.ps1 --init# Local mode
python -m leetcode_world solve
python -m leetcode_world stats
python -m leetcode_world search "sliding window"
# A2A mode β Terminal 1
python -m leetcode_world serve
# A2A mode β Terminal 2
python -m leetcode_world solve-a2a
python -m leetcode_world agents # inspect live agent cards, health, and skills
python -m leetcode_world agents --json # export ecosystem snapshot as JSON
# ADK visual debugger
adk web .adk/appsThe curated ADK workspace exposes individual apps for parser, architect, coder,
librarian, pipeline, and orchestrator, so you can:
- chat with each agent directly
- paste a full problem into
orchestratorto inspect the distributed flow - compare the local
pipelinewith the distributedorchestrator - avoid ADK trying to index
Vault/,tests/, or other repo folders
The Vault/ directory (gitignored) is auto-created as your Obsidian vault:
Vault/
βββ LeetCode/
βββ Problems/
β βββ Two Sum.md
β βββ Container With Most Water.md
β βββ ...
βββ Patterns/
β βββ Two Pointers.md
β βββ Hash Map.md β dynamically discovered!
β βββ Sliding Window.md
β βββ ... (20+ pattern notes)
βββ Dashboard.md β Dataview-powered mastery dashboard
---
title: "Two Sum"
difficulty: Easy
date_solved: 2026-03-30
patterns: ["Hash Map", "Two Pointers"]
time_complexity: "O(n)"
space_complexity: "O(n)"
status: solved
---With [[backlinks]] connecting to pattern notes and similar problems.
.\start.ps1 --test
# or
python -m pytest tests/ -vTests covering the pattern registry, Obsidian tools, ChromaDB, agent configuration, tracing, and A2A server/launcher setup. No LLM calls required.
Install the optional dev dependencies first with pip install -e .[dev].
- ADK Web UI for browser-started sessions, event timelines, and per-agent debugging
- Agent Cards at each service's
/.well-known/agent-card.json - A2A inspection CLI via
python -m leetcode_world agents --json - Per-agent health checks in the launcher with named status output
- Custom trace module in
leetcode_world/tracing.pyfor JSON trace logging and future frontend observability work
For the clearest workflow:
- use ADK Web
orchestratorto watch the distributed flow - use ADK Web single-agent apps to inspect one worker at a time
- use the terminal CLI when you want a fast manual run
The project is designed around a repeatable learning loop:
- Paste a new problem.
- Check whether it already exists in the vault.
- If it does, review the existing explanation and patterns instead of re-solving blindly.
- If it does not, solve it through the full agent workflow.
- Save the result as a structured note connected to broader pattern knowledge.
- Use the vault and statistics to revisit weak areas on purpose.
That makes the system useful for:
- deliberate practice
- spaced review of solved problems
- identifying recurring patterns
- building intuition instead of only collecting accepted submissions
- Google ADK β Agent Development Kit for multi-agent orchestration
- A2A Protocol β Agent-to-Agent communication via
to_a2a()+RemoteA2aAgent - Gemini β LLM powering all agents (configurable via
GOOGLE_GENAI_MODEL) - ChromaDB β Local vector database for problem similarity search
- Obsidian β Knowledge management with
[[backlinks]]and Dataview - Rich β Beautiful CLI output
- Pydantic β Structured data validation
- Uvicorn β ASGI server for A2A agent services
MIT β see LICENSE for details.
Built by Mateusz Urbanek as a multi-agent system for learning LeetCode through pattern reuse, persistent notes, and inspectable workflows.
