The workflow is aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/vrashmanyu605-eng/Langchain_Interview_Multi_Agents_Flow/llms.txt
Use this file to discover all available pages before exploring further.
StateGraph where every node is a plain Python function and routing decisions are made by the supervisor agent at runtime. Adding a new specialist agent follows a consistent four-file pattern: create the agent function, extend HiringState with its output field, register the node and its edges in workflow.py, and tell the supervisor about it in agents_info. Because the supervisor reads the registry at runtime to decide routing, no changes to the supervisor’s core logic are needed — only its configuration dict.
Add a new agent
Create the agent function
Create a new Python file in the Keep each agent focused on a single responsibility and a single output field. The supervisor routes more reliably when agents have narrow, well-defined outputs.
agents/ directory. Follow the same structure as the existing agents: import llm, define a function that accepts state, build a prompt using f-string interpolation, invoke the LLM, and return a dict with a single output key.Add the output field to HiringState
Open
graph/state.py and add the new field to the HiringState TypedDict. Because total=False is set on the class, all fields are implicitly optional — you do not need to wrap the type in Optional.Register the node and edges in workflow.py
Open Then add the new agent’s key to the routing dict inside
graph/workflow.py. Import your new agent, add it as a node, and add an edge that returns control to the supervisor after the agent completes.add_conditional_edges:Register the agent with the supervisor
Open The supervisor checks
agents/supervisor.py and add an entry to the agents_info dict. The requires list must match existing field names in HiringState. The provides list must match the key your agent returns.requires against available state data before routing. If any required field is missing, the supervisor will route to a different agent first.Print the new agent’s output in main.py
To see the output in the streaming loop, add a branch to the inner loop inmain.py:
Removing an agent
To remove an existing agent from the workflow:- Delete or comment out the
graph.add_node(...)andgraph.add_edge(...)lines for that agent inworkflow.py. - Remove the agent’s key from the routing dict in
add_conditional_edges. - Remove the agent’s entry from
agents_infoinsupervisor.py. - Remove the agent’s output field from
HiringStateingraph/state.py. - Remove any references to that field in downstream agents that previously read it.
jd_analysis when matching requires jd_analysis), the supervisor will be unable to route to matching and will eventually route to finished after detecting the missing input.
After adding a new agent, test it with a simple prompt first before integrating into the full pipeline. Call the agent function directly with a hand-crafted state dict and inspect the output to confirm it returns valid JSON before wiring it into the graph.