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

**URL:** <https://www.artofsm.art/t/dspy-vs-langgraph-ai-agent-frameworks-explained-stanford-cs329z-lecture-5-with-michael-ryan/28395>\
**Category:** Content Creators\
**Tags:** stanford-online, agents\
**Created:** [13 November 2026 21:00 UTC](https://www.artofsm.art/t/dspy-vs-langgraph-ai-agent-frameworks-explained-stanford-cs329z-lecture-5-with-michael-ryan/28395 "2026-11-13T21:00:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![artesia](https://www.artofsm.art/user_avatar/www.artofsm.art/artesia/32/36_2.png) [@artesia](https://www.artofsm.art/u/artesia)\
**Post date:** [13 November 2026 21:00 UTC](https://www.artofsm.art/t/dspy-vs-langgraph-ai-agent-frameworks-explained-stanford-cs329z-lecture-5-with-michael-ryan/28395/1 "2026-11-13T21:00:26Z")

</div>

[![](https://www.artofsm.art/uploads/default/original/3X/3/d/3ddc73868ba1c9ecc065b0b88a80eab6c4b6ed88.jpeg "DSPy vs. LangGraph: AI Agent Frameworks Explained | Stanford CS329Z Lecture 5 with Michael Ryan") ](https://www.youtube.com/watch?v=q0Q-Hy8TTps)

The lecture provided an in-depth comparison of AI agent frameworks DSPy and LangGraph, highlighting DSPy’s strengths in prompt optimization and Python-based control flow versus LangGraph’s capabilities in graph-based orchestration and distributed workflow management, while demonstrating how both can be integrated for complex AI system engineering. It also covered the importance of evaluation, data, and tooling—including agent harnesses, orchestration platforms like Temporal, and observability tools—to build reliable, maintainable AI agents with effective failure recovery and performance monitoring.

---

<div class="post-metadata">

**Author:** ![artesia](https://www.artofsm.art/user_avatar/www.artofsm.art/artesia/32/36_2.png) [@artesia](https://www.artofsm.art/u/artesia)\
**Post date:** [13 November 2026 21:20 UTC](https://www.artofsm.art/t/dspy-vs-langgraph-ai-agent-frameworks-explained-stanford-cs329z-lecture-5-with-michael-ryan/28395/3 "2026-11-13T21:20:48Z")

</div>

The lecture focused on practical aspects of AI agent engineering, emphasizing frameworks and orchestration to simplify programming complex AI workflows. It began by discussing the three pillars essential to AI system engineering: the system itself (models or agents), the data used for training or feedback, and evaluation metrics to assess performance. The lecture highlighted a spectrum of agency ranging from simple model calls, through compound AI workflows where control flow is in code, to agents where the AI model controls the flow. Different frameworks cater to these levels, with DSPy and LangGraph being prominent tools for building workflows and agents, alongside reliability and observability tools like Temporal and LangFuse.

DSPy was explored in depth, showcasing its core concepts: signatures (defining structured inputs and outputs), modules (composable units that implement inference logic), and optimizers (tools to improve prompts and system performance based on data and metrics). Through live coding, the lecturer demonstrated how DSPy enforces structured outputs using adapters, supports complex data types, and enables chaining modules with Python logic. The optimizer was shown to significantly improve a smaller model’s accuracy on an event extraction task by refining prompts automatically, illustrating the importance of data and evaluation in system improvement. DSPy also supports agent architectures like React and recursive language models, allowing the model itself to manage control flow and handle long contexts.

LangGraph was introduced as a graph-based framework where a shared state is manipulated by nodes connected via edges that define control flow, including conditional branching. The lecture demonstrated building a simple event extraction and calendar update workflow using LangGraph, highlighting its suitability for orchestrating complex, distributed, and observable workflows. LangGraph also supports agent creation with tool integration, similar to DSPy, but focuses more on graph orchestration and state management. The lecturer noted that while DSPy emphasizes prompt optimization and Python-based control flow, LangGraph excels in managing large-scale, conditional workflows and distributed execution, and the two can be composed together.

The lecture then surveyed various open-source agent harnesses, which are pre-built frameworks that wrap around language models to provide memory, tool integration, and context management. Examples included MiniSweet Agent, OpenHands, Pi Agent, and Claude Code, each with different design trade-offs in terms of context handling, tool execution, and user interaction. The discussion also touched on research ideas like meta harnesses, where agents can evolve their own harnesses to optimize for specific tasks. The importance of design decisions in agent harnesses was emphasized, as these choices impact success rates, cost, latency, and user control.

Finally, the lecture covered orchestration and telemetry tools like Temporal, which provide durable, reliable execution of long-running agent workflows with retry and failure recovery mechanisms, and observability frameworks such as MLflow, LangSmith, and LangFuse that enable monitoring, debugging, and performance tracking. Best practices were outlined, including starting simple, carefully selecting tools, making failures observable and recoverable, and grounding design decisions in rigorous evaluation metrics tailored to the specific domain. The lecturer stressed the importance of understanding underlying system details despite the abstraction frameworks provide, to build robust, maintainable AI agents and effectively diagnose failures in complex systems.

## Useful Links

- [DSPy GitHub Repository](https://dspy.ai/current/) — Central to the video as a primary framework discussed and demonstrated for AI agent engineering.
- [LangGraph GitHub Repository](https://github.com/langchain-ai/langgraph) — Central to the video as a main framework compared and demonstrated alongside DSPy.
