Stanford Online

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

YouTube summary11 sectionsWatch on YouTube ↗

This is an AI-generated summary of the YouTube video "DSPy vs. LangGraph: AI Agent Frameworks Explained | Stanford CS329Z Lecture 5 with Michael Ryan" (Stanford Online), made with Samuraize and published by Samuraize. It condenses the YouTube video into 11 titled sections you can read in a couple of minutes, each linking to the moment in the video it covers.

1
Filed under💻 Technology0 comments🍱 Add to trayReport
Study this

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

Stanford Online

切

Frameworks and abstractions 0:05

Today’s focus is frameworks and orchestration. The lecture uses PyTorch as the model for an abstraction: you write the forward pass, then call loss.backward instead of doing every derivative by hand. The same idea carries to agent systems. You can build an agent without data or evaluations, but engineering one means thinking about the system, the data that improves it, and the metrics that judge it.

切

Agency and DSPy basics 4:30

The landscape runs from models, to workflows, to agents. In workflows, the control flow lives in your program. In agents, the model chooses the next step, such as a tool call. DSPy is introduced as a tool for these workflows. Its three core ideas are signatures, which define inputs and outputs; modules, which run the logic; and optimizers, which improve prompts and weights.

切

Structured outputs and fallbacks 14:31

DSPy turns a prompt into a fixed input-and-output shape. The adapter writes the input fields into the prompt, asks for named output fields, then parses the model reply back into a prediction you can use. If the model misses the format, DSPy tries a chat adapter first, then a JSON adapter, and can use custom adapters before finally erroring.

切

Signatures and module flow 16:00

A signature can be a class with typed fields, such as extracting an event name, date, time, and duration from an email. The field name and type guide what goes in each slot, and the docstring acts like a system prompt. Modules can then chain these pieces together: one module extracts the event, another picks an emoji, and Python logic decides whether to add the event to a calendar or return no event found.

切

Exact match scoring 29:01

[29:01] The evaluator checks whether the predicted date, start time, and duration all match the gold answer. It uses Python's all function to turn those checks into a float score of zero or one. If the result is wrong, DSPy can also turn the failure into plain-text feedback. That extra feedback is optional, but it can help the optimizer improve the prompt later.

切

Prompt optimization and agents 30:00

[30:00] A small model starts at 55 percent on the email task, then the optimizer rewrites the instruction and pushes it to 100 percent on the test set. The speaker warns that this can cost many tokens and needs train, dev, and test splits to avoid overfitting. DSPy can also build agents with react, use tools, and handle long inputs through recursive language models and a shared state workflow.

切

LangGraph state and routing 43:30

LangGraph treats the state as shared data across the whole graph. A node reads the state and writes back only the fields it changes. Here the graph extracts event details from an email with structured output, then ends. A second graph adds conditional edges: if the state has a valid event, it routes to pick an emoji and add the event to a calendar; otherwise it goes straight to the end.

切

Agents and harnesses 51:30

LangGraph can also build agents in a few lines with a model and tools. Its value is orchestration, retries, observability, and graph-shaped control flow. DSPy is framed as better for Python control flow and prompt optimization, and the two can be composed. The lecture then turns to agent harnesses: the surrounding memory, tools, and execution setup. Mini SWE Agent uses only Bash and simple stacked history; OpenHands stores events and rebuilds context, with a persistent terminal.

切

Agent harness choices 58:30

Different harnesses make different trade-offs. Pi agent keeps only four tool calls and no permissions system, while OpenAI’s long-running agent stores context as a tree, wakes every 30 minutes, and saves memories each night. The point is that there is no single right harness. Design choices change success rates, and benchmarks like Terminal Bench show the model and harness both matter.

切

Orchestration and observability 1:02:30

Temporal shows durable execution for long tasks. It links activities, retries failures, and keeps execution history so you can inspect what happened when a worker breaks. Other tools such as MLflow, LangSmith, and LangFuse help you trace inputs, outputs, tokens, latency, cost, and scores. The practical advice is simple: keep systems simple, make failures recoverable, and build strong evaluations.

切

Framework limits and recap 1:13:30

Abstractions make agents easier to build, but you still need to understand what sits underneath. Complex systems can fail in hard-to-find places, so traces and observability matter. Frameworks also add dependence on outside libraries that may change or disappear. The recap is simple: build, run, evaluate, improve, and keep complexity justified.

AI-generated summary. It can be wrong or incomplete - check anything that matters against the original.

Summarize your own YouTube video

Paste a YouTube link, article, PDF, ebook or slide deck and get a summary like this in seconds. Free to try, no sign-up needed.

⚔️ Try the YouTube summarizer

Discussion

Sign in to join the discussion. Sign in

More from the Bento Box

Browse the Bento Box →

With your OK, Microsoft Clarity and Google Analytics set cookies (data goes to the US) so we can see what breaks. Cookie details