Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: pub@towardsai.net
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab VeloxTrend Ultrarix Capital Partners Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Free: 6-day Agentic AI Engineering Email Guide.
Learnings from Towards AI's hands-on work with real clients.
Prompt to Protocol: Architecting Agent-Oriented Infrastructure for Production LLMs
Latest   Machine Learning

Prompt to Protocol: Architecting Agent-Oriented Infrastructure for Production LLMs

Last Updated on February 12, 2026 by Editorial Team

Author(s): Shreya Singhal

Originally published on Towards AI.

The “Chatbot Era” is dead. Here is how to navigate the microservices moment for AI and choose between LangGraph and AutoGen.

If you’ve spent the last few years building AI applications, you’ve probably hit the same wall I did.

About a year ago, my team was trying to scale a complex Retrieval-Augmented Generation (RAG) pipeline for a heavy-duty enterprise client. We spent weeks agonizing over prompt engineering, tweaking hyperparameters, and stuffing context windows. The flow was entirely linear: Input -> Retrieve -> Generate -> Output.

It worked beautifully in our notebooks. But in production? It was a nightmare.

Because LLMs are inherently stochastic, if the model hallucinated or dropped context at step three of a five-step DAG (Directed Acyclic Graph), the entire pipeline failed. There was no recovery mechanism. It became painfully obvious that prompts are not infrastructure.

We are currently living through what industry analysts are calling the “Microservices Moment” for AI. We are shifting away from probabilistic token generation toward deterministic workflow orchestration. We are moving from single, monolithic prompts to Agent-Oriented Infrastructure.

Prompt to Protocol: Architecting Agent-Oriented Infrastructure for Production LLMs

But when it comes time to actually build these cyclic, self-correcting systems, you run into the big architectural dilemma of 2026: How do you orchestrate them?

Having spent the last 8 years in distributed systems and the last few deep in LLM orchestration, I want to break down the two dominant paradigms right now i.e. Microsoft’s AutoGen and LangChain’s LangGraph, and how to think about them for production.

The Conversational Paradigm: AutoGen

AutoGen approaches multi-agent workflows through the lens of human-like conversation. Instead of defining strict programmatic paths, you define “Personas” (agents) and let them talk to each other to solve a problem.

It uses a message-passing architecture. You might set up a UserProxyAgent (acting on your behalf to execute code) and an AssistantAgent (writing the code).

from autogen import AssistantAgent, UserProxyAgent

# Defining the conversational agents
coder = AssistantAgent(
name="Senior_Developer",
llm_config={"model": "gpt-4o"}
)

executor = UserProxyAgent(
name="Code_Executor",
human_input_mode="NEVER",
code_execution_config={"work_dir": "build_dir"}
)

# Kicking off the orchestration
executor.initiate_chat(
coder,
message="Refactor this legacy Python script for PEP-8 compliance and write unit tests."
)

The Reality in Production: AutoGen is incredibly intuitive. If you understand how a dev team talks in a Slack channel, you understand AutoGen. It is phenomenal for rapid prototyping, brainstorming, and use cases where you want the LLMs to figure out the path to the solution themselves.

However, as a Lead Engineer, handing over control flow to the LLM’s conversational whims can be terrifying. As noted in recent framework comparisons, debugging a failed AutoGen workflow often means reading through raw chat logs to figure out where the agents misunderstood each other. It lacks strict, deterministic state transitions.

The State Machine Paradigm: LangGraph

LangGraph, on the other hand, treats agent orchestration like a state machine. It forces you to think in terms of nodes (functions/agents), edges (control flow), and a centralized state object that gets updated at each step.

Become a Medium member

Instead of agents chatting, they are mutating a shared state. Crucially, LangGraph introduces cyclic graphs, allowing you to build loops where an agent writes code, another tests it, and if it fails, the flow loops back to the coder.

from typing import TypedDict, List
from langgraph.graph import StateGraph, END

# 1. Define the strict state schema
class WorkflowState(TypedDict):
code: str
errors: List[str]
iterations: int

# 2. Define the nodes (business logic)
def generate_code(state: WorkflowState):
# LLM generation logic here...
return {"code": new_code, "iterations": state["iterations"] + 1}

def run_tests(state: WorkflowState):
# Execution logic here...
return {"errors": test_results}

# 3. Define the routing logic
def route_next(state: WorkflowState):
if state["errors"] and state["iterations"] < 3:
return "generate" # Loop back
return END # Finish

# 4. Compile the graph
workflow = StateGraph(WorkflowState)
workflow.add_node("generate", generate_code)
workflow.add_node("test", run_tests)
workflow.add_conditional_edges("test", route_next)
workflow.set_entry_point("generate")

app = workflow.compile()

The Reality in Production: LangGraph has a steeper learning curve. You have to understand graph theory basics and handle state management explicitly.

But for enterprise production, it is usually my weapon of choice. It gives you deterministic guardrails. You know exactly why an agent moved to a specific node. Furthermore, LangGraph’s built-in checkpointing allows for “time-travel” — you can pause a workflow, let a human review the state, modify it, and resume.

The Protocol for Building

Whichever framework you choose, the rules of engagement for agent-oriented infrastructure remain the same. Over the last year of deployments, I’ve settled on a few harsh truths:

  1. Don’t Overcomplicate the Graph: As the team at Vellum AI rightly points out, a massive workflow with 15 specialized agents and 40 tools will just confuse the orchestration layer. Start with a “Supervisor” pattern: one router agent and two execution agents. Expand only when accuracy demands it.
  2. FinOps is an Architecture Concern: Cyclic graphs mean your LLM calls can loop endlessly if not capped. Using an expensive frontier model (like GPT-4o or Claude 3.5 Sonnet) for every node will bankrupt your project. Design your protocols so that cheap, fast models handle routing and simple formatting, reserving frontier models solely for heavy reasoning nodes.
  3. Structured Output is Mandatory: If your agents are passing unstructured strings to one another, your system will break. Enforce strict JSON schemas (using Pydantic or similar) at every edge in your graph.

Final Thoughts

We are moving away from the era of “vibes-based” AI development and into an era of rigorous software engineering.

We can no longer just throw a massive prompt at an API and cross our fingers. We have to architect protocols. We have to design systems that anticipate failure, reflect on their own mistakes, and iterate toward a solution. The tools are finally here to do it, now it’s just a matter of building the right infrastructure.

References & Further Reading

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI


Towards AI Academy

We Build Enterprise-Grade AI. We'll Teach You to Master It Too.

15 engineers. 100,000+ students. Towards AI Academy teaches what actually survives production.

Start free — no commitment:

6-Day Agentic AI Engineering Email Guide — one practical lesson per day

Agents Architecture Cheatsheet — 3 years of architecture decisions in 6 pages

Our courses:

AI Engineering Certification — 90+ lessons from project selection to deployed product. The most comprehensive practical LLM course out there.

Agent Engineering Course — Hands on with production agent architectures, memory, routing, and eval frameworks — built from real enterprise engagements.

AI for Work — Understand, evaluate, and apply AI for complex work tasks.

Note: Article content contains the views of the contributing authors and not Towards AI.