Prompt chaining is a Agentic pattern where multiple LLM (Large Language Model) calls are linked together in a sequence. Each step performs a specific task, and the output from one step becomes the input for the next.
It can also include custom code between steps to guide or transform the data. This approach helps complex problems into manageable parts dividing into small pieces, allowing each prompt for better results. While it's called a "workflow," it can still include some autonomy, like letting the first LLM decide the topic that the rest of the chain works on.
○ Input Received→ Input to the workflow.
○ LLM → First model processes the input.
○ CODE → Optional custom logic or transformation.
○ LLM2 → Second model processes the transformed data.
○ LLM3 → Third model processes the transformed data.
○ Out → Final output.

%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BfillColor%3D%2399CCFF%3B%22%20value%3D%22%F0%9F%93%9D%20Input%20Received%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2261%22%20width%3D%22110%22%20x%3D%22210%22%20y%3D%221488%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20edge%3D%221%22%20parent%3D%221%22%20source%3D%224%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3BentryX%3D0.5%3BentryY%3D0%3BentryDx%3D0%3BentryDy%3D0%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3B%22%20target%3D%225%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%224%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3B%22%20value%3D%22%F0%9F%A4%96%20LLM%201%3A%20Initial%20Reasoning%20%2F%20Planning%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2283%22%20width%3D%22151%22%20x%3D%22419%22%20y%3D%221477%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%225%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BfillColor%3D%2399CCFF%3B%22%20value%3D%22%F0%9F%A7%A0%20CODE%3A%20Optional%20Logic%20%2F%20Transformation%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2280%22%20width%3D%22131%22%20x%3D%22429%22%20y%3D%221635%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%226%22%20edge%3D%221%22%20parent%3D%221%22%20source%3D%2212%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3BentryX%3D0.5%3BentryY%3D0%3BentryDx%3D0%3BentryDy%3D0%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BexitX%3D0.636%3BexitY%3D1.043%3BexitDx%3D0%3BexitDy%3D0%3BexitPerimeter%3D0%3B%22%20target%3D%229%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%227%22%20edge%3D%221%22%20parent%3D%221%22%20source%3D%228%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3B%22%20target%3D%2212%22%20value%3D%22%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%228%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3B%22%20value%3D%22%F0%9F%A4%96%20LLM%202%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2270%22%20width%3D%22108%22%20x%3D%22650%22%20y%3D%221640%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%229%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BfillColor%3D%23CCE5FF%3B%22%20value%3D%22%F0%9F%93%A4%20Final%20Output%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2260%22%20width%3D%22140%22%20x%3D%22850%22%20y%3D%221780%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2210%22%20edge%3D%221%22%20parent%3D%221%22%20source%3D%222%22%20style%3D%22startArrow%3Dnone%3BendArrow%3Dblock%3BexitX%3D1%3BexitY%3D0.5%3BentryX%3D0%3BentryY%3D0.5%3Brounded%3D0%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BedgeStyle%3DorthogonalEdgeStyle%3B%22%20target%3D%224%22%20value%3D%22%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2211%22%20edge%3D%221%22%20parent%3D%221%22%20source%3D%225%22%20style%3D%22startArrow%3Dnone%3BendArrow%3Dblock%3BexitX%3D1%3BexitY%3D0.5%3BentryX%3D0%3BentryY%3D0.5%3Brounded%3D0%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BedgeStyle%3DorthogonalEdgeStyle%3BentryDx%3D0%3BentryDy%3D0%3B%22%20target%3D%228%22%20value%3D%22%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2212%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3B%22%20value%3D%22%F0%9F%A4%96%20LLM%203%3A%20Final%20Reasoning%20%2F%20Synthesis%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2270%22%20width%3D%22140%22%20x%3D%22830%22%20y%3D%221640%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E Routing Agentic pattern:
%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BfillColor%3D%2399CCFF%3B%22%20value%3D%22%F0%9F%93%9D%20Input%20Received%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2261%22%20width%3D%22110%22%20x%3D%22210%22%20y%3D%221488%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20edge%3D%221%22%20parent%3D%221%22%20source%3D%224%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3BentryX%3D0.5%3BentryY%3D0%3BentryDx%3D0%3BentryDy%3D0%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3B%22%20target%3D%225%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%224%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3B%22%20value%3D%22%F0%9F%A4%96%20LLM%201%3A%20Initial%20Reasoning%20%2F%20Planning%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2283%22%20width%3D%22151%22%20x%3D%22419%22%20y%3D%221477%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%225%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BfillColor%3D%2399CCFF%3B%22%20value%3D%22%F0%9F%A7%A0%20CODE%3A%20Optional%20Logic%20%2F%20Transformation%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2280%22%20width%3D%22131%22%20x%3D%22429%22%20y%3D%221635%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%226%22%20edge%3D%221%22%20parent%3D%221%22%20source%3D%2212%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3BentryX%3D0.5%3BentryY%3D0%3BentryDx%3D0%3BentryDy%3D0%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BexitX%3D0.636%3BexitY%3D1.043%3BexitDx%3D0%3BexitDy%3D0%3BexitPerimeter%3D0%3B%22%20target%3D%229%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%227%22%20edge%3D%221%22%20parent%3D%221%22%20source%3D%228%22%20style%3D%22edgeStyle%3DorthogonalEdgeStyle%3Brounded%3D0%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BorthogonalLoop%3D1%3BjettySize%3Dauto%3Bhtml%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3B%22%20target%3D%2212%22%20value%3D%22%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%228%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3B%22%20value%3D%22%F0%9F%A4%96%20LLM%202%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2270%22%20width%3D%22108%22%20x%3D%22650%22%20y%3D%221640%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%229%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BfillColor%3D%23CCE5FF%3B%22%20value%3D%22%F0%9F%93%A4%20Final%20Output%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2260%22%20width%3D%22140%22%20x%3D%22850%22%20y%3D%221780%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2210%22%20edge%3D%221%22%20parent%3D%221%22%20source%3D%222%22%20style%3D%22startArrow%3Dnone%3BendArrow%3Dblock%3BexitX%3D1%3BexitY%3D0.5%3BentryX%3D0%3BentryY%3D0.5%3Brounded%3D0%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BedgeStyle%3DorthogonalEdgeStyle%3B%22%20target%3D%224%22%20value%3D%22%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2211%22%20edge%3D%221%22%20parent%3D%221%22%20source%3D%225%22%20style%3D%22startArrow%3Dnone%3BendArrow%3Dblock%3BexitX%3D1%3BexitY%3D0.5%3BentryX%3D0%3BentryY%3D0.5%3Brounded%3D0%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3BedgeStyle%3DorthogonalEdgeStyle%3BentryDx%3D0%3BentryDy%3D0%3B%22%20target%3D%228%22%20value%3D%22%22%3E%3CmxGeometry%20relative%3D%221%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%2212%22%20parent%3D%221%22%20style%3D%22whiteSpace%3Dwrap%3BstrokeWidth%3D2%3Bsketch%3D1%3BhachureGap%3D4%3Bjiggle%3D2%3BcurveFitting%3D1%3BfontFamily%3DArchitects%20Daughter%3BfontSource%3Dhttps%253A%252F%252Ffonts.googleapis.com%252Fcss%253Ffamily%253DArchitects%252BDaughter%3B%22%20value%3D%22%F0%9F%A4%96%20LLM%203%3A%20Final%20Reasoning%20%2F%20Synthesis%22%20vertex%3D%221%22%3E%3CmxGeometry%20height%3D%2270%22%20width%3D%22140%22%20x%3D%22830%22%20y%3D%221640%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E
Routing is a design pattern where an input first goes to a router LLM, which decides which specialized model should handle the task. Each specialist LLM is optimized for different functions. The router classifies the input and directs it to the best-fit model, enabling separation of concerns. While it follows a workflow, the router introduces some autonomy by making decisions within guardrails.
Flow Steps:
○ Input Received - A user query or task enters the system.
○ Router LLM - Analyzes Task - The router examines the input to determine its nature
○ Classification & Decision - Based on task type and complexity, the router selects the best specialist model
○ Route to Specialist -The chosen model processes the task using its expertise.
○ Out - The result is sent back to the router or to the user, maintaining workflow consistency.
Notes: Routing – An LLM routes tasks to the most suitable expert LLM.
Parallelization Agentic pattern:
Parallelization is a design pattern where code (not an LLM) splits a task into multiple parts, sends them to several LLMs to run concurrently, and then uses code to aggregate the results—either combining different subtasks or averaging repeated runs of the same task.
Flow Steps:
parallelization pattern diagram:
○ Code: Breaks the main task into subtasks.
○ Task: Represents the split workload.
○ LLMs: Multiple models process subtasks in parallel.
○ Aggregator: Collects and combines results (e.g., stitching, averaging).
Notes: Parallelization – Code splits tasks and sends them to multiple LLMs in parallel; results are aggregated.
Orchestrator-Worker Agentic pattern:
An LLM acts as the orchestrator, breaking down a complex task into smaller steps, assigning them to other LLMs (workers), and then synthesizing their outputs into a final result.
Flow Steps:
Orchestrator-Worker pattern diagram:
○ Top LLM: Acts as the orchestrator.
○ Orchestrator: Breaks down the complex task into smaller subtasks.
○ Worker LLMs: Execute subtasks in parallel.
○ Output: Orchestrator synthesizes results into a final answer.
Notes: Orchestrator-Worker – An LLM orchestrates task breakdown and synthesis, assigning subtasks to other LLMs.
Evaluator-Optimizer Agentic attern:
One LLM generates a solution, and another LLM evaluates it. If accepted, the output is finalized; if rejected, feedback is sent back to the generator for improvement, creating a feedback loop to enhance accuracy and reliability.
Flow Steps:
Evaluator-Optimizer pattern diagram:
○ Generator LLM: Creates the initial solution.
○ Evaluator LLM: Validates the solution.
- If accepted, it goes to Output.
- If rejected, feedback loops back to the Generator for refinement.
○ This cycle continues until the solution meets standards.
Notes: Evaluator-Optimizer – One LLM generates, another evaluates; feedback loop improves accuracy.
Legends:
- Red color shows LLM enagment no manaual code
- Blue color shows Manaul enagment and it does have manaual code
Use case scenarios for each design pattern:
1. Parallelization
Scenario:
A company needs to summarize three different research papers quickly.
○ Code splits the task into three subtasks (one per paper).
○ Sends each subtask to a different LLM in parallel.
○ Aggregator combines the summaries into a single consolidated report.
2. Orchestrator
Scenario:
A user asks for a comprehensive market analysis.
○ Orchestrator LLM breaks the task into subtasks:
- Competitor analysis
- Customer trends
- Pricing strategy
○ Assigns each subtask to specialized LLMs.
○ Orchestrator then synthesizes all outputs into a final report.
3. Evaluator
Scenario:
Generating legal contract clauses for compliance.
○ Generator LLM drafts the clause.
○ Evaluator LLM checks for compliance and clarity.
○ If rejected, evaluator provides feedback → generator revises.
○ Loop continues until evaluator approves.
4. Routing
tools are modular and can be dynamically selected by the AI agent based on the request.