Inside The Agent Loop with Pierce Boggan

Inside The Agent Loop with Pierce Boggan

Visual Studio Code

0:00 Welcome back everyone to the VS Code Insiders podcast,

0:04 your one-stop shop for everything VS Code,

0:06 your favorite code editor in the entire world.

0:08 I'm James Monte Magno, and with me,

0:10 back for the 18th time, I don't know, 20th time.

0:12 We only have like 20 podcast episodes, so it can't be that many.

0:15 Here's Brian, how's it going, buddy?

0:16 It's going great.

0:18 I'm going to put your face directly into my teleprompter,

0:21 so now it's just like, wow, I can stare directly into your soul.

0:23 I love it.

0:25 I love it.

0:25 I'm here in a garage, you're here in like some new setup.

0:28 What is going on?

0:29 You're like at Yeah, I finally moved into a real office after all this time.

0:33 I got out of my basement, so um I figured it was time for the upgrade in 2026.

0:37 You're so grown up, I love it.

0:39 Very nice.

0:40 Looks good.

0:41 Uh Looks good.

0:42 Uh today, so we're kind of building on a bunch

0:45 of exciting enhancements that have really come over the last several months,

0:51 uh in and around how developers are working with agents,

0:53 actually how the agents are working with themselves and other things.

0:56 We had Harold on a while ago talking about sub agents,

0:59 and we ended up kind of going into even custom agents and orchestration,

1:03 and I think that's a really cool like advanced scenario.

1:05 However, what I've noticed is that there seems to be I send a prompt,

1:10 and inherently, there seems to be this loop happening that is that is churning,

1:15 and at the end of the loop, there's a response that comes back,

1:18 and that loop has changed dramatically over the last,

1:22 you know, 6 7 8 months as sort of agentic development has evolved,

1:27 and this agent loop, if you would call it that, has really evolved,

1:31 and I think we get tons of questions

1:32 on Twitter and on Reddit about what is this thing, what is that, what is that?

1:35 Oh, is that the model?

1:37 I didn't pick that model.

1:37 What's this model?

1:38 And and what about my context window?

1:40 And what's going what's going on here, right?

1:43 And I think because things are evolving so quickly,

1:46 and we get updates every day or every single week,

1:49 for me at least, like just happening, right?

1:52 And and I I can dive through the documentation to figure

1:54 out what's going on, but then I have these questions as like,

1:57 what is a sub agent actually doing,

1:59 and how does it actually work, and should I actually care?

2:01 Like, so I want to dive deeper into the agent loop,

2:04 and maybe you can peel back the layers of of of what I

2:07 just said as far as like how the agent loop maybe has started,

2:11 how it evolved, and where it's at today, and where it's going.

2:14 Yeah.

2:15 I mean, it's such a big topic.

2:17 I literally, it's funny that this was the topic

2:19 for today because I just got back from visiting a customer,

2:21 and I did a 6-hour presentation.

2:24 So, we'll try not to have a 6-hour podcast,

2:27 cuz there's a lot you can dive into here.

2:30 Um but yeah, you're right, like we talk about this agent loop.

2:33 So, what is it?

2:34 So, I'm going to use some like approximations, they may not be exactly correct,

2:38 uh but I think they're helpful for understanding mentally how this thing works.

2:42 Um so, imagine you just basically have a giant while loop, right?

2:46 Um and uh that while loop starts when you hit enter on your first prompt.

2:52 Um and basically, what's happening in this loop is

2:55 every there's many many interactions with the model, right?

2:58 Um and in each interaction,

3:00 you basically uh it's just an API request to a model, right?

3:03 Uh and within that API request, there's several components.

3:07 Uh so, you have uh the system prompt.

3:10 Uh this [snorts] is actually dynamically built for every single

3:14 kind of combination of things you pick in the picker.

3:15 So, if you're picking a different model, a different family,

3:19 that's giving you a different set of prompts, actually.

3:21 Um so, there is no one prompt for Copilot.

3:23 There is some basic uh responsible AI safety

3:26 prompts that every single uh Copilot request has,

3:29 but outside of that, uh it's dynamically

3:31 built and optimized specifically for that model.

3:33 So, we work a lot with the model providers in advance of shipping

3:36 the model to really tune the prompts for the best possible results.

3:39 Um so, there's a huge feedback loop that happens pre-launch

3:42 on that, and then also a huge feedback loop that happens post-launch on that.

3:45 So, we'll do like things like AB experiments,

3:47 test alternative prompts based on hypotheses we have, and there's a huge kind

3:51 of pre-launch optimization loop with offline evaluations,

3:54 and then uh post-launch uh improvement loop with online evaluations.

3:59 So, you have the system prompt, right?

4:01 Then, you have uh other things we append to that.

4:04 So, explicit context,

4:06 things you mentioned like you're like at hello.tsx, that's that's mentioned.

4:10 We have implicit context that we include.

4:12 So, if you have an editor uh like a file open in the editor,

4:16 and you start an agent session,

4:17 we consider that to be pretty high signal that like your thing

4:21 might relate to the the the editor you have open, right?

4:24 So, we attach that.

4:25 Uh if you have running terminals, things like dates, right?

4:28 Your environment information, your you know,

4:29 terminal configuration, things like that are auto-attached.

4:32 Um then you have tools, right?

4:35 So, this is really the foundation of the agent loop.

4:37 When you think about like chat,

4:39 um chat was like you send a prompt yes to the model, so from that perspective,

4:43 it's similar to what we have today,

4:45 but then the model can just send me back a text response.

4:47 And now, actually, what happens is there is a set of built-in tools,

4:51 um as well as uh tools that you can add for things like NCP and other things.

4:56 Um and basically, you can say to the model,

5:00 you can pick one of these tools, or you can give me back a text response.

5:03 So, like maybe it's searching, maybe it's uh creating a file,

5:07 maybe it's editing a file, right?

5:09 Uh maybe it's calling the GitHub NCP server,

5:11 and each of those tools has a schema and a description.

5:13 So, it says, this is what this tool does, um here's the parameters, right?

5:17 So, then the model, if it says, okay,

5:19 the first thing I think I need to do is search.

5:21 Okay, well, we'll use the search tool,

5:23 and then the model will fill in those parameters,

5:25 and then pass that back to us, and we'll execute the tool.

5:27 So, then you have tools, right?

5:29 And then we have your user prompt, right?

5:31 And so, that's sent to the model.

5:32 Uh so, that's that's kind of the basic foundation.

5:35 And then, what's happening in the agent

5:36 loop is that's just continuously going, right?

5:39 So, the model is given the outputs

5:41 of the previous thing and able to iterate on it.

5:43 So, okay, we do a search.

5:45 Okay, so now we have a list of files we could potentially read.

5:48 Okay, now the agent might call the tool to read some of these files.

5:51 Okay, now we have the right context.

5:52 Okay, now I think I have the information I need

5:55 so that I can go place and edit in a file.

5:57 Okay, I'll call the edit tool, right?

5:59 Okay, now I think I'm done, so I'm going to respond with that kind

6:02 of some text to the user summarizing what happened.

6:04 Uh and then the agent will basically return like a stop message and say, "Hey,

6:08 I'm done." And then that's when like the conversation in VS Code wraps up,

6:12 and and you're able to send it out of prompt.

6:14 So, that's the the basic foundation of the agent loop.

6:17 Makes a lot of sense.

6:18 There's actually a lot of things happening pre,

6:20 you know, before the actual user prompt, right?

6:23 And I think it feels as though, you know,

6:27 the set of tools and options have grown, right?

6:31 Cuz not only do you have bypass,

6:32 do you have autopilot mode, do you have just normal interaction mode,

6:35 do you have planning mode, do you have custom agents,

6:36 do you have ask mode, do you have these normal agent interactive mode, right?

6:40 And then, inside that, you have all the models

6:41 and reasoning levels and all these different things.

6:44 So, it's fascinating to kind of learn about this, and then also,

6:47 like you said, all the tools that are available.

6:49 What I've noticed a lot is those agents are going off,

6:52 and there's a lot of like research and investigation happening, right?

6:56 And this is kind of always happens.

6:57 Like, okay, I need to go figure out how to add this button somewhere.

6:59 Well, where am I going to put it?

7:00 What file is it?

7:01 It's greps around and reads around and reads files, um in general,

7:06 but I think in that loop that you're talking about,

7:10 it feels as though is that all happening

7:13 in a in just one single agent, one single thing?

7:17 Because I feel as though there's branches that are happening that I'm seeing,

7:21 cuz I'm a big like reader, right?

7:23 Like, I love to read what's happening in the chat.

7:25 Like, oh, and drop-downs, they collapse, and there's little output here,

7:28 and it's doing this thing, it's doing that thing.

7:30 So, who who is calling what in this agent loop?

7:33 Like, who is deciding what gets called?

7:37 Uh the model is deciding based off the context it's given.

7:40 And it's just iterating over the previous

7:42 output and appending that to the message.

7:44 Um so, like I think the foundations that we just said are very important.

7:48 There is much more advanced techniques that we can talk about now, like, okay,

7:52 when you start thinking about sub agents and orchestration and all these things,

7:54 how do these things actually work?

7:56 Uh how do all these customizations work?

7:58 When I have a skill versus an instruction versus uh a prompt file,

8:02 like the the reality is all of these things

8:05 are just modifying that basic construct in different ways, right?

8:08 So, uh let's think about something basic like an instruction.

8:11 It is text that is appended to your prompt.

8:14 If it's a global instruction, it's always appended.

8:17 If it is a an instruction file where you have the glob pattern,

8:20 it's selectively appended, right?

8:23 Uh if you have a skill, right?

8:24 Basically, in the prompt, uh the model is given a list of skills,

8:28 just like it's given a list of tools.

8:29 It can choose to go read that skill.

8:31 And then, what happens?

8:33 It's just appending text, right?

8:35 And then this is more context for the model to make its decision, right?

8:38 Um what happens when you have NCP servers?

8:42 Well, this is just appending the built-in tool list, right?

8:45 That you see um in the agent loop.

8:48 So, now you've given the model more tools.

8:50 And I think when we think about like harnessing

8:54 and like all the decisions we have to make,

8:55 there's a actually an enormous amount of tradeoffs we have to make as a product

8:58 team to decide what are the different strategies we want to use, right?

9:02 So, um sure, we can add a million things to the prompt, right?

9:06 But this fills context, right?

9:08 Sure, we can add like, I see some people like,

9:11 I want to have a thousand tools, a tool for everything.

9:13 Okay, well, going back to the foundations for how these models work,

9:17 the model has to make a choice, right?

9:19 It has to decide between these all these options you give,

9:21 which is the most optimal.

9:23 And just like a human, when you give people more choices,

9:26 their ability to pick the right choice degrades, right?

9:29 Uh and so, there's an enormous amount of optimization

9:30 going in from our side that you don't actually see,

9:33 and we don't really talk about, we should talk about,

9:36 uh but we don't talk about very much around like tool optimization,

9:39 like, what are the right tools, how many tools should we have?

9:41 Uh we have custom models that will basically take the tool list,

9:45 if you did have 1,000 tools,

9:46 and basically refine that to like,

9:48 these are the tools we actually think are important

9:50 for this session based off what the model says.

9:52 Some of these tools also have their own

9:54 like custom models we built behind the scenes.

9:56 So, like you mentioned context gathering.

9:58 Right?

9:58 We have a custom model for agentic code retrieval.

10:01 Uh because that it turns out if you don't have the right context,

10:03 you don't know where to place an edit,

10:04 which is pretty important for the agent loop, right?

10:06 Yeah.

10:06 Yeah.

10:07 There's a lot of kind of micro decisions you

10:09 make with these things and like then as someone prompting,

10:12 it's it's kind of helpful to know when you do certain things,

10:15 what does that mean?

10:16 So, if you tell the model to do something and then you're like,

10:19 "No way, do something else." right?

10:21 Going back to those first principles, right?

10:23 Each of those messages are just getting appended to the end as text, right?

10:27 So, it's possible that the model is smart enough to say, "Hey,

10:30 I understand the last message the user sent me was correcting a previous

10:33 thing." We can also understand how now in this history of text,

10:39 the model in in the same request

10:40 API request has two different instructions, right?

10:44 This is generally good that the agent is

10:45 building on the last thing it did, right?

10:47 I wanted to build on the I wanted to make

10:48 an edit based off the context that we have gathered, right?

10:51 Exactly, yeah.

10:51 It can also lead to bad behaviors, right?

10:54 Uh so, that's when the agent starts going down a really bad path,

10:56 that's why it's important to kill it,

10:58 back up and and understand why do you think it's going down this path

11:00 because the previous token that the model gets informs the next token, right?

11:05 Um so yeah, there's a there's a whole

11:07 bunch of really interesting things there in terms

11:10 of like how this agent loop this is optimized and all the choices we make.

11:13 I I think on the VS Code team, we have you know,

11:16 15, 20 people probably who are working exclusively on this problem, right?

11:19 Uh building the best harness that we can so that you get really,

11:22 really good code quality results from this thing.

11:24 Uh with Opus 4 6, James,

11:26 I think we're getting 90% of Opus 4 6 code in our harness committed.

11:31 Um this is this is pretty amazing.

11:33 Uh GPT-4 1, when I first started on this team, we were 52, 53%.

11:37 So, this is the improvement we see in 1 year.

11:40 Um so, there's an enormous amount of work that goes

11:42 in not just to partnering with our model friends,

11:44 but optimizing those prompts so that we in tools

11:46 so that we give you the best results.

11:47 Yeah, I think like this loop and it's what's fascinating

11:49 and why this is so important is because what people

11:53 may not know is is is that work in the harness

11:56 is really custom tailored not only to the tools,

12:00 but to the model and that evolves over time, right?

12:02 These these evaluations,

12:04 these prompts that we've talked about on the pod before,

12:07 but in general when you think about it,

12:09 like today's a launch day, Opus 4 7 came out when we're recording this pod Yes.

12:14 like to say like today is like the worst day

12:15 to use that model because it's a brand new model.

12:18 Like everyone's going to be trying to use it cuz it's so capacity and then Yes.

12:22 the system prompt, it's fresh.

12:24 It's it's it's a newborn.

12:25 It's it's an infant state, right?

12:28 And there's yet been time to go work and and hone it,

12:31 but you really see within a few weeks, even like that first week, you know,

12:35 the the system prompt like things how are are working,

12:38 yeah, how it works with tools,

12:39 how things work with all the models work different,

12:40 even incrementally from like 4 5 to 4 6 to 4 7, right?

12:43 You know, in in a in a in a 5 3 to the 5 3 Codex,

12:46 all think a little bit different.

12:48 But then it quickly evolves over time.

12:51 Yeah, definitely.

12:52 Um like of course we try our best pre-launch.

12:54 We you we usually get access to the model several weeks,

12:57 if not uh several months before.

13:00 Um and then we're working with kind of people from Anthropic,

13:03 Gemini, uh OpenAI, xAI, etc.

13:07 to like really refine those prompts based

13:10 off what we're seeing basically in our harness.

13:12 So, we run a ton of we have

13:13 our own uh kind of SWE-bench equivalent called VS SWE-bench.

13:16 It's built on custom problems.

13:17 It doesn't have all the pollution issues that SWE-bench has now.

13:20 I don't even think the labs actually use SWE-bench anymore because

13:23 of all the pollution we see in the training data for this benchmark.

13:26 So, we built our own.

13:27 Um and then basically we have a ton

13:28 of different cases and we run many many runs,

13:31 not just one, but many many runs to to reduce variance and you spot patterns.

13:36 You look at what we call the agent trajectory.

13:39 Uh so, that's basically the path at which the agent takes to solve your problem.

13:43 Right?

13:43 So, it's not even just did we solve your problem, yes no.

13:46 That's a very simplistic way of looking

13:48 at something like resolution rate at benchmark.

13:50 No, we're we're actually going and saying like,

13:52 "What is the path the model took and was that an optimal path?

13:55 How can we influence the path the model takes?

13:57 How can we get you to that really good resolution rate in fewer steps, right?

14:02 Uh so that you get actually really high quality results,

14:04 but instead of waiting 1 hour, right?

14:06 You're waiting, you know, 1 minute, right?

14:08 And so, those are the sorts of things we

14:10 do and every problem kind of brings its own thing.

14:12 So, we do a lot of optimization there.

14:13 And then as you say, like we do the best we can,

14:15 but offline evaluations are always flawed, right?

14:18 It's a very small subset of data as much

14:20 as we try to improve the the cases that we have.

14:23 Um so then post-launch as you say, like the there's capacity things like both

14:28 on our end and upstream providers, right?

14:30 Um and we have to kind of figure out what demand looks like.

14:33 It's different for every single model.

14:35 It's hard to predict demand in an agentic world

14:37 where people run now 10 agents at once, right?

14:39 Um and more and more people are using it agents every day.

14:42 So, demand prediction is very difficult.

14:44 Um and then also like to your point like when it's out there,

14:49 we can do things like run AB tests and and basically

14:51 actually know in the wild what is better, right?

14:53 Not a hypothetical in our in our offline evaluation cases,

14:56 but actually know what's better.

14:57 Uh and of course the model providers also have their own updates they

15:00 make to the models and so they see things and improve stuff like that.

15:03 Um so yeah, like that's all part of the continuous loop that's happening.

15:07 So, there's like continuous work on models

15:09 that have we have already shipped to optimize them.

15:11 There's new models in the queue we're working on optimizing.

15:14 There's generic kind of prompt

15:16 and tool optimizations that are constantly happening.

15:19 And then for many of these things, there's also custom, you know,

15:21 purpose-built models actually being created by our data science

15:23 team to go and actually solve really hard problems there.

15:26 Yeah, it's crazy.

15:27 There's there's a lot of little tiny things that are

15:29 happening that I think people don't actually even realize.

15:32 Like when you start a chat, like it update the name of the chat.

15:36 Like that's a that's pretty sure it's a custom Right?

15:38 Yeah, we're passing the conversation history to a a cheap model,

15:41 admittedly, cuz there's no reason to use Opus for this.

15:43 We need to get uh we need to get a title back

15:46 very quickly and it's okay if it's not exactly the perfect title.

15:49 Um But yeah, that's an LLM call, right?

15:51 So, there's there's a lot of other things always

15:52 happening in the product that maybe like you don't appreciate.

15:55 Yeah.

15:56 There's like some random if statement like uh that generated

15:59 the title in this way based off this heuristic.

16:01 That's actually going and hitting a model, right?

16:03 So, Yeah.

16:04 It's and and some of the things that become

16:06 like second nature to me, which is like, oh,

16:08 I just like, you know, click a button to like generate a commit message,

16:11 generate a PR, click a little button.

16:14 And those are all things happening and those are also things that are tweaking.

16:16 They're they're they're they have their own little tiny

16:18 agent loop of things that are happening as well, right?

16:21 Yeah.

16:21 And that that are just transparent to you,

16:23 those AI edits and there's actually like

16:25 modifying code and editing code by hand, right?

16:27 There's tons of things happening in the next edits and the suggestions.

16:31 I think the biggest question we get part of this agent loop,

16:34 which is more of the advanced scenario that we've seen it time and time again,

16:38 which is why I really wanted to talk about the agent loop,

16:40 was part of when the agent is figuring out if

16:44 it should do something or if it should delegate work.

16:47 And when I mean delegate work, I mean to sub-agents.

16:51 Yes.

16:51 Now, we got this question recently on Twitter.

16:55 Uh I forgot about exactly who it was from.

16:57 I had we had a big conversation.

16:59 Um and I was pulling up docs from OpenAI, our documentation,

17:01 the Claude code docs, like all the different docs, right?

17:04 And understanding here's how these models work, how these harnesses work.

17:06 When I say harness, like like the It's I guess describe harness.

17:12 It it's kind of a a rough definition,

17:13 but it's like all the things that combine to basically make that agent loop.

17:16 So, like the the prompts that we have, the context that it's able to gather,

17:21 uh the tools that we provide it, like the custom models behind the scenes.

17:24 That's all the the magic that actually gets you good results.

17:27 Yeah.

17:27 So, CLI has a harness, VS Code has a harness,

17:30 VS has a harness, other coding agents have harnesses, harnesses in general.

17:35 And that's why you get different behavior between

17:36 different things cuz there's different harnesses, different prompts.

17:39 So, the question we got was, "Hey,

17:41 I chose um I think Opus 4 6 or maybe 5 or or OpenAI uh you know,

17:48 GPT-5 4 or Codex and I see a bunch of work being done.

17:53 I see this loop happening and then I see a bunch of sub-agents exploring,

17:59 grabbing code, doing things, Yes.

18:02 but it's using a different model.

18:04 It's using Haiku or it's using a mini model, for example.

18:09 And the question I got was, "How is this actually working?

18:13 Why is it using different models?

18:16 And what is is is the VS Code team pulling a fast

18:20 one over my eyes?" That's That's how That's how it read.

18:23 It didn't actually how it It didn't That wasn't what was written,

18:25 but that was my interpretation.

18:27 Like, "Hey, are you guys pulling one over my eyes

18:29 here because you guys pulling a bait and switch?

18:31 I thought I'm 3x in over here.

18:33 Now you're 0.33 and over here.

18:34 What's going on?

18:36 And what's the advantage?" I think at the end of the day, Yeah.

18:39 we could talk about the solution, but actually talking about the problem,

18:43 the why is more important than like how it actually works.

18:46 Yeah, that's that's correct.

18:48 Um well, first like we're all of our incentives on on the VS Code

18:53 and GitHub Copilot teams are to build

18:55 the best possible experience for you, right?

18:56 So, so that is our North Star goal and we will like we will not pull fast

19:01 one on you because that is not what we are as a team incentivized to do, right?

19:04 I I don't want to do this, right?

19:06 Um that's ever been part of our culture in in GitHub or VS Code.

19:09 Um yeah, so like going back to to basic primitives, right?

19:13 Um let's just talk about sub-agents and then we'll

19:16 get into the specific case of this sub-agent, right?

19:19 Um so like for instance, um going back to the basic mechanism for agent loop.

19:25 So, a sub-agent is basically like this main agent can decide,

19:29 "I want to go uh basically do this workflow,

19:32 run this agent loop again with fresh context.

19:35 I want to tell it what to do as a goal." So,

19:37 the main agent is basically prompting this other

19:40 agent to go do something with fresh context.

19:43 The agent will run its own kind of loop, like just like the main one.

19:47 Uh and then it will just like a function,

19:49 it has a result and it will return back to main thread, right?

19:52 Uh so, that's essentially what a sub agent is.

19:54 So how does it work?

19:55 How does it decide when to call a sub agent?

19:58 Well, let's go back to basic mechanisms.

20:01 A sub agent is just a tool the model can choose to use.

20:04 So the model can selectively say I want to use the run sub agent tool, right?

20:11 It can choose to to to select this in the magic agent loop, right?

20:15 And that will be returned back to VS Code in this case.

20:19 And then VS Code will go spin a sub agent, right?

20:22 Based off the input parameters that has been filled by the model, right?

20:27 So it is just basically a tool call, right?

20:30 Which is interesting.

20:30 This is why it's so interesting to understand the basic mechanisms.

20:33 So then how do you actually get it to call a sub agent?

20:36 So then it's it's kind of basic pro- prompting, right?

20:39 Like you could be very explicit in your user prompt

20:42 that you want sub agents to be used for certain things.

20:45 We could have things in our prompts

20:49 that are quite explicit about using sub agents.

20:52 That's also a possibility, right?

20:54 So like the system prompt could be very aggressive about saying

20:56 we want to use sub agents for these sorts of things.

20:59 And some features do, right?

21:00 Like if you've ever used inside of Copilot CLI or research or things like this.

21:06 Again, same basic mechanism.

21:08 It's just aggressively prompted to really rely on the sub agent strategy, right?

21:12 Which really allows you to keep that main agent loop super fresh cuz

21:15 remember we're just appending the result

21:17 of all the conversations to the main loop.

21:20 Well, if you're doing all that in the main process, right?

21:21 Your main process gets very convoluted.

21:24 The agent will get confused.

21:25 You'll have to compact the conversation which you generally do want

21:28 to try and avoid cuz you're going to lose some fidelity.

21:31 So sub agents are really a strategy.

21:33 So then okay, now getting back to original question.

21:35 Explore sub agent.

21:37 So I mentioned we do a lot

21:39 of kind of investigation into these trajectories, right?

21:42 What is the path the agent takes?

21:44 You inspect this a lot and you think about like how can we make this better?

21:48 And better has different characteristics, right?

21:50 It could be higher output quality, right?

21:53 We could bump up all the you know,

21:56 thinking effort on all the models to max things.

21:58 We could have it run 100 sub agents, self-validate all its work, right?

22:03 There's a trade-off you make as a product team because that that would

22:06 be kind of a terrible customer experience for a synchronous partnership, right?

22:10 And so the idea is like how can we get to the highest

22:12 possible resolution rate while still making

22:15 like the experience feel somewhat interactive, right?

22:17 You know what's going on with this agent.

22:18 Like you're going to want to provide feedback at the right points, right?

22:22 You don't want it to be overly chatty.

22:24 You also don't want it to be too terse cuz you have no idea what's going on.

22:26 And so there's a whole bunch of knobs that are

22:28 actually product decisions you make in the prompts and tools, right?

22:31 To go and do that.

22:32 So for So you mentioned like at the beginning of every turn,

22:35 yes, we go search things.

22:37 You need context.

22:38 So thinking more about that problem what actually is happening there, right?

22:42 Well, as you say, it's it's mostly choosing to either

22:45 do run run in term- run in terminal and grep, right?

22:48 Or use one of our search tools and gather context in that way.

22:52 Or it's hitting our semantic search

22:54 endpoint and doing agentic code retrieval, right?

22:57 But it's a very simplistic thing, right?

22:59 It's just okay, I need to run grep.

23:01 I need to gather context.

23:03 And something like Opus is a is a very heavy reasoning model.

23:06 It it is very powerful, but it is also quite slow, right?

23:10 And so basically what we found is like well,

23:13 considering actually when you think about the agent turn the quality of results,

23:18 yes, it does depend on the context within reason,

23:21 but like it's much more determined by what happens after that.

23:23 Like how does the model operate over the context it's gathered?

23:27 So in the case of the explore sub agent,

23:29 we decided to use Haiku cuz the performance

23:31 characteristics were much better in terms of time

23:33 to first token and how quickly it was

23:34 able to execute things like grep searches, right?

23:37 And so it can run super super fast.

23:40 And basically we found that it didn't actually degrade the quality when we

23:44 did this pattern of the overall resolution

23:47 rate going back to those offline emails.

23:48 So you can basically speed up the agent turn by creating a sub agent,

23:52 keeping all the nasty context of gathering stuff in that sub agent, right?

23:56 Doing it with Haiku which is extremely fast.

23:58 It's just running a ton of greps.

23:59 Returning that back and then Opus is actually able to use

24:02 his big brain and kind of reason over all the context we gathered.

24:04 So basically it's one of those like magic things where like we were

24:08 essentially able to speed up the entire turn by not sacrificing quality at all.

24:13 That's that's actually like the goldmine, right?

24:15 And so this is why we really are looking deeply

24:17 at all these trajectories for opportunities like that for optimization.

24:20 So that's actually what's happening there.

24:21 It's like yes, we could have used Opus,

24:23 but like it was maybe going to make your turn 30% slower, 40% slower.

24:28 And we can give you the exact same resolution rate

24:30 with a model that's much faster and give you faster turns.

24:33 So those are the sorts of kind of things we are exploring behind the scenes.

24:37 I definitely think we can do a better job

24:38 of kind of explaining our rationale for these sorts of things.

24:41 That's totally fair feedback.

24:42 We need to make sure in the UX it's quite clear when these things are happening.

24:45 That's totally fair feedback.

24:47 But that's kind of like how we got there

24:48 and and kind of the justification for for these sorts

24:50 of things like these special purpose sub agents

24:54 that we've started building into our agent loop.

24:56 It makes a lot of sense because even me

24:58 when I'm writing prompts to do specific things at work,

25:01 I will specifically in my prompt front matters specify like a Haiku or GPT mini

25:09 model because they're super quick and I'm not

25:11 doing super complex things inside of it, right?

25:13 I don't need that big rationale.

25:16 I think of it as you know, I need to eat some cereal, right?

25:21 And I have the bowl, I have the cereal, I have the milk in there.

25:24 Things are good.

25:25 I'm in a good place.

25:25 All the all the all the the the loop is ready.

25:28 Like the harness is ready.

25:29 It's it's it's got my my bowl, but I need a utensil to eat said cereal.

25:35 This is a terrible analogy,

25:36 but you I'm going to tell you you can tell me if it works.

25:40 [laughter] So I can go one of two routes to get to the same conclusion.

25:42 I could bring a Swiss Army knife that can do a thousand

25:45 things and has like all the capabilities and all the really advanced things.

25:50 And there is a spoon in there that I could open.

25:52 I'd have to find it.

25:53 Like I'd have to go deeper into it.

25:55 Now when I use this tool, it might also get in my way cuz it

25:57 has other things that are coming up and poking me.

26:00 Or I could just go grab a spoon.

26:02 Which is going to give me the same exact

26:03 result as that Swiss Army knife which has a spoon,

26:06 but it does one thing and it does that one thing really good.

26:08 And like the sub agent with this specific

26:10 model can do that one thing really really Well,

26:12 obviously that model does a lot of things really well,

26:14 but in this case it's super focused in on it, right?

26:17 Well, and like I I think in this particular case it's like that is a product

26:21 choice we're making for our plan mode is

26:22 we think it gives you really good results.

26:24 But if you decide, hey, I actually don't want that to happen for plan mode,

26:28 you know, for whatever reason,

26:29 I I think that I should we should choose a different strategy.

26:32 The really cool thing about VS Code is like you can take our built-in,

26:35 you know, modes like plan mode.

26:37 You can literally go in and copy the exact,

26:39 you know, it's just a custom agent, right?

26:41 You can go copy the exact prompt and tools that uses

26:44 and you can just modify it to how you and your team works.

26:46 So if you're like, I don't like that.

26:48 That's a really cool thing about VS Code.

26:50 You can go change and basically build your own plan mode.

26:52 Now I have full confidence that our plan mode is going to give you really really

26:55 good results because we have a whole group

26:57 of people who work on optimizing it, right?

27:00 And making sure it does give good results.

27:01 But I also at the same time believe like I mean,

27:04 we see this in in resolution rate.

27:06 Like certainly Opus is the is the strongest model in terms of, you know,

27:09 if you were to take the average of all of your resolution rates,

27:12 it's going to do the best.

27:13 But we see tons of problems in our in our harness where Opus isn't the best.

27:17 Where GPT-4 is the best.

27:19 Where Opus might be one of the worst models actually.

27:22 And so there is an extreme amount of variance.

27:24 And so I do also at the same time appreciate like

27:27 you may have some specialized things you want in your plan mode.

27:30 And for your specific like team and company and project,

27:33 those might be the right things.

27:34 But generally I feel like the choices we make for things like our plan

27:37 mode and agent loop are optimizing

27:39 for the overall experience like the P50 median experience.

27:42 It's certainly possible you may need to go and tweak it yourself.

27:45 And that's the cool thing is you can, right?

27:46 So yeah, I like that we have like an opinion

27:50 and we try to give you the best results,

27:51 but you can always go to your own thing if you feel like you need to.

27:54 Yeah, it's like I go back to my spoons analogy.

27:57 There's a general spoon design,

27:59 but you might you might want a different, you know,

28:02 width or like different style,

28:04 a different color of spoon for said cereal consumption.

28:08 And like it's out there for you can go do it, right?

28:10 You can go you can go pick off the shelf another spoon

28:13 that someone built or you could you could build your own spoon.

28:16 You could put it together.

28:17 You could get into your your welding shop.

28:21 It's like I'm going to I'm going where it's like spoons basically.

28:24 That's what I'm saying.

28:25 How many spoons do you got?

28:26 And you just need one good spoon.

28:27 And we got many many spoons and they all have different capabilities.

28:30 I think that's really important.

28:31 So now in general though um when these the the thing that you said

28:38 for these sub agents where the it's basically

28:40 like work trees are isolated code branches basically, right?

28:44 It's an isolated thing.

28:46 And you can think of a sub agent as an isolated context window, right?

28:49 Is that Is that the same analogy?

28:51 Yeah, I mean it's it's Imagine if you were to just create a new

28:55 chat and run like I want you to gather context in this new chat.

28:58 And then you were to ask in that chat,

29:00 please summarize the context that you just gathered for this is my goal.

29:04 Please please pick only the most relevant details.

29:06 Then imagine you were to copy paste all

29:08 that from that other chat you created back into the main chat.

29:11 That's essentially what's happening at like a high

29:14 level with the sub agent pattern, right?

29:16 Is it's just basically going and creating a new chat,

29:19 doing this thing with a prompt based off where the agent is

29:22 at in his main loop and then returning back some result based off my goal.

29:27 Yep.

29:28 That makes sense.

29:29 Yeah, exactly.

29:29 Yeah.

29:30 I like it.

29:31 I think that's the biggest question that that people get.

29:34 Now in VS Code you can override that as well, that functionality, right?

29:38 Everything's super customizable, correct?

29:40 That's right.

29:41 Yeah.

29:42 If there's any if you want to disable the run sub agent tool,

29:44 you can literally do that, right?

29:46 So all these, you know, this is why it's a it is a lot to to keep up with.

29:52 I I totally agree, but if you can understand the basics of the agent loop,

29:56 then you can really start to reason much more about like,

29:58 "Okay, well, I don't like subagent or why

30:00 does subagent work?" Or like these sorts of things.

30:02 You can go turn it off, you can turn it on.

30:04 You can aggressively prompt it to do that.

30:06 And none of these strategies is like foolproof, right?

30:09 There's there's different tradeoffs you make, right?

30:11 Um and so like you may decide you

30:13 want to make a different set of tradeoffs, right?

30:15 So like a big one is like,

30:17 "Do I put a lot of things in my rule file?" Like I was working with a customer

30:20 and they had like a lot of custom things

30:22 that were in like their uh Confluence uh instance, right?

30:26 And they're like, "Do we represent that as a as an as a rule

30:29 or do we use the tool?" So like well there's a tradeoff there, right?

30:31 Like you could put it in every single prompt,

30:33 but then it's in every single prompt and of course then you are

30:35 responsible for keeping that that uh information

30:39 up to date in the prompt, right?

30:41 Um so that's that's its own set of problems, right?

30:43 Could be could be advantageous.

30:44 Or you could add the Confluence tool, right?

30:47 It can go search.

30:48 But now the agent has to decide when to invoke your tools,

30:52 so you'll need some strong prompting on when it needs to go to your tool.

30:54 That tool description needs to be good, right?

30:56 Um and also you're adding more latency to your entire agent loop, right?

31:00 Because you're having to go run more tools as part of the thing.

31:03 So the total turn time is going to get longer.

31:05 But if that gets you to a faster result

31:07 in the end because you pay the tax of going

31:09 and getting the right context and the agent doesn't

31:12 have to iterate as much later in the loop,

31:14 maybe that's a that's a price worth paying, right?

31:16 And so these are the sort of engineering decisions

31:18 like when you understand the basics of the agent loop,

31:20 you can start to reason about, "Well, like you know,

31:23 we could put it in the prompt or we should

31:24 be doing a tool or maybe you find some hybrid strategy

31:26 that really works for you over time." But like understanding those basics

31:29 helps you to better reason about the tradeoffs that you're making.

31:33 No, that makes a lot of sense.

31:34 Yeah, I think it's it's good to kind of talk through

31:38 like how things are working and why they're working this way.

31:41 And of course this may evolve over time, too,

31:43 but at least in the day of April 2026,

31:45 this is like how things are evolving in general.

31:48 So that's really neat.

31:50 I think that talking about the loop, diving here, there's a lot more happening.

31:54 We could go for hours, but we're not going to.

31:55 So what we want to do is kind of six hours earlier this week.

31:59 So we're going to cut the pod here,

32:00 but what we want you to do is like let us know.

32:02 Reach out to me and Pierce on uh Twitter or write

32:05 into the show or just leave feedback in any of the VS

32:07 Code um subreddits or things like that and and let

32:10 us know if you have more questions on this agent loop,

32:13 we'll dive deeper through it.

32:14 I'll bring out some people from the team

32:15 that are working on these evals and going as well.

32:17 So uh Pierce, thanks for coming on and talking

32:19 about the the deepness uh of the agent loop.

32:22 I know we just scratched the surface.

32:24 Yeah, definitely.

32:24 And you know, the other cool thing about VS Code

32:26 is if you always want to go inspect this for yourself,

32:28 there's commands, you know, developer show chat debug log,

32:31 uh developer show agent debug log.

32:33 Confusingly, there's two different ones,

32:35 but um you can see like basically a flowchart of like how your agent is going,

32:39 all the different tool calls.

32:40 Um so you can look at this trajectory, as I called it,

32:43 yourself and go dig in and see exactly what's happening.

32:46 Totally.

32:47 Yep.

32:47 I love it.

32:48 All right, Pierce, well thanks for coming on.

32:50 We'll dive deeper in the future on more of this stuff,

32:52 but don't forget you should subscribe on your favorite podcast application,

32:55 tell your friends, tell your coworkers.

32:56 And of course you can check out the YouTube @code,

33:00 which has over a million subscribers uh as well.

33:03 And we also put us there as well, so you can see our faces.

33:06 And here's the new office.

33:07 All right, that's going to do it for this VS Code Insiders podcast.

33:10 Until next time, happy coding.

Study with Looplines Download Captions Watch on YouTube