13 Frameworks & Advanced Patterns
You could hand-write the agent loop, the tool routing, the memory, the retries, the parsing — for every single agent, forever. That's a special kind of insane. Frameworks hand you the plumbing so you spend your time on what your agent actually does. Then the real edge shows up: the advanced patterns most tutorials never mention.
The toolbox
Think of these like power tools. A hand saw cuts wood, but a table saw cuts it faster and straighter — as long as you pick the right one for the cut. Each framework is tuned for a different job. Here's when to reach for each.
The default starting point — 100+ integrations for models, tools, and databases, so you rarely write glue code. Its sibling LangGraph handles complex, stateful, multi-agent workflows with loops and branching.
When to useYour general-purpose workhorse for production pipelines.
Built to connect an LLM to your documents. Best-in-class retrieval, strong document processing, and 50+ data connectors that pull from PDFs, Notion, databases, and more.
When to useKnowledge-base and question-answering systems over your own data.
Pioneered multi-agent conversation — agents that talk to each other to solve a problem, passing messages back and forth. Comes with built-in code execution.
When to useAutonomous coding and research where agents debate and iterate.
The gentlest on-ramp to multi-agent systems. You define each agent by its role — researcher, writer, analyst — hand it a goal and some tools, and let the crew collaborate.
When to useRole-based teams of agents, up and running fast.
In real code
Here's CrewAI's whole idea on one screen: describe who each agent is, give the crew a task, and press go. You're writing job descriptions, not control flow — the framework handles the handoffs.
from crewai import Agent, Task, Crew # define agents by role, then let them collaborate researcher = Agent( role="Researcher", goal="Find the 3 strongest sources on the topic", tools=[web_search], ) writer = Agent( role="Writer", goal="Turn the research into a tight one-page brief", ) brief = Task(description="Research and write the brief", agent=writer) crew = Crew(agents=[researcher, writer], tasks=[brief]) result = crew.kickoff() # they hand work to each other print(result)
The differentiators
Frameworks get you running. These four techniques are what separate a demo from a system serious practitioners actually trust in production — how they keep agents cheap, reliable, and self-improving.
The agent reads a small rules-and-memory file at the start of every session. When you correct a mistake, it rewrites that file with the lesson it just learned. Next session, it opens with the corrected rules and doesn't repeat the error. Over time it stops needing the same feedback twice — it improves itself.
Spawn ~10 agents on the exact same prompt. Because temperature adds a little randomness, each returns a slightly different take. Where they agree, you've found the reliable answer. Where they diverge, you've surfaced the creative edge cases — one bad roll can't dominate, and the interesting outliers become idea fuel.
Don't dump your whole codebase or knowledge base into context — most of it is dead weight the model pays for on every call. Keep only the core rules visible above the waterline, and give the agent grep and read tools to pull in exactly the piece it needs, when it needs it. Cuts token cost 60–80%.
Not every task deserves your smartest, priciest model. Route roughly 60% of tasks — simple classification and formatting — to cheap, fast models; send 30% — research and synthesis — to a mid-tier; and reserve just 10% — complex orchestration and high-stakes calls — for your most powerful model. Same quality where it matters, a fraction of the bill. See it in motion below.
Frameworks give you the plumbing. The advanced patterns are how serious practitioners keep agents cheap, reliable, and self-improving — and that's the difference between a flashy demo and something you'd actually ship.
Chapter 13 in one breath
LangChain for general pipelines, LlamaIndex for RAG, AutoGen for agent-to-agent conversation, CrewAI for role-based teams — pick the tool that fits the cut. Then layer on what the tutorials skip: agents that rewrite their own rules, consensus from many parallel runs, the iceberg for context, and 60-30-10 for cost. Next up — keeping all of this safe.
A matching slide deck with speaker notes — press S for notes, F for fullscreen.