Section 3: The Agentic Leap
An agentic system places an LLM inside a model-driven control loop: observing state, selecting tools, and iterating toward a goal. Crucially, more autonomy is not always better—always choose the simplest pattern that solves the problem reliably.
3.1 Single Call vs. Workflow vs. Controlled Agent
| Design Pattern | Control Flow | Best Use Cases | Trade-Offs |
|---|---|---|---|
| Single LLM Call | One prompt → one response | Summarization, extraction, classification, drafting | Fastest, cheapest, lowest variance; cannot look up live data or take actions |
| Deterministic Workflow | Code-defined sequence/branches of LLM & tool calls | Fixed RAG Q&A, multi-step document pipelines, known SOPs | Predictable, easy to test and audit; brittle when inputs require dynamic paths |
| Controlled Agent Loop | LLM dynamically selects tools/steps within strict bounds | Open-ended research, multi-tool troubleshooting, coding tasks | Flexible and adaptive; higher latency/cost, harder to evaluate, needs strong guardrails |
3.2 Common Agentic Architecture Patterns
- Tool-Use Loop (ReAct-style): The model alternates between reasoning about state, calling read/write tools, and incorporating observations until ready to answer.
- Router Pattern: A fast classifier or LLM inspects the request and dispatches it to a specialized prompt, retrieval index, or sub-workflow.
- Planner-Executor: A strong reasoning model drafts an explicit multi-step plan; cheaper executor calls carry out individual steps and report status back.
- Supervisor-Worker (Multi-Agent): A coordinator delegates scoped subtasks to specialized worker agents (e.g., Docs Researcher, SQL Analyst) with isolated toolsets. Use sparingly—multi-agent handoffs add latency and coordination bugs.
- State Machine / Graph: Explicit nodes and edges constrain legal transitions, blending agent flexibility inside nodes with deterministic guardrails between nodes.
- Human-in-the-Loop (HITL) Approval: Execution pauses at a checkpoint before any irreversible, high-risk, or external-facing action, resuming only after explicit human sign-off.
3.3 Interoperability Protocols: MCP vs. A2A
Two complementary open protocols standardize how agents connect to tools and to each other:
- Model Context Protocol (MCP): Introduced by Anthropic, MCP standardizes how an AI application connects to external tools, data sources, and prompt templates exposed by MCP servers. Think of MCP as "USB-C for agent-to-tool and agent-to-data integration" (vertical integration).
- Agent-to-Agent (A2A) Protocol: Introduced by Google with ecosystem partners, A2A standardizes how independent, opaque agents discover each other's capabilities (via Agent Cards), exchange tasks, stream updates, and collaborate across organizational or framework boundaries (horizontal delegation).
3.4 Orchestration Frameworks vs. Plain Application Code
- LangChain: Modular abstractions for model providers, retrievers, prompt templates, and tool bindings. Helpful for rapid prototyping, though heavy abstractions can obscure raw prompts.
- LangGraph: Models agent workflows as explicit stateful graphs with cycles, checkpointing, streaming, and native HITL interrupts—well-suited for complex, auditable state machines.
- When Plain Code Wins: For a single tool-calling loop or a 3-step RAG workflow, 80 lines of plain Python or TypeScript with the provider's official SDK plus Pydantic/Zod is often clearer, faster to debug, and immune to framework churn.
3.5 State, Memory, Budgets, and Recovery
- Short-Term vs. Long-Term Memory: Short-term memory is the active thread/state object; long-term memory persists preferences or facts externally—always scope per user/tenant and support deletion.
- Hard Stopping Conditions & Budgets: Enforce maximum loop iterations (e.g., max 6 steps), maximum token spend, wall-clock timeouts, and duplicate-tool-call detection.
- Partial Failure Recovery: Design write tools to be idempotent (with idempotency keys), checkpoint state after each step, and return clean error messages so retries never duplicate side effects.