AgentLearn

Agentic patterns

Choose the simplest control flow that matches the task: a pipeline, a router, a bounded loop, or a coordinated workflow.

Architecture is a hypothesis

A fixed pipeline is often enough for policy Q&A: retrieve, answer, verify. A router may select shipping versus returns. A loop helps when the next action depends on an observation. Parallel work helps independent tasks but adds coordination and resource cost. These are design options, not a maturity ladder.

How it works

Make states and transitions explicit. Define what each stage consumes and produces, what can fail, and who owns retries. A verifier can catch some mistakes, but agreement between two models is not proof. Measure the full workflow under the same cases and budget before adopting a more elaborate pattern.

A concrete example

For a support request that asks both 'Where is my parcel?' and 'Can I return it?', independent read-only lookups can run together. Issuing a refund must wait for eligibility, identity, and approval. A dependency graph makes this distinction visible.

Apply it to your assistant

Add another intent and define its route explicitly. Before running the exercise, predict the result. Afterward, explain which assumption changed and add one case where the system should refuse, ask for clarification, or escalate.

All exercise inputs and outputs are deterministic teaching examples. No language model is called. Run the same idea against a versioned dataset before making a production claim.

Key takeaway

Use explicit dependencies and measured requirements to choose control flow.

JavaScript exercise: Agentic patterns · code experiment

Add another intent and define its route explicitly.

const routes = { shipping: ['lookupOrder', 'formatStatus'], returns: ['retrievePolicy', 'checkEligibility', 'draftAnswer'] };
const intent = 'returns';
for (const stage of routes[intent] || ['askClarification']) console.log('Next stage:', stage);
console.log('No write occurs in this read-only workflow.');

Knowledge check

When is parallel execution appropriate?

  1. Whenever more agents are available
  2. When subtasks are independent and their resource cost is acceptable
  3. Before authorization checks to save time
Answer and explanation

When subtasks are independent and their resource cost is acceptable

Parallelism helps independent work. Dependent actions and authorization must still occur in the required order.

Sources

  • LangGraph overview — LangChain, Living documentation. Graph-based orchestration, state, persistence, and long-running workflows.

Read this lesson as Markdown

Continue learning

  • Tools & function calling — A tool call is an untrusted request to application code. A schema describes the request; authorization determines whether it may run.
  • Memory systems — Memory is application-managed state. Decide what to remember, who may read it, and when it should expire.
  • Errors, retries & guardrails — A reliable agent distinguishes failures it can retry from failures that need a different decision or a human.
  • Agentic patterns — Choose the simplest control flow that matches the task: a pipeline, a router, a bounded loop, or a coordinated workflow.