LALatent SpaceSep 11, 2025· 1:03:18

Context Engineering for Agents - Lance Martin, LangChain

Lance Martin from LangChain discusses context engineering for AI agents, arguing that managing context from tool calls is the key challenge and introducing five techniques: offloading, reducing, retrieval, caching, and context isolation. Offloading saves raw tool call outputs to disk and passes only summaries, drastically cutting token usage—Martin's deep research agent went from 500,000 tokens per run to much less. Manus uses file system offloading and warns that irreversible pruning risks information loss, while Cognition advocates fine-tuned summarization for agent-agent boundaries. For retrieval, Martin contrasts Windsurf's multi-step indexing with Claude Code's agentic search using grep and llms.txt, finding the latter more effective. He applies the Bitter Lesson to agent engineering: his own Open Deep Research evolved from a highly structured workflow to a simple agent loop as models improved, and he warns against rigid abstractions that hinder adaptation.

  1. 0:00Intro
  2. 6:17Offloading
  3. 10:53Context Isolation
  4. 15:51Retrieval
  5. 27:39Reducing Context
  6. 35:21Caching
  7. 40:53Memory
  8. 47:01Bitter Lesson
  9. 56:22Frameworks

Powered by PodHood

Transcript

Intro0:00

Alessio0:04

Hey everyone, welcome to the Latent Space Podcast. This is Alessio, founder of Kernel Labs, and I'm joined by Swyx, founder of Smol AI.

Swyx0:11

Hello, hello. Uh, we are so happy to be in the remote studio with Lance Martin from LangChain, LangGraph, and everything else he does. Welcome.

Lance Martin0:20

It's great to be here. I'm a longtime listener to the pod, and, uh, it is finally great to be on.

Swyx0:25

Yeah. Um, you, you've been, uh, part of, uh, you know, our, our orbit for a while. You, you spoke at, uh, one of the AIEs, uh, and also obviously we're, we're pretty close with, with LangChain. Um, I think, uh, recently though, you know, I think you, you've, you've also, like, been doing a lot of tutorials.

I remember you did, like, o1 Deep Researcher-- oh, sorry, r1 Deep Researcher, which is, uh, a pretty popular project, um, and, uh, a- async ambient agents. Uh, but the thing, the thing that really sort of prompted me to reach out and say like, "Okay, it's, it's finally time for the Lance Martin pod," is your recent work on context engineering, which is all the rage.

Uh, how'd you get into it?

Lance Martin1:04

Well, you know, it's funny. Um, buzzwords emerge oftentimes when people have a shared experience, and I think lots of people started building agents kind of early this year, mid this year, quote unquote, "the year of agents." And I think kind of what happened is when you put a, put t- when you kind of put together an agent, it's just tool calling a loop.

It's relatively simple to lay out, but it's actually quite tricky to get it to work well. And in particular, managing context with agents is a hard problem. Karpathy put out that tweet kind of canonizing the term context engineering, and he kind of mentioned this, uh, kind of nice definition, which is context engineering is the challenge of feeding an LM just the right context for the next step, which is highly applicable to agents.

And I think that re-really resonated with a lot of people. And I in particular had that experience over the past year working on agents, and I wrote about that a little bit in my piece talking about building open deep research over the past year.

So I think it's, it was kind of an interesting point that the term kind of captured a common experience that many people were having, and it kind of took hold because of that.

Alessio2:09

How do you define the lines between prompt engineering and, like, context engineering? So is the prompt optimization like context engineering in your mind? Like, I think people are kind of confused, like are we replacing the, the term? Like what, what is it?

Lance Martin2:25

Well, I think that, you know, prompt engineering is kind of a subset of context engineering. I think when we kind of move from chat models and chat interactions to agents, there was a big shift that occurred. So with chat models, working with ChatGPT, the human message is really the primary input.

And of course, a lot of time and effort is spent in crafting the right message that's passed to the model. With agents, the game is a bit trickier though, because the agent's getting context not just from the human, but now context is flowing in from tool calls during the agent trajectory.

And so I think this was really the key challenge that I observed and many people observed is like, oof, um, when you put together an agent, you're not only managing, of course, the system instructions, system prompt, and of course user instructions, you also have to manage all this context that's flowing in at each step over the course of a large number of tool calls.

And I think there's been a number of good pieces on this. Manus put out a great piece talking about context engineering with Manus, and they made the point that the typical Manus task is like fifty tool calls. Anthropic's Multi-Agent Research is another nice example of this.

They mentioned that the typical production agent, and this is probably referring to Claude Code, could be other agents that they've produced, is like hundreds of tool calls. And so when I had my first experience with this, and I think many people have this experience, you put together an agent, you're sold the story that it's just tool calling in a loop.

That's pretty simple. You put it together. I was building deep research. These research tool calls are pretty token heavy, and suddenly you're finding that my deep researcher, for example, with a naive tool calling loop, was using five hundred thousand tokens.

It was like a dollar to two dollars per run. And I think this is an experience that many people had, and I think it's kind of that the challenge is realizing that, oof, building agents is actually a little bit tricky because if you just naively plumb in the context from each of those tool calls, naively, you just hit the context window of the LM.

That's kind of the obvious problem. But also, Jeff from Chroma tok- spoke about this on the recent pod. There's all these weird and idiosyncratic failure modes as context gets longer, so Jeff has a nice report on context rot.

And so you have both these problems happening. If you build a naive agent, context is flowing in from all these tool calls. It could be dozens to hundreds. And there's degradation of performance with respect to context length, and also the trivial problem of hitting the context window itself.

So this was kind of, I think, the motivation for this new idea of actually it's very important to engineer the context that you're feeding to an agent. And that kind of spawned into a bunch of different ideas that I put together in the blog post that people are using to handle this, um, drawn from Anthropic, from my own experience, from Manus and others.

Swyx5:13

So I'm just gonna put some of the, um, relevant materials on screen just because I, we like to, you know, part, this is gonna be-

Lance Martin5:19

Yeah

Swyx5:19

... we'd like to have some visual aid. Uh-

Lance Martin5:21

Yeah

Swyx5:21

... we did our, our post on GPT-5, and we called it Thinking with Tools. So where, you know, you part, part of the tools is to get context, um, and I think using tools to, to obtain more context, like the agent can figure out what context it needs, and if you just tell it to.

Uh, and then the other one is, actually, I thought you would, you did a blog post on, on this, but apparently it was just like, th-this is it. Um,

Lance Martin5:42

I will say it's funny, and actually I w-was hoping you'd bring this up. I also have a blog post, but it's all moving so quickly-

Swyx5:49

Yeah

Lance Martin5:50

... that I did a meetup after the blog post and updated the story a little bit with this meetup. So actually this is a better thing to show. But I do have a blog post too, but things changed between my blog post and the meetup, which were like two weeks apart.

Swyx6:01

Right.

Lance Martin6:01

So that's how quickly these things are moving. Exactly. That's the blog post.

Swyx6:04

Should we, should we do this sequentially then? Um-

Lance Martin6:07

I think it's actually okay to just hit the meetup-

Swyx6:11

Okay

Lance Martin6:11

... uh, because that's-- it's just easier to follow one thing, and it, it's, it's like a superset of the blog post story.

Offloading6:17

Swyx6:17

Okay. How do you define the five categories? So I mean, I understand what offload kinda means, but, like, can you maybe-

Lance Martin6:26

Yeah, yeah

Swyx6:27

... yeah, go deeper?

Lance Martin6:27

Yeah, yeah. We should-- let's walk through these, actually. So when I talked about naive agents and the first time I built an agent, agent makes a bunch of tool calls. Those tool calls are passed back to the LLM at each turn, and you naively just plumb all that context back.

And of course, what you see is the context window grows significantly because these, this tool feedback is accumulating in your message history. So a perspective that Manus shared in particular I thought was really good is it's important and useful to offload context.

Don't just naively send back the full context of each of your tool calls. You can actually offload it, and they talk about offloading it to disk. So they talk about this idea of using the file system as externalized memory rather than just writing back the full contents of your tool calls, which could be token heavy.

Write those to disk, and you can write back a summary. It could be a URL, something so that the agent knows it's retrieved a thing. It can fetch that on demand, but you're not just naively pushing all that raw context back to the model.

So that's this offloading concept. Um, note that it could be a file system. It could also be, for example, agent state. So LangGraph, for example, has this notion of state. So it could be kind of the, the la- agent runtime state object.

It could be the file system. But the point is, you're not just plumbing all the context from your tool calls back into the agent's message history. You're saving it in externalized system. You're fetching it as needed. This saves token cost significantly.

So that's the offloading concept.

Swyx8:04

I, I guess the question on the offloading is, like, what's the, um, minimum, you know, summary metadata or whatever you need to keep in the context to let the model understand what's in the offloaded context. Like, if you're doing deep research, obviously you're offloading kinda like the full pages maybe.

But, like, how do you generate, like, an effective summary or blurb about what's in the file?

Lance Martin8:26

So this is actually a very interesting and important point. So I'll give an example from what I did with Open Deep Research. So Open Deep Research is a, a deep research agent that I've been working on for about a year, and it's now, according to Deep Research Bench, the best performing, uh, deep research agent, um, at least on that particular benchmark.

So it's, it's pretty good. Listen, it's not as good as OpenAI's deep research, which uses end-to-end RL. It's all fully open source, and it's pretty strong. So I just do carefully prompted summarization. I try to prompt the summarization model to give kind of an exhaustive set of kind of bullet points of the key things that are in the post, just so the agent can know whether to retrieve the full context later.

So I think it's kind of prompting, if you're doing summarization carefully for recall, compressing it, but, like, making sure that all the key bullet points necessary for the m- for the LLM to know what's in that piece of kind of full context is actually very important when you're doing this kind of summarization step.

Now, Cognition had a really nice blog post talking about this as well, and they mentioned you can really spend a lot of time on summarization, so I don't wanna trivialize it. But at least my experience has been it's worked quite effectively.

Prompt a model carefully to capture exactly. So in this post, they talk a lot about even using a fine-tuned model for performing kind of summarization. In this case, they're talking about, um, agent-agent boundaries and summarizing, for example, message history.

But the same applies... the same challenges apply to summarizing, for example, the full contents of token heavy tool calls so the model knows what's in context. So I basically spent a lot of time prompt engineering to make sure my summaries capture with s- high recall what's in the document, but compress the content significantly.

Swyx10:15

I, I, I do think the, the compression, that, that was also part of the meetup findings of yesterday, where we were, we were at the context engineering meetup that Chroma hosted, uh, that you do want frequent compression because you don't wanna hit the context route limit.

Um, yeah, I don't, I'm not sure there's much else to say. Like, offloading is important, and you should probably do it. The, um, there was also a really interesting link, I guess somebody, I think Dex, um, was linking it to the concept of multi-agents and why you, why you do want multi-agents is because you can compress and load in different things based on the role of the agent.

And, uh, probably a single agent would not have all the context.

Context Isolation10:53

Lance Martin10:53

Yeah. You know, so that's exactly right. And actually one of the other big themes I hit and, and talk about quite a bit is context isolation with multi-agent. And I do think this does link back to the cognition take.

So the... which is interesting. So their argument against multi-agent-

Swyx11:12

It's literally called-

Lance Martin11:12

... is that it can be hard-

Swyx11:12

... called Build Multi-Agent.

Lance Martin11:14

Correct. And what they're arguing is a few different things. One of the main things is that it is difficult to communicate sufficient context to sub-agents. They talk a lot about, um, spending time on that summarization or compression step.

They even use a fine-tuned model to ensure that all the relevant information... Yeah, so they actually show it a little bit down below as kind of a linear agent. But even at those agent-agent boundaries, they talk a lot about being careful about how you compress information and pass it between agents.

Swyx11:45

Yeah. I think the, the biggest question for me, I, I mean, uh, coding is kinda like the, the main use case that I have. Um, and I think, uh, I still haven't figured out how much of value there is in showing how the implementation was made to then write...

If you have a sub-agent that writes tests, or you have a sub-agent that does different things, how much do you need to explain to it about how you got To the place the code base is in versus not.

And then does it only need to return the test back in the context of the main agent? Sh- if it has to fix some code to match the test, should it say that to the main agent? I think that's kind of like...

Uh, it, it's clear to me in, like, the deep research use case because it's kind of like atomic pieces of content that you're going through. But I think when you have state that depends between the sub-agents, I think that's the thing that's still unclear to me.

Lance Martin12:35

So I think that's one of the most important points about this context isolation, um, kind of bucket. So Cognition argues, which actually I think is a very reasonable argument, they argue, don't do sub-agents because each sub-agent implicitly makes decisions, and those decisions can conflict.

So you have sub-agent one doing a bunch of tasks, sub-agent two doing a bunch of tasks. They... Those kind of decisions may be conflicting, and then when you try to compile the full result, in your example with coding, there could be tricky conflicts.

I found this to be the case as well, and I think a perspective I like on this is use multi-agent in cases where there's very clear and easy parallelization of tasks. Cognition and Walden Yens spoke on this quite a bit.

He talks about this idea of kind of read versus write tasks. So for example, if each sub-agent is writing some component of your final solution, that's much harder. They have to communicate, like you're saying, and agent-to-agent communication is still, um, quite early.

But with deep research, it's really only reading. They're just doing context collection, and you can do a write from all that shared context after all the sub-agents work. And I found this worked really well for deep research, and actually Anthropic report on this too.

So their deep researcher just uses parallelized sub-agents for research collation, and they do the writing in one shot at the end. So this works great. So it's a very nuanced point that what you apply context isolation to in terms of the problem, yeah, so you can see this is their work, matters significantly.

Coding may be much harder. In particular, if you're having each sub-agent create one component of your system, there's many potentially implicitly conflicting decisions each of the sub-agents are making. When you try to compile a full system, there may be lots of conflicts.

With research, you're just doing context gathering in each of those sub-agent steps, and you're writing in a single step. So I think this was kind of a key tension between the Cognition take, don't do multi-agents, and the Anthropic take, "Hey, multi-agents work really well."

It depends on the problem you're trying to do with multi-agents. So this was a very subtle and interesting point. What you apply multi-agents to matters tremendously in how you use them. I like the take that apply multi-agents to problems that are easily parallelizable, that are read-only, for example, context gathering for deep research, and do like the final, quote-unquote, "write," in this case report writing, at the end.

I think this is trickier for coding agents. I did find it interesting that Claude Code now allows for sub-agents, so they obviously have some belief that this can be done well, or at, at least it can be done.

But I still think, I actually kind of agree with Walden's take, it can be very tricky in the case of coding if sub-agents are doing tasks that need to be highly coordinated.

Swyx15:28

I think that's a, a well, uh, explained, uh, contrast and comparison. Um, not much to add there. I think, um, it's interesting that they have different use cases and different architectures involved. Um, I don't know if that's a permanent thing.

That, that might fall to the Bitter Lesson as, as, uh, you would put it.

Lance Martin15:45

Yes.

Swyx15:46

We should probably talk about, uh, some of the other parts of the system that, uh, you set up, so, um-

Lance Martin15:50

Yeah

Swyx15:51

... 'cause there, there's a lot of interesting techniques there.

Retrieval15:51

Lance Martin15:53

Let's talk about classic old retrieval. So RAG is obviously, uh... It, it has been in the air for now many years, obviously well before LMS and this whole wave. One thing I found pretty interesting is that, for example, different code agents take very different approaches to retrieval.

Varun from Windsurf shared an interesting perspective on how they approach retrieval in the context of Windsurf. So they use classic code chunking along carefully designed semantic boundaries, embedding those chunks, so classic kind of sem- semantic similarity vector search and retrieval.

But they also combine that with, for example, grep. Then they do, for example, knowledge, knowledge graphs. They, they then also mention knowledge graphs. They then talk about combining those results, doing re-ranking. So this is kind of your classic complicated multi-step RAG pipeline.

Now, what's interesting is Boris from Anthropic and Claude Code has taken a very different approach. He's spoken about this quite a bit. Claude Code doesn't do any indexing. It's just doing, quote-unquote, "agentic retrieval," just using simple tool calls, for example, using grep, to kind of poke around your files.

No indexing whatsoever, and obviously works extremely well. So there's very different approaches to kind of RAG and retrieval that different code agents are taking, and this seems to be kind of a, an interesting and emerging theme. Like when do you actually need kind of more hardcore indexing?

When can you just get away with simple, just kind of agentic search using very basic file tools?

Swyx17:37

Yeah, one of the more, uh, viral moments from one of our recent podcasts was Boris's pod with us and Cline also mentioning that, uh, they just don't do code indexing. They just use agentic search. Um, and yeah, probably they, you know...

That's a, that's a really good 80/20, and then if you really wanna fine-tune it, probably you wanna do a little mix, but maybe you don't have to for, for your needs.

Lance Martin18:00

Yeah, I actually just saw Cline posted, uh, I think yesterday talking about that they only use grep. They don't do indexing. And so I think within the retrieval kind of area of context engineering- Um, there are some interesting trade-offs you can make with respect to are you doing kind of classic vector store-based semantic search and retrieval with a relatively complicated pipeline like Varun's talking about with Windsurf, or just good old kind of agentic search with basic file tools.

I will note, I actually did a benchmark on this myself. I have-- think there's a shared blog post somewhere. I'll bring it up right now. Yep. I actually looked at this a bit myself. Um, this was a while ago.

But I compared three different ways to do retrieval on all LangGraph documentation for a set of 20 coding questions related to LangGraph. So I basically wanted to allow different code agents to write LangGraph for me by retrieving from our docs.

I tested Claude Code and Cursor. I used three different approaches for grabbing documentation. So one was I took all of our docs, around three million tokens, I indexed them in a vector store and just did classic old vector store search and retrieval.

I also used an llms.txt with just a simple file loader tool, so that's kind of more like the agentic search, just basically look at this llms.txt file, which has all of the URLs of our documents with some basic description, and let the LLM, or the code agent in this case, just make tool calls to fetch specific docs of interest.

And I also just tried context stuffing. So take all the docs, three million tokens, and just feed them all to the code agent. So these are just some results I found comparing Claude Code to Cursor. And interesting, what I actually found, this, this is only my particular test case, but I actually found that llm.txt with good descriptions, which is just very simple, it's just basically a markdown file with all the URLs of your documentation and, like, a description of what's in that doc, just that passed to the code agent with a simple tool just to grab files is extremely effective.

And what happens is the code agent can just say, "Okay, here's the question. I need to grab this doc and read it." It'll read it. "I need to grab this doc, read it." Read it. This worked really well for me, and I actually use this all the time.

So I actually personally don't do vector store indexing. I actually do llm.text with a simple search tool with Claude Code is kind of my go-to. Claude Code, in this case, this was done a few months ago. These things are always changing.

In this particular point in time, Claude Code actually outperformed Cursor for my test case. That's ac- this actually Claude Code pilled me, and this was, I did this back in April, so I've been kind of on Claude Code since.

Um, but that was really it. So this kind of goes to the point that Boris has been making about Claude Code, about, and Clyde as well. You give an LLM access to simple files, file tools. In this case, I actually use an llm.text to help it out, so it can actually know what's in each file, is extremely effective and much more simple and easy to mainta- easier to maintain than building an index.

So that's just my own experience as well.

Swyx21:10

The scaled up form of llms.txtish I really like and I use, uh, quite a bit is, uh, actually the, the DeepWiki from Cognition. So I made a little Chrome extension for myself where I, like any repo, including yours, uh, I can just hit DeepWiki, and this is an llms.txt kind of, but also I, I read it.

Um . It's just a better wiki .

Lance Martin21:33

No, no. So this, this is a great example. So, uh, and I, actually I think th- this could be a very nice approach. Take a repo, compile it down to some kind of easily kind of readable, yeah, llm.text.

What I actually found was even using an LLM to write the descriptions helped a lot. So I have actually a little package on my GitHub where it can rip through documentation and just pass it to a cheap LLM to write a high quality summary of each doc.

This works extremely well. And so that llm.text then has LLM generated... Yeah. Let's see where it is. It's, uh, doc QPG. If you go to my repos, it's one of my newer ones. No, that's old. That's much older .

I have a million things here. Go to my repos. Uh, it's, uh, go back up to the top. It's, I've, I'll, I'll have too much here. Try repositories.

Swyx22:22

You do too much, man.

Lance Martin22:23

Yeah, I know.

Swyx22:23

Too much open stories.

Lance Martin22:24

It won't be top. It'll be, uh, yeah, this one. This is a little repo. It got almost no attention and, but I found it to be very useful. So basically can... It's, it's trivial. You just point it to some documentation, it can kind of rip through it, grab all the pages, send each one to an LLM, and LLM writes a nice description, compiles it into an llm.text file.

I found when I did this, and I then fed that to Claude Code, Claude Code's extremely good at saying, "Okay, based on the description, here's the page I should load. Here's the page I should load from the question asked."

Dead simple. I use this all the time. Um, well, I use it when I'm trying to generate llm.text for new documentation, but I've done this for LangGraph, I've done it for a few other kind of libraries that I use frequently.

You just give that to Claude Code, then Claude Code can rip through and grab docs really effectively. Super simple, and the only catch is I found that the descriptions in your llm.text matter a lot because the LLM actually has to use the descriptions to know what to read.

You know, anyway, that's just a, a nice little utility that I use all the time.

Swyx23:29

When we had a client that had the Context Seven MCP by OpsStash, which is like an MCP for like, um, project documentation and stuff like that, was one of the most used. Have you seen... Have you tried it?

Have you seen anything else like that that kind of like automates some of this stuff away?

Lance Martin23:44

Well, you know, it's funny, we have an MCP server for LangGraph documentation that basically gives, for example, Claude Code the, an llm.text file and a simple search, a file search tool. Now Claude has built-in kind of, uh, fetch tools, but at the time we built it, it didn't.

But it's a very simple MCP server that exposes llm.text files to, for example, Claude Code. It's called MCP Doc. Uh, so it's a little very simple utility. I use that all the time. Extremely useful. So you basically can just point it to all the llm.text files you wanna work with- Yeah, this one

Alessio24:18

Yeah. Well, the MCP docs have a MCP server that you can search the docs, uh, with-

Lance Martin24:25

Yeah

Alessio24:25

... so it's kinda-

Lance Martin24:26

Exactly

Alessio24:26

... it rolls all the way down. But I guess my question is, like, should this be, like, one server per project? You know? Or, like, at some point you're gonna have kinda like a meta server which is, like, the be- And I think part of it is, um, you know, once you move on from just doing tool calling and servers to doing things like sampling and kinda like, uh, you know, prompts and resources and stuff like that, you can do a lot of the extraction in the server itself as well.

And again, it, it goes back to, like, your point on context engineering. It's like maybe you, you do all that work not in the context, but in the server, and then you just put the final piece that you care about in the context.

Uh, but it seems, like, very early.

Lance Martin25:05

Yeah. This is actually a very interesting point. I've spoken with folks from Anthropic about this quite a bit. It is, I've found that storing prompts in MCP servers is actually pretty important, in particular to tell the LLM or code agent how to use the server.

And so I actually end up do having kind of separate servers for different projects with specific prompts. Um, and also sometimes I'll have... You can also store resources, so sometimes I'll have specific resources for that particular project in the server itself.

Um, so I actually don't mind separating servers project-wise, um, with project-specific kind of context and prompts necessary for that particular task.

Swyx25:42

Yeah, a lot of people actually may have missed some features of the NCP spec, and, uh, you do have prompts in there. Uh, it's probably one of the, the first actual, uh, features that they, that they have, which, uh, actually may be kind of underrated.

Like may- pe- pe- people kinda view MCP as just, you know, uh, in tool integration. But, uh, there's actually a lot of stuff in here, including, uh, sampling, which, um, is, is underrated too.

Lance Martin26:08

Yeah, that's right. That's exactly right. And actually the, the prompting thing is pretty important because even to use our little simple MCP doc server for LangGraph docs, you actually... I found it, it's better, of course, if you prompt it.

But then I had to put in the readme initially, like, oh, okay, here's how you should prompt it, but of course, that prompt can just live in the server itself. And, uh, so you can kind of compartmentalize the prompt necessary for the LLM to use the server effectively within the server itself, and this was a problem I saw initially.

A lot of people were using our MCP doc server and then finding, oh, this doesn't work well, and it's like, oh, it's a skill issue. You need to prompt it better, but then that's, that's our problem. This, the prompt should actually live in the server and should be available to the code agent-

Swyx26:46

Right

Lance Martin26:47

... uh, so it knows how to use the server.

Swyx26:49

Right.

Lance Martin26:49

So that, that's maybe retrieval, and that's a whole... Retrieval's a big theme, uh, and it's, y- you know, it, it, it kind of obviously predates this new term of context engineering, but there's a lot going on in the retrieval bucket.

It certainly is an important subset of context engineering.

Swyx27:03

I'm wondering if there's any other trends in retrieval before we leave the topic. Um, you know, I think one other thing I was tracking was just ColBERT and, like, l- the, the general concept of late interaction. I don't know if you guys do a, do a ton on that, but, um, some sort of in-between element between full-agentic and full pre-indexing and sort of, sort of, um, two-phase indexing maybe is, is what I would call it.

Any comments on that?

Lance Martin27:31

I haven't personally looked at ColBERT very much. I played with it only a little bit, so I don't have much perspective there unfortunately.

Swyx27:38

All right. Happy to move on.

Reducing Context27:39

Lance Martin27:39

We could talk about maybe reducing context briefly. Everyone's had an experience with this because if you use Claude Code, you hit that kind of 95-- you know, you've hit 95% of the context window and you're about to... And, and Claude Code's about to perform compaction.

So that's, like, a very intuitive and, and kind of obvious case in which you want to do some kind of context reduction when you're near the context window. I think an interesting take here, though, is there's a lot of other opportunities for using summarization.

We talked about it a little bit previously, um, with offloading, but actually at tool call boundaries is a pretty reasonable place to do some kind of compaction or pruning. I use that in Open Deep Research. Hugging Face actually has a very interesting Open Deep Research implementation.

It actually uses, like, not a coding agent, but the code agent agent implementation. So instead of tool calls as JSON, tool calls are actually code blocks that go to a coding environment that actually runs the code. And one argument they make there is that they perform some kind of summarization or compaction and only send back limited context to the LLM, leave the raw kind of tool call itself, which is often token-heavy, as we're talking about deep research, in the environment.

So it's another example. Anthropic and their Multi-Agent Researcher also does kind of summarization of findings. Um, so y- I think you see pruning show up all over the place. It's pretty intuitive. I think an interesting counter to pruning was made by Manus.

They make the point and the kind of warning that pruning comes with risk, particularly if it's irreversible. And Cognition kind of hits this too. They talk about we have to be very careful with summarization. You can even fine-tune models to do it effectively.

That's actually why Manus kind of has the, the perspective that you should definitely use context offloading, so perform tool calls, offload the raw observations to, for example, disk so you have them. Then sure, do some kind of pruning, summarization, like Alessio was asking before, to pass back to the LLM useful information.

But you still have that raw context available to you, so you don't have kind of lossy, uh, compression or a lossy summarization. So I think that's a, an important and useful caveat to note on the point of kind of summarization or pruning.

You have to be careful about information loss.

Swyx30:06

Uh, this is something that people do disagree on, and I'll just flag this, uh, on pruning mistakes, pruning wrong paths. Um, Manus says keep it in and so you can learn from the mistakes.

Lance Martin30:18

Right.

Swyx30:18

Some other people would say that, well, once you've made a mistake- It's gonna keep going down that path that, oh, there's a mistake, you gotta, you gotta unwind. Or you just gotta, like, prune it and tell it, "Do not do the thing I know to be wrong," so you, so then you just do the other thing.

I don't know if you have an opinion, but, like, I would call this out as a... There was someone that s-that spoke yesterday that disagreed with this.

Lance Martin30:38

So that's actually very interesting. So Drew Breunig has a really nice blog post on context failure modes.

Swyx30:46

So he has a few. Um, just gonna-

Lance Martin30:48

Yes. This one, context poisoning. This is interesting. Drew Breunig has a nice blog post that hits this point. He talks about this theme of context poisoning, and apparently Gemini reports on this in their technical report. So he talked about, um, for example, a model can perform a hallucination, and that hallucination then is stuck in the history of the agent, and it can kind of poison the context, so to speak, and, and kind of steer the agent off track.

And I think he, he cited a very specific example from Gemini two five playing Pokemon they mentioned in the technical report. So that's one perspective on this issue of we should be very careful about mistakes in context that can poison the context.

That's perspective one. Perspective two is like you're saying, is if an agent makes a mistake, for example, calling a tool, you should leave that in so it knows how to correct. So I think there is an interesting tension there.

I will note it does seem that Claude Code will leave failures in. I notice when I work with it, for example, it'll, it'll kind of have an error, the error will get printed, and it'll, it'll kind of use that to correct.

So... And in my experience just working with agents in particular, for tool call errors, I actually like to keep them in personally. That's just been my experience. Uh, I don't try to prune them. Also, for what it's worth, it can be kind of tricky to prune from the conte- from the, from the message history.

Um, you have to decide when to do it. So you, i- you're introducing a bunch more code you have to manage. Um, so I'm not sure I love the idea of kind of selectively trying to prune your message history when you're building an agent.

It can add more logic that you need to manage, uh, within your kind of agent scaffolding or harness.

Swyx32:21

That's a classic sort of precision recall, but like sort of reinvented for, uh, context in a, in an agentic workflow.

Lance Martin32:28

Exactly. Exactly right.

Swyx32:30

While we're on the topic of Drew, Drew, Drew is, uh, obviously another, uh, really good author. Uh, he's-- so he's created, he's coined a bunch of like sort of context engineering lore. Um, any other, uh, commentary on, on stuff that, you know, you particularly like or disagree with?

Lance Martin32:45

I'll show you something kind of funny. If you go to his post, um, so he and I did, did a meetup on this, and I ac- I kinda like this quote from Stewart Brand. It was kind of comical.

"If you wanna know where the future is being made, look for where language is being invented and lawyers are congregating." So it... And it was talking about this, this idea of kind of why buzzwords emerge, and he actually was the one who turned me onto this idea that a term like context engineering kind of catches fire because it captures an experience that many people are having.

They don't come out of nowhere. And if you scroll down a little bit, he kinda talks about this. He has a whole post about kind of... I think it's how to build a buzzword. Um, but he talks a lot about this idea of, of kind of successful budwor- buzzwords are capturing a common experience that many of us feel.

And I think that's kind of the, the genesis of context engineering is also largely because many of us build agents. Ooh, there's lots of ways that can be quite tricky, and oh, context engineering is kind of what I've been doing.

And you hear a mon- number of people saying it, and then you k- it kind of resonates, and you say, "Oh, okay. Yes, that describes my experience." So I, I think-

Swyx33:47

Yeah

Lance Martin33:47

... that's just an interesting aside on, on kind of how language emerges anthropologically kind of in, in, in different communities.

Swyx33:52

Uh, well, I mean, I, I will co-sign this because that's exactly what I use to coin or come up with AI engineering.

Lance Martin33:59

AI engineer.

Swyx34:00

Um-

Lance Martin34:00

No, exactly

Swyx34:01

... just because, uh, people were trying to hire software engineers that were, uh, more up to speed with AI, and engineers wanted to work at companies that, um, would respect their work, uh, you know, and, uh, maybe also come out from the baggage of classical ML engineering.

Uh, a lot of AI engineers don't even need to use PyTorch because you can just prompt and, uh, do typical software engineering, um, and I think that's probably the right way, uh, at least in a world where most models are, most of the frontier models are coming from closed labs.

Lance Martin34:35

I think a, an interesting counter on this is, uh, when you, for example, people try to create language that doesn't really resonate, that doesn't ca-capture common experience, it tends to flop. So which is to say that buzzwords kind of co-evolve with the ecosystem.

They tend to kind of become big and, and resonate because they actually capture an experience. Many people try to coin terms that don't actually resonate, that go nowhere.

Swyx34:56

Alessio, do you have experience with that?

Alessio34:58

I'm the worst at naming things. Uh, but you do a great job, Sean.

Lance Martin35:02

Yes.

Alessio35:03

You nailed it, the, the few ones you put on Latent Space, so.

Lance Martin35:06

That's right.

Swyx35:07

Cool. Uh, well, you know, I, I wanted to talk about context engineering. Uh, i- okay, so, so, uh, sorry, I, I don't know if I sidetracked you a, a little bit with, uh-

Lance Martin35:14

No, that's perfect

Swyx35:15

... the meta stuff on, on, uh, Thoughty.

Lance Martin35:17

That hit, that hits a lot of the major themes. I can maybe just talk very brief about one more. We could talk about Bitter Lesson and some other things.

Caching35:21

Swyx35:24

Yeah.

Lance Martin35:25

Um, if you go back to that table, I just wanted to s- give Manus a shout because I thought they had one other very interesting point.

Swyx35:34

Oh, the, the table that you had.

Lance Martin35:36

Yes, exactly. So we ta-talked about offloading, re-reducing context, retrieval, context isolation. Those are, I think, the big ones you can see very commonly used. I do wanna highlight Manus. I thought they had a very interesting take here about caching, and it's a good argument.

When people have the experience of building an agent, the fact that it runs in a loop and that all those prior tool calls are passed back through every time is quite like a shock the first time you build an agent.

You have one token every tool call, and you incur that token cost every pass through your agent. And so Manus talks about the idea of just caching your prior message history. It's a good idea. I haven't done it personally, but it seems quite reasonable.

So caching reduces both latency and cost significantly

Swyx36:25

Yeah. Don't, but don't most of the APIs auto cache for you? I mean, if you're using like OpenAI, you would just automatically have a cache hit.

Lance Martin36:32

I'm actually not sure that's the case. For example, when you're building Age, you're passing your message history back through every time. As far as I know, it's stateless.

Swyx36:39

I think, uh, so there's different APIs for this across the different providers. Um, but especially if you use just the responses API, the new one, um, it should be that if you're just-- if you're never modifying the state, uh, which is good for people, uh, good for you if you believe that you shouldn't compress co- uh, conversation history, bad for you if you do.

Uh, if you never modify the state, then you can just use the assists API. Everything that you passed in prior is gonna be cached, which is, which is kinda nice. Anthropic used to require weird header thing, and they've made it more automatic.

Lance Martin37:12

Yeah, okay. So that's a good call-out. So I had used Anthropic's kind of caching header explicitly in the past, but it may be the case that caching is automatically done for you, which is, which, which is fantastic if that's the case.

I think it's a good call-out for Manus.

Swyx37:24

Yeah, Gemini also introduced implicit caching. You know, it's like it's, it's really hard to keep up. Like, you basically have to follow everyone on Twitter and just like read everything. Um, so that-

Lance Martin37:33

Yeah

Swyx37:33

... I mean, that's why I built a bot for it.

Lance Martin37:35

Yeah, yeah, yeah, yeah. Well, you know, you know, it's, it's interesting though. So APIs are now supporting caching more and more. That's fantastic. Um, I'd used Anthropic's explicit cache or he- caching header in the past. I do think an important and subtle point here is that caching doesn't solve the long context problem.

So it of course solves the problem of like latency and cost, but if you still have hundred thousand tokens in context, um, whether it's cached or not, the LM is utilizing that, that context. This came up. I actually asked Anton this in their context for our meetup, um, or, or in their context for our webinar.

Um, and, and they kind of had mentioned that the characterization of context rot that they made, they, they think they would expect to apply whether or not using caching. So caching shouldn't actually help you with all the context rot and long context problems.

It absolutely helps you with latency and cost.

Swyx38:27

Yeah. I, I, I do think, I do wonder what else can be cached. Um, I feel like the, this is definitely a form of lock-in, um, because you ideally want to be able to run prompts across multiple providers and, uh, and all that.

And, uh, yeah, caching is a, is a hard problem. Like I think ultimately, like you control your destiny if you can run your own open models because then you can also control the caching. Uh, here ev- every- everything else is just a half approximation of that.

Lance Martin38:57

That's right.

Swyx38:58

Yeah.

Lance Martin38:58

That's exactly right.

Swyx39:00

That is overall broad, uh, context engineering. Alessio, I don't know if you have any other takes from like the meetup yesterday or q- questions.

Alessio39:06

No, I think my main take from yesterday was like, um, quality of compacting. Um, I think there was like one of the charts was using the automated compacting of like, uh, open code, and some of these sources basically the same as not doing it, unlike the quality of what you get from the previous instructions.

And, um, I think Jeff had this chart that's like curated compacting is like two X better, but I'm like, how to? You know? It's like, how do you do curated compacting? I think that's something that, uh, maybe we can do a future blog post on.

Uh, I, I think that's interesting to me, like how do you compact, especially coding agents things where like it can get very, very long. I think for things like deep research is like, look, once I get the report, it's fine, you know?

But for coding, it's like, well, I would like to keep building. I, I found that like even when you're like writing tasks or like you're doing changes, having the previous history, it's like helpful to the model. It seems to perform better when it knows why it made certain decisions, and I think how to extract that in a way that is like more token efficient is still unclear.

Um, so I don't have, I don't have an answer, but maybe like a, a request for, for work by people listening.

Lance Martin40:15

Yeah. Y- y- you know, that, that's a great point, and it actually echoes some of Wald and Dan's points from Cognition also that the summarization compaction step is just, is non-trivial. You have to be very careful with it.

Devin uses a fine-tuned model for doing summarization within the, within the context of coding. Um, so they obviously spend a lot of time and effort on that particular step. Uh, and Manus kind of calls out that, uh, they are very careful about, uh, information loss whenever they do pruning, compaction, summarization.

They always use a file system to offload things so they can retrieve it. So it's a good call-out that compaction is risky when you're building agents, and very tricky.

Memory40:53

Swyx40:53

You know, I think there were a lot of, there's a lot of previously, a lot of interest in memory and, um, I'm always-- I was thinking about the interest interplay between memory and, uh, context engineering. Uh, I mean, are they kind of the same thing?

Is this just a rebrand? Uh, are there parts of memory-

Lance Martin41:09

Yeah

Swyx41:09

... and, uh, you know, you guys recently, uh, relaunched LangMem. That's also a form of context engineering, but I, I don't know if there's, there's like a qualitatively or philosophical difference.

Lance Martin41:20

Yeah. So that's a good thing to hit, actually. I'm maybe thinking about this on two dimensions: writing memories, reading memories, and then the le- degree of automation on both of those. So take the simplest case, which actually I quite like, Claude Code.

How do they do it? Well, for reading memories, they just suck in your Claude MDs every time. So every time you spin up a Claude, uh, Claude Code, it pulls in our Claude MDs. For writing memories, the user specifies, "Hey, I wanna save this to memory," and then Claude Code writes it to a Claude MD.

So on this axis of like degree of automation across read, write, it's kinda like the zero, zero. It's very simple, and it's kind of very like Boris pilled, like super simple, and I, I actually quite like it. Now, the other extreme is maybe ChatGPT.

So behind the scenes, ChatGPT decides when to write memories, and it decides when to suck them in. And actually, I thought Simon at AI Engineer had a great talk on this, and he... I- it wasn't about memory, but he hit memory in the talk, and he mentioned...

I don't know if you remember this, but it was a failure mode in image generation because he wanted an image of a particular scene, and it sucked in his location and put it in the image. Like it sucked in half, like half Moon Bay or something and sucked it in the image, and it was a case of memory retrieval gone wrong.

He didn't actually want that. So- Even in a product like Chap— ChatGPT that spent a lot of time on memory, uh, it's non-trivial. And I think my take is the, well, well the writing of memories is tricky, like when actually should the system write memories is, is non-trivial.

Reading of memories actually kinda converges with the context engineering theme of retrieval. Like memory retrieval at large scale is just retrieval, right? I, I kind of view them as-

Swyx43:03

It's retrieval in a certain context, which is your past conversations, which, um-

Lance Martin43:06

That's right

Swyx43:07

... you know, it, it is different than retrieval from a knowledge base, dif-different than retrieval from the public web. Uh, by the way, this is, uh, Sakan's, uh, writeup on his website, uh, on, on h- here, where he was just trying to generate images, and then suddenly it shows up.

Lance Martin43:21

That, that's exactly it. So th- th- there you go. Uh, a-actually, it's a subtle point. I, I don't know exactly know what OpenAI does behind the hood with respect to memory retrieval. My guess is they're indexing your past conversations using semantic vector search and probably other things.

So-

Swyx43:35

Yeah

Lance Martin43:35

... it may still be using, you know, uh, some kind of knowledge base, uh, or, or vector store for retrieval. So in that sense, I kind of view it just simply as, um, you know, in the case of sophisticated memory retrieval, it is just like a, a, you know, complex RAG system, in the same way we talked about with like Varun and building Windsurf.

It's kind of a multi-step RAG pipeline. Um, so I, I kind of-

Swyx43:58

Yeah

Lance Martin43:58

... view memories, at least the reading part, as just, you know, it's just retrieval. Um, and actually, I quite like Claude's approach. It's very simple. Just retrieval is trivial. Just suck it in every time.

Swyx44:10

Uh, totally. Um, I would also highlight, um, the sort of, uh, the semantic differences that you've, you've established, you know, episodic, semantic, procedural, uh, and background memory processing. We've done an episode with the letter folks on SleepTime Compute, uh, which I, I...

You know, I think these are just like, like if you h- if you have ambient agents, very long-running agents, you're gonna run into this kind of context engineering, which is previously the domain of memory, and, uh, I, I would say that the classic context engineering discussion doesn't have this stuff, not yet.

Lance Martin44:43

Yeah. So actually, there, there's an interesting point there. Uh, I did a course on building ambient agents, and I built, I had this little email assistant that I used to run my email. I actually think this is a bit of a sidebar on memory.

Memory pairs really well with human-in-the-loop. So for example, in my little email assistant, it's just an agent that runs my email, I have the opportunity to pause it before it sends off an email and correct it if I want, like change the tone of this email, or I can literally just modify the tool call to have a little UI for that.

And every time, one of these ambient agents, you edit, for example, or you give it feedback, you edit the tool calls itself, that feedback can be sucked into memory, and that's exactly what I do. So actually, I think memory pairs very nicely with human-in-the-loop, and like when you're using human-in-the-loop to make corrections to a system, that should be captured in memory.

And so that's a very nice way to use memory in kind of a narrow way that's just capturing user preferences, uh, in a... over time, and actually uses LLM to actually reflect on the changes I made, reflect on the prior instructions in memory, and just update the instructions based upon, uh, my edits.

And that's a very simple and effective way to use memory when you're building ambient agents that I quite like.

Swyx45:57

Uh, there's, there is a course which you can find on the GitHub. Um, and yeah, I mean, uh, you know, you guys have done plenty of talks on using agents.

Lance Martin46:04

That's right. But I, I think it, I think it's a very good point that memory is often kind of confusing when to use it. I think a very clear place to use it is when you're building agents that have human-in-the-loop, because human-in-the-loop is a great place to update your agent memory with your preferences, so it kinda gets smart over time and learn from you.

It is exactly what I do with my little email assistant. So Harrison, I'm, I'm sure, I think he said this publicly, uses an email assistant for all his emails, uh, and he gets a lot as a CEO. I, I get much fewer 'cause I'm just a lowly guy.

Uh, but I still use it. Um, and, uh, that's a very nice play- way to use memory, is kind of pair it with human-in-the-loop.

Swyx46:41

Yeah, totally. Um, I've, I've tried to use the, the email system before, but like, uh-

Lance Martin46:45

Yeah

Swyx46:45

... you know, I'm still, still very married to my superhuman. Um.

Lance Martin46:48

Yeah, fair enough. That's right. That's right.

Swyx46:50

Okay, so cool. Um, I think that, you know, that was, that was about the coverage that we planned on Context Eng. Um-

Lance Martin46:56

Yeah, it was great

Swyx46:57

... you have a little bit on, uh, Bitter Lesson that we could, uh, wrap up with.

Bitter Lesson47:01

Lance Martin47:01

Yeah. That's a fun theme to hit on a little bit. I'd love to hear your perspective. So there's a great talk from Hyung Won Chung-

Swyx47:10

Yep

Lance Martin47:11

... previously OpenAI, now at MSL-

Swyx47:13

Yep

Lance Martin47:14

... on the Bitter Lesson and his approach to AI research. So the take is compute 10 Xs every five years for the same cost, of course. We all know that. The kind of history of machine learning has shown, yeah, exactly this slide exactly.

History of machine lear- machine learning has shown that actually capturing this scaling is the most important thing. In particular, algorithms that are more general with fewer inductive biases and more data and compute tend to beat algorithms with more, for example,

hand-tuned features, inductive biases built in, which is to say, just letting a machine learn how to think itself with more compute and data rather than trying to teach a machine how we think tends to be better. So that's kind of the Bitter Lesson piece simply stated.

So his argument is this subtle point, that at any point in time when you're, for example, doing research, you typically need to add some amount of structure to get the performance you want at a given level of compute.

But over time, that structure can bottleneck your further progress, and that's kind of what he's showing here, is that in the kind of low compute regime, kind of on the left of that X-axis, adding more structure, for example, more modeling assumptions, more inductive biases, is better Than less.

But as compute grows, less structure, and this is exactly the Bitter Lesson point, less structure, more general tends to win out. So his argument was, we should add structure at a given point in time in order to get something to work with the level of compute that we have today, but remember to remove it later.

And a lot of his argument was, like, people often forget to remove that structure later. And I think my link here is that I think this applies to AI engineering too. And if you kind of scroll down, I have the same chart showing- -my little exa-exactly.

This is, this is my little example of building deep research over the course of a year. So I started with a highly structured research workflow. Didn't use tool calling. I embedded a bunch of assumptions about how research should be conducted.

In particular, don't use tool calling because everyone knows tool calling is not reliable. This was back in twenty twenty-four. Decompose the problem into a set of sections and parallelize each one, those sections written in parallel into the final report.

What I found is you're building LM applications on top of models that are improving exponentially. So while the workflow was more reliable than building an agent back in twenty twenty-four, that flipped pretty quickly as LMs got better and better.

And so it's exactly like was mentioned in the Stanford talk. You have to be constantly reassessing your assumptions when you're building AI applications given the capabilities of the models. And I talk a lot about here the structure, the specific structure I added, the fact that I used a workflow because we know tool calling doesn't work.

This was back in twenty twenty-four. The fact that I decomposed the problem because it's how I thought I should perform research, and this basically bottlenecked me. I couldn't use MCP as MCP got, for example, you know, much more popular.

I couldn't take advantage of the fact that tool calling was getting significantly better over time. So then I moved to an agent, started to remove structure, allow for tool calling, let the agent decide the research path. A subtle mistake that I made, which links back to that point about failing to remove structure, I actually wrote the report sections within each sub-agent.

So this talks-- This kind of links back to what we talked about with sub-agents in isolation. Sub-agents just don't communicate effectively with one another. So if you write report sections in each sub-agent, the final report is actually pretty disjoint.

This is exactly Alessio's challenge and problem about, you know, using multi-agent. So I actually hit that exact problem. So I ripped out the independent writing and did a one-shot writing at the end, and this is the current kind of version of Open Deep Research, which is quite good, and this is kind of the thing that's, at least on Deep Research Bench, the best performing open deep research assistant.

At least that, that's open source. So it was kind of my own arc, although we do have some faded results with GPT 5 that, that are quite strong. So you know, the models are always getting better, and so indeed, our open source assistant actually takes advantage and rides that wave.

Um, but I actually kind of experienced... I felt like I got, actually got Bitter Lessoned myself because I started with a system that was very reliable for the current state of models back in mid twenty twenty-four, early twenty twenty-four, but I was completely bottlenecked as models got better.

I had to rip out the entire system and rebuild it twice, rechecking my assumptions, um, in order to kind of capture the gains of the model. So I think, I just want to flag, I think this is an interesting, uh, point.

It's hard to build on top of rapidly expanding models or rapidly improving model capability. And actually, I really enjoyed from AI engineer Boris's talk on Claude Code and their very Bitter Lesson pilled. He talks a lot about the fact that they make Claude Code kind of very simple and very general because of this fact.

They want to give users unfettered kind of a-access to the model without much scaffolding around it. Yeah, exactly. He, he hits it in one of these slides.

Alessio52:29

Yeah. I, I don't know where.

Lance Martin52:30

Yeah, yeah, yeah. But, but I, but I think it's, it's an interesting consideration in AI engineering that we're building on top of models that are improving exponentially, and one of the points he makes is a correlator of the Bitter Lesson is that more general things around the model tend to win.

And so when building applications, we should be thinking about this. We should be adding structure necessary to get things to work today, but keeping an eye on improving models and keep... by keeping a close eye on models improving rapidly and removing structure in order to unbottleneck ourselves.

I think that was kind of my takeaway, so I really liked the talk, um, from Hyung Won Chung. I think that's worth everyone listening to. Um, and I think a lot of the lessons apply to AI engineering.

Alessio53:17

I think this is similar to incumbents kind of like adopting AI, putting AI in existing tools because you already have the workflow, right? So you already have all the structure. You just put AI, it becomes better. Um, but then kind of like the AI native approaches catch up as the models get better, and then it...

there's, like, there's no way for existing products to remove the structure because the structure is the product.

Lance Martin53:39

Yes.

Alessio53:39

You know? And that's why then you have, you know, Cursor and Windsurf are being... are better than VS Code for like AI native thing just because they didn't have to deal with removing things and why Cognition is like, you know, uh, again, it's like it doesn't even think about the ID as like the first thing.

The ID is like a piece of the agent. Um, and so I think you see this in a lot of markets, which is like, hey, again, if you have a workflow and you put AI, the workflow is better.

Lance Martin54:05

Yes.

Alessio54:05

Like the workflow is not the end goal, you know? Um, and so I, I think we're now at a place where, like, you should just start without a lot of structure just because now the models are, like, so good.

But I think-

Lance Martin54:15

Correct

Alessio54:15

... the first two and a half years of the market, there was kind of like the stance of, like, should I just put AI into the workflow that works? Should I rewrite the workflow? But the workflow is not that good because the models are not that good.

Um, but I think we're past, we're past that point now.

Lance Martin54:28

That's an amazing example. Actually, if you show your chart again, there's another interesting point in your chart. An interesting point here is that in the kind of earlier model regime, the structure approach is actually better And so an interesting take on this, so, um, Jared Kaplan, the founder of Anthropic, has a great talk at Startup School from a couple of weeks ago, and he mentions this point about oftentimes building products that explicitly don't quite work yet can be a good approach because a model under them is improving exponentially, and it'll kind of unlock the product, and we saw that with Cursor.

So, like, part of the Cursor lore is that it, it did not work quite... It did not work particularly well. Claude 3.5 hits, and then boom, it kind of unlocks the product. And so you kind of hit that knee of the curve when the model capability kind of catches up to the product needs.

But in that, in that kind of earlier regime, the structured approach appears better. So it's kind of this interesting subtle point that for a while, the more structured approach appears better, and then the models finally hits the capability needed to unlock your product, and then suddenly your product just takes off.

There's kind of another, a corollary to this that you can get tricked into thinking your structured approach is, is indeed better because it'll be better for a while until the model catches up with less structured approaches.

Swyx55:46

Your chart looks very similar to the Windsurf chart. Uh, I gotta bring it up because, uh, I, I was involved in this, in the writing of this one. Isn't that similar? There's a, there's a, there's the ceiling, you know, and then, like, boom, you, you, you go slow.

It's-

Lance Martin55:59

That's it

Swyx55:59

... this is almost like Bitter Lesson, but in, like, uh, enterprise SaaS.

Lance Martin56:03

That's right. That's right.

Swyx56:07

Very similar. Very similar. I, I, I just like, you know, for me, like, okay, the lines are important, but to me, the bullet points are the main thing. If you understand the bullet points, then you cannot... You can actually learn from the, the, the mistakes of others.

Uh-

Lance Martin56:19

Right

Swyx56:19

... so this is... I spend a lot of effort on the bullet points.

Lance Martin56:21

Right.

Swyx56:22

Cool. Yeah, I mean, uh, so generally, you know, um, there is one spicy take on, on this, which is, like, you know, how much is LangGraph aligned with the Bitter Lesson? Uh-

Frameworks56:22

Lance Martin56:33

Yes

Swyx56:33

... obviously, you guys are obviously aware of it, so it's not gonna be a surprise. But I do think that making things, making abstractions easy to unwind is very important if you believe in the Bitter Lesson, which, which you do.

Lance Martin56:45

No, no, this is super important actually, and I actually talk about this at the end of the post.

Swyx56:49

Yeah.

Lance Martin56:49

There's an interesting subtlety when you talk about agent frameworks, and a lot of people are anti-framework. I completely understand and sympathetic to those points. But I think when people talk about frameworks, there's two different things. So there can be l- a low-level orchestration framework.

There's a great talk, for example, at, um, Anthropic from Shopify. They built this kind of orchestration framework called Roast internally, and, uh, it's basically LangGraph. It's some kind of way to build kind of internal orchestration workflows with LLMs.

And Roast LangGraph provides you low-level building blocks, nodes, edges, state, which you can compose into agents, you can compose into workflows. I don't hate that. I like working with low-level building blocks. They're pretty easy to tear down, rebuild.

In fact, I, I used, for example, LangGraph to build Open Deep Research. I had a workflow. I rip it out. I rebuild with agent. The building blocks are low level, just nodes, edges, state. But the thing I'm sympathetic to is s- there's also, in addition to just kind of low-level orchestration frameworks, there's also agent abstractions, like from framework import agent.

That is actually where you can get into more trouble because you might not know what's behind that abstraction. I think when a lot of people kind of are anti-framework, I think what they're really saying is they're also anti-abstract.

They're, they're largely anti-abstraction, which I'm actually very sympathetic to, and I part... I don't particularly like agent abstractions for this exact reason, and I think Wald and Janz made a good point, like we're very early in the archive agents.

We're, like, in the HTML era, uh, and, and agent abstractions are problematic because you don't know what's necessarily under the hood of the abstraction. You don't understand it, and if I was building, for example, you know, Open Deep Research with an, with an abstraction, I wouldn't necessarily know how to rip it apart and rebuild it, uh, when the models got better.

So I'm actually wary of abstractions. I'm very sympathetic to that part of the critique of frameworks, but I don't hate low-level orchestration frameworks that just provide nodes, edges. You can just recombine them in any way you want, and then the question is why use orchestration at all?

And actually, I use LangGraph because you get some nice use... You get checkpointing, you get state management. It's low-level stuff, and that's the way I happen to use LangGraph, and that's why I like LangGraph. Uh, and that's actually why a lot of...

I found, like, a lot of customers like LangGraph. It's not necessarily for the agent abstraction, which I agree can be much trickier. Some people like agent abstractions. That's completely fine as long as you understand what's under the hood, but I think that's a very interesting debate about frameworks.

I think the critique is it should be made a little bit more on abstractions because often people don't know what's under the hood.

Swyx59:27

For those who are looking for resources, uh, it was a bit hard to find the Shopify talk because it's unlisted.

Lance Martin59:33

Yeah. It's unlisted now. Exactly. I don't know why it's unlisted, but it's, it's a nice talk.

Swyx59:38

I found it through the, this Chinese, Chinese rip-off of the talk.

Lance Martin59:42

Funny. There you go. Yeah. It's hard... It's actually hard to find now.

Swyx59:46

I think there should be a browse conf where, uh, you find obscure YouTube videos because that's something I'm very good at. Uh, it's kind of my bread and butter.

Lance Martin59:54

It's good, and w- you know, what's funny is this talk follows exactly the arc we often see when we're talking to companies about LangGraph. It is people wanna build agents and workflows internally. Everyone rolls their own. It becomes hard to kind of manage and coordinate and review code.

In lo- in this context of large organizations, it can be very helpful to have a standard library or framework that people are using with low-level components that are easily composable. That's, that's what they build with Roast. That's effectively what LangGraph is, and that's why a lot of people like LangGraph.

I actually thought the talk on MCP that, uh, I believe it was, it was, um, at AI Engineer, it was, um, John Welsh.

Swyx1:00:34

Yes. I, I, I think that was, like, a super underrated talk. I tried yelling about it. No one listened to me, but, like, you know, if you listen this far into the podcast, do us a favor. Actually listen to, uh, John Welsh's talk.

It's actually very good.

Lance Martin1:00:47

It's very good. So, so actually, what-- He makes a case for a lot of the reason why people actually, for example, enterprises, larger companies like LangGraph, which is the fact that when tool calling got good within Anthropic in, you know, sometime mid last year, he actually makes this point explicitly.

Yes, exactly. It's, it's somewhere right around here. Actually, there's a timeline slide if you go back like one or two. It's very good. So this, this is very interesting. So he mentions, okay, so you're in Anthropic, tool calling gets good in mid twenty-twenty-four.

Everyone's building their own integrations. It becomes complete chaos, and that's actually where kind of MCP came from. Let's build a kind of a standard protocol for accessing tools. Everyone adopts it, much easier to kind of have auth and have review, and you redu-- minimize cognitive load.

And this is actually the argument for standardized tooling, whether it be frameworks or otherwise, within larger orgs, is practicality. And he actually... His, his whole talk is making that very pragmatic point, which is actually why, um, people do tend to like kind of frameworks, uh, for example, in larger, in larger organizations.

Swyx1:01:51

Agreed. Um, and then, and then ship it as a gateway. Uh, this is the-

Lance Martin1:01:55

Right

Swyx1:01:56

... the, the other, uh, big, um, thing that they do. Um-

Lance Martin1:01:59

That's right.

Swyx1:02:00

Lance, you've been so generous with your time. Thank you. Uh, any shameless plugs, uh, calls to action, stuff like that?

Lance Martin1:02:06

Yeah. If you all made it this far, thanks for listening. Um, we have a, a bunch of different courses I've taught, uh, one on MB and Agents, uh, one on building Open Deep Research. So I, I actually was very inspired by, uh, Karpathy.

He had a tweet a long time ago talking about building on-ramps. So he talked about he had his Micro-RAG repo. A few people looked at it, but not that many. He made a YouTube video, and that created an on-ramp, and the repo skyrocketed, skyrocketed in popularity.

So I like this one-two punch of building a thing like Open Deep Research, then creating a class so people can actually understand how to build it themself, and I kinda like that. Build a thing, create an on-ramp for it.

So I have a class on building Open Deep Research. Feel free to... It's for free. Um, but it ha- walks through a bunch of notebooks as to how I build it and, and you can see the agent's is quite good.

We even have better results coming out soon with GPT 5. So, uh, if you want kind of an open source deep research agent, have a look at it. Um, it's, uh, it's been pretty fun to build, and that's exactly what I talk about in that Bitter Lesson blog post as well.

Swyx1:03:01

Awesome, Lance. Thank you for joining.

Lance Martin1:03:03

Yeah, a lot of fun. Great to be on.