All AI videos

AI video

DSPy vs. LangGraph: AI Agent Frameworks Explained | Stanford CS329Z Lecture 5 with Michael Ryan

Stanford CS329Z instructor Michael Ryan compares DSPy and LangGraph in code, then places agent harnesses, Temporal, telemetry and evaluation in one system design.

Stanford Online · 2026 featured video

Watch on YouTube

What this video shows

Ryan live-codes agent programs with DSPy signatures, modules and optimizers, then rebuilds workflow ideas with LangGraph state, nodes and edges. The comparison shows that the frameworks solve different parts of the design problem instead of forming a simple winner-takes-all choice.

The lecture also surveys open-source harnesses such as mini-SWE-agent, OpenHands and Pi, then separates workflow definition from durable execution and observation. That distinction helps teams decide whether they need a programming abstraction, an agent runtime, an orchestrator or telemetry.

Follow the current DSPy documentation for signatures, modules and optimizers. Check the LangGraph overview for graph state, persistence and human review. Use Temporal's durable execution documentation when a workflow must survive worker and network failures.

What you will learn

  • Choose an abstraction from the failure and change patterns in your workflow, rather than from a generic framework ranking.
  • Use DSPy when you want to define a multi-stage LM program and optimize its prompts or examples against a metric.
  • Use LangGraph when explicit state, branches, loops, persistence and human checkpoints are central to the workflow.
  • Treat durable execution, traces and evaluations as separate requirements that either programming framework may still need.

How to apply this safely

  1. Draw one real workflow with inputs, state, tools, branches, retries and a measurable final result.
  2. Build the smallest version in plain code so the team can see which complexity a framework would remove.
  3. Prototype the same critical path with the framework that best matches the workflow's main constraint.
  4. Inject a tool timeout, worker restart and invalid model response, then verify recovery and recorded state.
  5. Run an evaluation set before and after optimization, and keep framework-specific code behind a narrow application interface.

Important limitations

  • The lecture introduces several tools in one session and cannot cover their full APIs, operational costs or upgrade risks.
  • Recorded examples use the framework versions available in October 2026, while the video was published in November.
  • A classroom comparison does not establish which framework performs better on a particular production workload.

Sources to check

Continue learning on Learnetto