Agent Frameworks

Agent Frameworks

A hands-on tour of the best-known agent frameworks: OpenAI Agents SDK, LangGraph, CrewAI and Microsoft Agent Framework (the successor of AutoGen), and how to choose between them.

AdvancedLevel
6Lessons
88 minutesReading time
0Module questions

About the module

After building the agent from its basic components by hand, in this module you meet the frameworks that shorten this work in practice. We study four schools of design: a simple agent loop with handoffs in the OpenAI Agents SDK, an explicit state graph in LangGraph, a team of roles and tasks in CrewAI, and agents and workflows in Microsoft Agent Framework, which succeeded AutoGen and Semantic Kernel. For each framework we show the central idea, a documented snippet that matches the official documentation with a clear review date, and when it fits and when it does not. We close with a practical method for choosing a framework according to the project's requirements rather than popularity, with a reminder that these libraries change quickly, so always check the version and the documentation before building.

Learning objectives

  • Distinguish the main design patterns behind agent frameworks: the loop, the state graph and the role-based team
  • Read snippets of OpenAI Agents SDK, LangGraph, CrewAI and Microsoft Agent Framework and understand every line
  • Identify what a framework adds on top of a hand-written agent loop: tracing, persistence, handoffs and guardrails
  • Understand the current status of AutoGen and the teams' move to Microsoft Agent Framework
  • Choose a suitable framework for a specific project and justify the choice with clear criteria

Prerequisites

  • Completion of the fundamentals module and understanding of the agent loop
  • The tools module and function calling
  • The multi-agent module and the concepts of handoff and shared state
  • Basic knowledge of Python and virtual environments (venv)

Skills gained

  • Read an agent framework's documentation and check the version and review date
  • Write a simple agent with the OpenAI Agents SDK, with a tool and a handoff
  • Build a state graph in LangGraph with clear nodes and edges
  • Define a CrewAI crew of agents, tasks and a process
  • Compare frameworks with a weighted criteria matrix

Lessons

  1. 1A map of agent-building frameworksThe Agent Frameworks LandscapeFrameworks cut down the repetitive code in building agents, but they differ in their central idea. In this lesson we see what any framework…14 min
  2. 2OpenAI Agents SDK: the agent, the runner and the handoffOpenAI Agents SDK: Agents, Runner and HandoffsThe OpenAI Agents SDK offers a small number of concepts: an agent, a runner, a handoff and guardrails. In this lesson we read the documented…16 min
  3. 3LangGraph: the agent as a state graphLangGraph: Agents as State GraphsLangGraph treats the agent as a graph: nodes that read and update a shared state, and edges that define the path. In this lesson we build a…16 min
  4. 4CrewAI: agent teams, roles and tasksCrewAI: Crews, Roles and TasksCrewAI borrows the language of work teams: agents with roles and goals, tasks with expected outputs, and a process that sets the order of ex…15 min
  5. 5From AutoGen to the Microsoft Agent FrameworkFrom AutoGen to Microsoft Agent FrameworkAutoGen became known for the idea of agents that converse to solve tasks, but it no longer receives new releases, and it has been officially…14 min
  6. 6How do you choose the right agent framework?Choosing an Agent FrameworkThere is no absolutely best framework, only a framework better suited to a specific problem. In this lesson we turn the problem into require…13 min

Module diagrams

ObservationReasoning engineLLM / ReasonerInstructions and goalInstructions / GoalMemoryPlannerToolsTools / APIsEnvironmentSafety guardrailsGuardrails
The agent's components: a reasoning engine (usually a language model) governed by the instructions, connected to memory, tools and the planner, and surrounded by safety controls.
handoffhandoffhandoffUser requestTriage agentBilling agentTechnical support agentSupport AgentSales agent
Handoff: the triage agent passes the whole conversation to the specialized agent, which continues the work with its own instructions and tools.
Tool?Sensitive?DoneSTARTAgentnodeToolsnodeHuman approvalinterruptENDStatecheckpoint
A workflow with a state graph: nodes that read and modify the shared state, conditional edges that choose the path, and checkpoints that allow resuming.
ABCFan-out123AggregateSupervisorWorkerWorkerWorkerManagerSupervisorSupervisorWWWW
Collaboration patterns: sequential (a chain), parallel (fan-out then aggregation), a supervisor that distributes and aggregates, and hierarchical with layers of supervisors.

Module terms

TermEnglishDefinition
Agent frameworkAgent FrameworkA library that provides ready-made components for building and running agents
TracingTracingRecording every call to the model and the tools in an inspectable trace
PersistencePersistenceSaving the state of a run so that it can be resumed later
HandoffHandoffTransferring the conversation from one agent to a specialized agent
State graphState GraphRepresenting the workflow as nodes and edges that share a single state
RunnerRunnerThe object that manages the agent's execution loop until the final output
Final outputfinal_outputThe output of the last agent that worked in the run
Function toolfunction_toolA decorator that turns a Python function into a tool the agent calls
GuardrailGuardrailA check on the inputs or outputs that stops execution on failure
Maximum number of cyclesmax_turnsA cap on the number of loop cycles that raises MaxTurnsExceeded when exceeded
NodeNodeA function that reads the state and returns an update to it
EdgeEdgeA defined transition from one node to another
Messages stateMessagesStateA ready-made state with a messages key to which new messages are appended
Durable executionDurable ExecutionThe ability to resume a run after an interruption from the last saved state
CompilecompileTurning the builder into a runnable graph
CrewCrewA group of agents and tasks executed according to a specific process
RoleRoleA description of the agent's function within the team
Expected outputexpected_outputA description of the shape of the task's result and its completion criteria
Sequential processSequential ProcessExecuting tasks in order, passing the results along
Hierarchical processHierarchical ProcessA manager that distributes tasks and reviews the results
Conversable agentConversable AgentAn agent that sends and receives messages within a multi-agent conversation
WorkflowWorkflowA graph-based flow of steps and agents controlled by code
Termination conditionTermination ConditionA rule that stops the conversation when a specific goal is met
Chat clientChat ClientAn object that connects the agent to a particular language model provider
Successor frameworkSuccessor FrameworkA framework that replaces an earlier framework and continues its development
RequirementsRequirementsWhat the system must achieve, against which the choice is measured
Decision matrixDecision MatrixA table of criteria, weights and scores for comparing options
Exploratory prototypeSpikeA short experiment to test a technical hypothesis before committing
Version pinningVersion PinningSpecifying the library's version number in the requirements file
Workflow vs agentWorkflow vs AgentA fixed path set by code versus a path decided by the model

Hands-on experiment

Representing the agent as a state graph Agent as a State Graph

To connect the simulator's diagram with the StateGraph concept in LangGraph: nodes that work on a shared state and edges that determine the path, including conditional edges.

  1. Open the Simulator (open ↗) and build a diagram: Start, then LLM with the task classify, then Decision, then two branches, then Output, then End
  2. Set Decision to the contains rule with a keyword as the value, and make one branch go to a Tool with the knowledge_search tool and the other to an LLM with the task answer
  3. Run with two different inputs and notice which branch was executed each time
  4. Export the diagram as JSON and read the structure of nodes and their edges
  5. Write on paper what corresponds to each node in LangGraph: add_node for each node and add_edge from START and to END
  6. Add a Human Approval node before Output and notice how it resembles the stopping point in human in the loop

What you will notice: You will notice that the path is determined by the state and the conditions, not by a fixed order, and that the exported JSON file is data that only describes the graph. This is the same thinking LangGraph requires, although the actual framework code needs the library to be installed.

Open the lab

Final task

Design a "support request triage agent" twice, on paper and then in the academy simulator (open ↗): once as a single-agent loop with a handoff to a specialised agent (in the style of the OpenAI Agents SDK), and once as a state graph with explicit nodes (in the style of LangGraph). Submit: (1) a diagram of each design, (2) a code snippet for each that matches the interface shapes given in the lessons, with the version number and the review date, (3) a weighted selection matrix of at least five criteria ending with a justified recommendation. Acceptance criteria: every node or agent has one clear responsibility, there is a maximum number of iterations and a human approval point before any action that changes customer data, and no framework is credited with an undocumented feature.

Completion criteria: the module counts as complete when you finish all its lessons and pass its quiz.

Official references