Zero Labs
Industry News / AI

Agent Control Patterns — Part 1: How Control Flow Shapes LLM Behavior

Source · Towards AI By Vahe Sahakyan

From the publisher’s feed, collected in the ZeroLabs newsroom.

Most conversations about AI agents focus on the model: bigger models, better prompts, more parameters.But in practice, two systems built on the same language model can behave in completely different ways. One breaks easily under edge cases. Another handles complex tasks reliably. A third scales as requirements grow, while a fourth starts failing as soon as the workflow becomes slightly complicated.The difference is determined primarily by the control structure.Execution order, branching logic, parallel steps, task breakdown, and stop conditions are not small technical details. They are design choices. And those choices determine how a system behaves when it runs — whether it works reliably, scales, or breaks.This article begins a four-part exploration of agent control patterns: the structural strategies that shape how LLM systems actually operate.Before we talk about reflection, adaptive reasoning, or tool-driven exploration, we need to understand something more fundamental: how execution is organized.Why Most LLM Systems Aren’t Really AgentsLarge language models are powerful. But a powerful model does not automatically produce an intelligent system.Most LLM applications today are structured workflows built around model calls: a prompt is sent, a response is returned, and the system proceeds according to predefined logic.What differentiates one system from another is rarely the model itself. It is the control structure that governs how the model is used.Execution order, branching rules, parallel paths, state updates, and termination conditions are not minor implementation details. They are architectural decisions. And those decisions determine:What the system can doHow reliably it behavesHow it scales under complexityHow it fails when assumptions breakTwo systems built on the same LLM can behave very differently if their control logic differs. One may follow a fixed linear sequence. Another may classify and route requests. A third may execute branches in parallel. A fourth may generate its task structure at runtime.The model itself can remain the same. What changes is the control structure — and that structure shapes what the system can actually do.This is the main idea of this series: agent capability depends more on control structure than on model sophistication.In this first article, we examine four foundational control flow patterns that shape modern LLM systems:Sequential executionConditional routingParallelizationOrchestrationThese patterns do not make the model smarter. They make the system structured. And that structure is what allows the system to behave like an agent.What Is a Control Pattern?A control pattern defines how execution is organized in an LLM-based system. It defines:Order — which step runs first and what followsBranching — whether execution splits based on a conditionConcurrency — whether tasks run sequentially or in parallelState transitions — how intermediate results are stored and updatedTermination — when the system stopsIn modern LLM systems, this structure is typically expressed as a graph:Nodes represent processing steps.Edges define how control moves between them.State carries information across steps.This graph represents how the system is structured. The model produces outputs, and the control pattern decides what happens next.To make this concrete, consider the same LLM used in different systems.In one system, it may be called three times in a fixed linear sequence.In another, it may classify the input and route it to a specialized branch.In a third, it may run several branches in parallel and merge the results.The model itself can stay the same. What changes is how the system is structured.A model produces responses. A control pattern defines how those responses are used.When we talk about an “agent,” we often focus on the model. But much of what looks like intelligent or adaptive behavior actually comes from how the system is organized.Control patterns are not about writing better prompts. They are about structuring the work.Pattern 1 — Sequential (Prompt Chaining)The Sequential Pattern — often called prompt chaining — organizes execution as a linear pipeline. Each step depends on the output of the previous one.Control flows in a single direction:Step A → Step B → Step C → ENDThere is no branching, no concurrency, and no dynamic task creation. The system moves through predefined stages in order.This pattern breaks a complex task into smaller steps. Each LLM call builds on the result of the previous one.When It Works WellSequential control works best when a task can be broken into clear steps.Consider a blog generation workflow:Generate an outline from a topicExpand the outline into a draftPolish the draft for clarity and styleEach step builds on the previous one. The structure mirrors a typical writing process: plan → draft → revise.Because each model call focuses on a specific task, the system:Reduces prompt overloadImproves coherenceAllows intermediate checksThe improvement does not come from making the model smarter. It comes from breaking the work into smaller steps. By narrowing the focus at each stage, the system produces clearer and more consistent results.Architectural CharacteristicsSequential control has three main characteristics.1. Linear topologyExecution moves along fixed edges:workflow.add_edge("generate_outline", "generate_draft")workflow.add_edge("generate_draft", "polish_post")workflow.add_edge("polish_post", END)There is only one valid execution path.2. Accumulating stateThe state grows as the workflow moves forward:class BlogState(TypedDict): topic: str outline: str draft: str final_post: strEach node reads the existing state and appends new fields.3. Single-path determinismOnce execution starts, the path cannot change. The system cannot skip steps, try different options, or go back and adjust earlier decisions. The order is fixed.Failure ModesBecause the flow is strictly linear, errors move forward through the system.If the outline is weak, the draft builds on that weakness. The final polish step can improve wording, but it cannot fix a poor structure created at the beginning.Sequential systems also struggle when:The task becomes more complexEarly decisions need to be changedDifferent types of requests require different handlingThe structure provides no way to branch or correct earlier steps.Sequential control works well for predictable, step-by-step workflows. But it cannot adapt once the process begins — and that limitation comes from the structure, not the model.Pattern 2 — Routing (Conditional Control)The Routing Pattern introduces conditional branching into control flow.Instead of executing a fixed sequence, the system first evaluates the input and then selects one execution path among several alternatives.Structurally, it looks like this:START → Router → {Path A | Path B} → ENDThe router does not complete the task. Its only job is to decide which branch should handle the request. The flow is no longer linear — it depends on the input.This is the first step beyond a simple linear pipeline.Structural InsightRouting separates the decision about what to run from the actual execution.Consider a simple system that handles different types of user requests. A user might submit:“Solve 2x + 3 = 7”“Summarize the main arguments of AI ethics”These requests need different handling.Instead of processing everything the same way, the system first uses a router. The router looks at the input and assigns it to a category:“math” for equation solving“text” for summarizationExecution then continues based on that decision.START → route_query ├── math_solver └── text_summarizerThis decision is handled using a conditional edge:workflow.add_conditional_edges( "route_query", intent_router, { "math_solver": "math_solver", "text_summarizer": "text_summarizer" })The router determines the next node:def intent_router(state: QueryState) -> str: if state["intent"] == "math": return "math_solver" elif state["intent"] == "text": return "text_summarizer" else: return ENDUnlike sequential control, there is no fixed path. The system chooses a different path depending on the input.The same model may run in both branches. What changes is how the system is organized and which branch handles the request.When It Works WellRouting works well when different types of tasks need different handling.In the example above:A math problem requires symbolic reasoning.A text request requires summarization.If both were handled by a single chain, the prompt would become overloaded and the logic would get messy. This increases the chance of errors.Routing keeps responsibilities separate. Each branch can be tuned for its specific task.It also makes the system easier to extend: new branches can be added without changing the existing ones.Failure Modes and Structural RisksRouting introduces a new risk: it depends on correct classification.The entire execution path depends on a single decision. If the router gets it wrong:A math question may be sent to the summarizer.A text request may be treated like an equation.Because the decision happens early, the mistake affects everything that follows.Other risks include:1. A single point of failure The router becomes critical. If it makes the wrong call, the rest of the system cannot recover.2. Too many routes Adding many branches can make the system hard to understand and maintain.3. No reconsideration Once a request is routed, the system usually does not revisit that decision. There is no built-in way to correct it.Routing adds flexibility compared to a simple linear flow, but it also makes the system more complex. The system no longer follows one fixed path — it depends on the input.Pattern 3 — ParallelizationThe Parallelization Pattern runs multiple independent tasks at the same time instead of one after another.Instead of selecting a single path (as in routing), the system splits into multiple branches and later combines the results.Structurally, it looks like this:START ├── Branch A ├── Branch B └── Branch C ↓ Merge ↓ ENDAll branches receive the same initial context and execute independently. No branch depends on the output of another.This pattern is appropriate when subtasks are independent and can be processed simultaneously.Architectural BenefitConsider a response generation system where a user submits:“Describe a smartwatch for marketing.”Instead of producing a single version, the system generates three stylistic variants:A formal product descriptionA casual, lifestyle-focused versionA technical, specification-oriented versionEach variant is created independently from the same input. No version depends on the others, and there is no required order.The graph then splits into multiple branches from the starting node:workflow.add_edge(START, "formal_variant")workflow.add_edge(START, "casual_variant")workflow.add_edge(START, "technical_variant")Each node updates shared state:class VariantState(TypedDict): prompt: str variants: Annotated[List[str], operator.add] combined: strAfter all branches complete, execution converges:workflow.add_edge("formal_variant", "aggregate")workflow.add_edge("casual_variant", "aggregate")workflow.add_edge("technical_variant", "aggregate")Unlike routing:All branches execute.The number of branches is fixed at design time.No classification determines path selection.The main benefits are speed and output variety:Independent tasks do not wait for each other.Multiple outputs can be compared or combined.The total runtime depends on the slowest branch, not the sum of all branches.Parallelization changes when work happens, not what work is done. The model stays the same — the difference is that tasks run at the same time.The Aggregation ChallengeParallelization introduces a new challenge: merging results correctly.Because multiple branches update the same state, the system needs a clear way to combine their outputs. Reducers handle this:variants: Annotated[List[str], operator.add]Without a defined merge strategy:Results may overwrite each other.Output ordering may become inconsistent.Partial updates may be lost.Parallelization does not automatically increase token usage or cost. If you need three outputs, you will still make three model calls — whether they run one after another or at the same time.What changes is execution time and system complexity. Running tasks in parallel affects latency, infrastructure load, and how results are combined.Sequential control focuses on ordering. Parallel control focuses on merging.That is the key difference.Pattern 4 — Orchestration (Planner–Worker)Orchestration introduces a fundamentally different control strategy: the execution plan is generated at runtime.Unlike previous patterns, the number of tasks is not fixed in advance. A planner node analyzes the input, decomposes it into structured subtasks, and dynamically assigns work to specialized worker nodes.Structurally:START → Planner ↓ Dynamic Task List ↓ Worker(s) (N instances) ↓ Aggregation ↓ ENDThe planner does not merely classify input. It generates a task structure. The number of workers depends on what the planner produces.This is the first control pattern where the structure is decided while the system is running.Structural Difference from RoutingRouting selects one predefined branch. Orchestration creates new branches.In routing:All possible paths are known at design time.Exactly one branch is executed.In orchestration:The planner determines how many subtasks exist.The graph expands accordingly.Multiple workers are created at runtime.Routing answers:“Which path should run?”Orchestration answers:“What work must be done?”Routing selects from a fixed graph. Orchestration constructs part of the graph while the system is running.Example: Structured Task DecompositionConsider a travel itinerary workflow.A user submits:“Plan a 3-day trip to Paris.”Instead of generating the final itinerary directly, the system first breaks the request into structured segments — one for each day.A minimal schema might look like:class Segment(BaseModel): day: int location: str activities: List[str]The planner generates this structured task list:def orchestrator(state: TravelState) -> TravelState: segments_output = planner_pipe.invoke({"request": state["request"]}) return {"segments": segments_output.segments}At this point, no itinerary has been written. The system has only generated a plan of work. Planning and execution are now explicitly separated.The important shift is that the number of workers is decided at runtime.from langgraph.types import Senddef assign_workers(state: TravelState): return [Send("day_planner_worker", {"segment": s}) for s in state["segments"]]The workflow turns those runtime instructions into N worker instances:workflow.add_conditional_edges("orchestrator", assign_workers, ["day_planner_worker"])If the planner outputs three segments, three workers run. If it outputs seven, seven workers run.That is what makes orchestration different: the task structure is created while the system is running.Architectural CostOrchestration increases structural complexity significantly.It introduces four major constraints:1. Structured planning requirements The planner must produce reliable, machine-parseable outputs. Free-form text is insufficient. Schemas and validation become mandatory.2. Shared state coordination Workers must append results safely into shared state. Reducers are required to prevent overwrites.3. Synchronization and aggregationAfter splitting into multiple branches, the system must combine the results correctly. How those results are merged becomes an important design decision.4. Increased reasoning surface The planner becomes a central point of correctness. If decomposition is flawed, all downstream work inherits that flaw.Unlike parallelization — where branches are independent transformations — orchestration depends on accurate task decomposition.The system’s correctness now depends on:How well the planner understands scopeHow reliably structure is generatedHow safely workers aggregate resultsOrchestration still assumes that the task can be decomposed before execution begins.It is powerful because it enables runtime task construction. But it replaces fixed control graphs with dynamically constructed ones. That shift is not incremental — it transforms the topology of the system.Pattern Comparison TableThe four control patterns differ primarily in how they structure execution. What changes across them is not the model, but the topology that governs how work unfolds.ObservationsEach pattern introduces a new dimension of structural flexibility:Sequential defines a single deterministic path.Routing introduces conditional branching, but from a predefined set of options.Parallelization executes multiple predefined branches concurrently.Orchestration generates the execution plan itself at runtime.The structural progression can be summarized as:Linear → Conditional → Concurrent → DynamicThis progression does not reflect increasing model intelligence.It reflects increasing structural flexibility.And structural flexibility is what gives LLM systems the appearance of agency.Transition to ReflectionThe patterns we’ve covered so far change how execution is organized. They define how work moves through the system, how tasks are split, and how results are combined. But they do not improve the model’s reasoning.If a sequential chain produces a weak outline, the draft builds on that weakness. If a routed branch generates an incomplete answer, the system still moves forward. If parallel workers produce inconsistent outputs, they are still merged. If a planner breaks the task down poorly, all workers follow that plan.Control decides where work happens. It does not decide whether the result is correct.So far, each node produces output once, and that output is accepted as final for that step. There is no built-in way to question, revise, or improve the reasoning during execution.This is the limit of control flow alone.In the next article, we introduce a different idea: separating generation from evaluation so the system can review and refine its own output before continuing.Control shapes behavior.Reflection begins to improve quality.Agent Control Patterns — Part 1: How Control Flow Shapes LLM Behavior was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.