In Day 17, we improved our recommendation system by introducing LLM-based reranking with Qwen and vLLM. However, our workflow still followed a relatively fixed sequence, where product retrieval, ranking, and recommendation were executed in a predefined order. As recommendation tasks become more complex, a single agent may need to handle several responsibilities, including searching for products, evaluating user preferences, retrieving additional information, and deciding what to do next. Today, we will explore how to build a multi-agent recommendation system with LangGraph by introducing a Supervisor Agent that coordinates multiple specialized agents. Each agent will focus on a specific responsibility, while the supervisor manages task delegation and determines when the system has enough information to produce a final recommendation.
Target
Today, our goal is to transform the recommendation system from a single-agent workflow into a multi-agent architecture using LangGraph.
Instead of assigning every task to one agent, we will introduce a Supervisor Agent that coordinates specialized agents responsible for product retrieval, information lookup, and ranking.
By the end of this article, we aim to:
1. Build a Supervisor Agent to coordinate the recommendation workflow.
2. Implement specialized Retrieval and Ranking Agents.
3. Enable agents to exchange information through LangGraph's shared state.
4. Use Qwen and vLLM to support agent decision-making.
5. Generate personalized recommendations through coordinated agent execution.
User Request
|
v
LangGraph Agent
|
v
Choose Next Action
/ | \
/ | \
v v v
FAISS Product Ask for
Retrieval Lookup Clarification
\ | /
\ | /
v v v
Agent Evaluation
|
v
Need More Data?
/ \
Yes No
| |
v v
Call Tool Qwen Reranking
| |
+------------+
|
v
Final Recommendations
Setting up the server:
vllm serve Qwen/Qwen2.5-7B-Instruct \
--host 127.0.0.1 \
--port 8000 \
--max-model-len 8192
Implement the multi-agent system:
@tool
def call_ranking_agent(
query: str,
candidate_ids: list[str],
) -> str:
"""Delegate candidate evaluation to the ranking agent."""
### Reject unknown IDs before passing them to the agent.
valid_ids = [
pid for pid in candidate_ids
if pid in product_lookup
]
if not valid_ids:
return "No valid product candidates."
result = ranking_agent.invoke({
"messages": [{
"role": "user",
"content": (
f"User requirements: {query}\n"
f"Candidate IDs: {valid_ids}\n"
"Look up these products and rank them."
),
}]
})
return str(result["messages"][-1].content)
Conclusion:
Today, we extended our recommendation system from a fixed retrieval-and-reranking pipeline into a multi-agent architecture using LangGraph. Instead of assigning every responsibility to a single workflow, we introduced a Supervisor Agent that coordinates specialized Retrieval and Ranking Agents.
The key takeaway is that multi-agent systems are not simply about adding more LLM calls. They are about dividing complex responsibilities into coordinated, independently manageable components.
Reference:
1. LangChain — Multi-Agent Systems
2. LangChain — Subagents
3. vLLM — OpenAI-Compatible Server