{"id":"02-how-agents-work","number":2,"slug":"how-coding-agents-work","title":"How a coding agent actually works","short":"How a coding agent works","module":"The shift","summary":"Claude Code, Codex, Cursor and Amp look different, but underneath they're the same thing: a model, a few tools, and a while loop. Once you see the loop, you'll understand why agents succeed, why they fail, and what you control.","voice":"Eric","scenes":[{"template":"title","chapter":"Intro","narration":"Claude Code, Codex, Cursor and Amp all look different. Under the hood, they're almost the same program. Once you see it, a lot of agent behavior suddenly makes sense.","params":{"kicker":"Lesson 2","module":"Module 1 · The shift","title":"How a coding agent *actually* works","subtitle":"A model, some tools, and a while loop.","bubble":"Let me show you my insides.","mood":"happy"},"start":0.5,"dur":12.511,"words":[{"text":"Claude","s":0.8,"e":1.12},{"text":"Code,","s":1.2,"e":1.76},{"text":"Codex,","s":1.84,"e":2.48},{"text":"Cursor","s":2.56,"e":2.96},{"text":"and","s":3.12,"e":3.28},{"text":"Amp","s":3.44,"e":3.76},{"text":"all","s":3.84,"e":4.08},{"text":"look","s":4.2,"e":4.32},{"text":"different.","s":4.56,"e":5.08},{"text":"Under","s":5.36,"e":5.6},{"text":"the","s":5.653,"e":5.707},{"text":"hood,","s":5.76,"e":6.32},{"text":"they're","s":6.36,"e":6.56},{"text":"almost","s":6.64,"e":6.96},{"text":"the","s":7.04,"e":7.12},{"text":"same","s":7.24,"e":7.36},{"text":"program.","s":7.44,"e":8.48},{"text":"Once","s":8.6,"e":8.72},{"text":"you","s":8.8,"e":8.88},{"text":"see","s":8.96,"e":9.04},{"text":"it,","s":9.12,"e":9.4},{"text":"a","s":9.44,"e":9.6},{"text":"lot","s":9.68,"e":9.76},{"text":"of","s":9.8,"e":9.84},{"text":"agent","s":9.92,"e":10.16},{"text":"behavior","s":10.24,"e":10.72},{"text":"suddenly","s":10.8,"e":11.2},{"text":"makes","s":11.32,"e":11.44},{"text":"sense.","s":11.64,"e":12.16}]},{"template":"formula","chapter":"The recipe","narration":"Anthropic's definition fits in one line. An agent is a model, using tools, in a loop. The model decides what to do next. The tools let it act on the world. And the loop keeps it going until the job is done.","params":{"parts":[{"text":"Agent","tone":"agent","at":"agent is"},{"op":"="},{"text":"Model","icon":"brain","sub":"decides the next step","at":"model"},{"op":"+"},{"text":"Tools","icon":"tool","sub":"read, edit, run","at":"tools"},{"op":"+"},{"text":"Loop","icon":"loop","sub":"until it's done","at":"loop"}]},"start":13.011,"dur":14.821,"words":[{"text":"Anthropic's","s":13.311,"e":13.951},{"text":"definition","s":14.231,"e":14.511},{"text":"fits","s":14.591,"e":14.831},{"text":"in","s":14.911,"e":14.991},{"text":"one","s":15.151,"e":15.311},{"text":"line.","s":15.391,"e":15.991},{"text":"An","s":16.271,"e":16.351},{"text":"agent","s":16.511,"e":16.831},{"text":"is","s":16.911,"e":16.991},{"text":"a","s":17.071,"e":17.111},{"text":"model,","s":17.151,"e":17.791},{"text":"using","s":17.871,"e":18.111},{"text":"tools,","s":18.191,"e":18.831},{"text":"in","s":18.911,"e":18.991},{"text":"a","s":19.018,"e":19.044},{"text":"loop.","s":19.071,"e":19.671},{"text":"The","s":19.951,"e":19.991},{"text":"model","s":20.031,"e":20.351},{"text":"decides","s":20.471,"e":20.831},{"text":"what","s":20.911,"e":21.071},{"text":"to","s":21.111,"e":21.151},{"text":"do","s":21.231,"e":21.311},{"text":"next.","s":21.391,"e":21.991},{"text":"The","s":22.191,"e":22.271},{"text":"tools","s":22.351,"e":22.751},{"text":"let","s":22.831,"e":22.911},{"text":"it","s":22.991,"e":23.071},{"text":"act","s":23.151,"e":23.311},{"text":"on","s":23.391,"e":23.471},{"text":"the","s":23.511,"e":23.551},{"text":"world.","s":23.631,"e":24.351},{"text":"And","s":24.431,"e":24.511},{"text":"the","s":24.551,"e":24.591},{"text":"loop","s":24.671,"e":24.991},{"text":"keeps","s":25.031,"e":25.231},{"text":"it","s":25.311,"e":25.391},{"text":"going","s":25.591,"e":25.791},{"text":"until","s":25.951,"e":26.111},{"text":"the","s":26.151,"e":26.191},{"text":"job","s":26.271,"e":26.511},{"text":"is","s":26.591,"e":26.671},{"text":"done.","s":26.791,"e":27.231}]},{"template":"quote","chapter":"The recipe","narration":"Thorsten Ball, who builds the Amp agent, put it bluntly. It's an LLM, a loop, and enough tokens. Everything else that makes a great agent feel magical is elbow grease.","params":{"text":"It's an LLM, a loop, and enough tokens. The rest? *Elbow grease.*","who":"Thorsten Ball","role":"engineer at Amp","src":"How to Build an Agent"},"start":27.832,"dur":12.496,"words":[{"text":"Thorsten","s":28.132,"e":28.612},{"text":"Ball,","s":28.692,"e":29.172},{"text":"who","s":29.252,"e":29.332},{"text":"builds","s":29.412,"e":29.692},{"text":"the","s":29.732,"e":29.812},{"text":"Amp","s":29.852,"e":30.052},{"text":"agent,","s":30.212,"e":30.532},{"text":"put","s":30.612,"e":30.692},{"text":"it","s":30.772,"e":30.852},{"text":"bluntly.","s":30.892,"e":31.332},{"text":"It's","s":31.812,"e":31.972},{"text":"an","s":32.052,"e":32.132},{"text":"LLM,","s":32.212,"e":32.932},{"text":"a","s":33.092,"e":33.172},{"text":"loop,","s":33.252,"e":33.812},{"text":"and","s":33.932,"e":34.052},{"text":"enough","s":34.132,"e":34.372},{"text":"tokens.","s":34.452,"e":35.212},{"text":"Everything","s":35.492,"e":35.892},{"text":"else","s":36.012,"e":36.132},{"text":"that","s":36.172,"e":36.212},{"text":"makes","s":36.292,"e":36.452},{"text":"a","s":36.532,"e":36.572},{"text":"great","s":36.612,"e":36.852},{"text":"agent","s":36.932,"e":37.252},{"text":"feel","s":37.332,"e":37.492},{"text":"magical","s":37.652,"e":38.132},{"text":"is","s":38.452,"e":38.612},{"text":"elbow","s":38.692,"e":39.012},{"text":"grease.","s":39.092,"e":39.732}]},{"template":"code","chapter":"Tools are JSON","narration":"So what is a tool call, really? The model never runs anything itself. It replies with a little bit of JSON that names a tool and its input. Then the harness, which is ordinary code, runs the command and sends the output back. As Dex Horthy says: there's nothing special about tools. It's just JSON and code.","params":{"file":"one tool call","lang":"js","lines":["// 1. the model replies with JSON, not magic","{ \"type\": \"tool_use\",","  \"name\": \"bash\",","  \"input\": { \"command\": \"npm test\" } }","","// 2. the harness runs it and sends back the output","{ \"type\": \"tool_result\",","  \"content\": \"FAIL  1 test failed: total()\" }"],"hl":[{"from":2,"to":4,"at":"JSON","label":"the model asks","tone":"agent"},{"from":7,"to":8,"at":"output","label":"the harness answers","tone":"human"}]},"start":40.328,"dur":21.639,"words":[{"text":"So","s":40.628,"e":40.808},{"text":"what","s":40.868,"e":41.248},{"text":"is","s":41.268,"e":41.388},{"text":"a","s":41.428,"e":41.508},{"text":"tool","s":41.588,"e":41.908},{"text":"call,","s":41.988,"e":42.388},{"text":"really?","s":42.468,"e":43.348},{"text":"The","s":43.428,"e":43.508},{"text":"model","s":43.588,"e":43.908},{"text":"never","s":43.988,"e":44.228},{"text":"runs","s":44.388,"e":44.548},{"text":"anything","s":44.628,"e":44.948},{"text":"itself.","s":45.068,"e":45.988},{"text":"It","s":46.068,"e":46.148},{"text":"replies","s":46.228,"e":46.628},{"text":"with","s":46.708,"e":46.788},{"text":"a","s":46.868,"e":46.948},{"text":"little","s":47.028,"e":47.108},{"text":"bit","s":47.188,"e":47.268},{"text":"of","s":47.348,"e":47.428},{"text":"JSON","s":47.708,"e":47.988},{"text":"that","s":48.068,"e":48.148},{"text":"names","s":48.268,"e":48.388},{"text":"a","s":48.468,"e":48.548},{"text":"tool","s":48.788,"e":49.028},{"text":"and","s":49.068,"e":49.108},{"text":"its","s":49.228,"e":49.348},{"text":"input.","s":49.588,"e":50.308},{"text":"Then","s":50.508,"e":50.708},{"text":"the","s":50.788,"e":50.868},{"text":"harness,","s":50.908,"e":51.508},{"text":"which","s":51.588,"e":51.668},{"text":"is","s":51.748,"e":51.988},{"text":"ordinary","s":52.228,"e":52.468},{"text":"code,","s":52.628,"e":53.188},{"text":"runs","s":53.268,"e":53.508},{"text":"the","s":53.588,"e":53.668},{"text":"command","s":53.908,"e":54.148},{"text":"and","s":54.268,"e":54.388},{"text":"sends","s":54.468,"e":54.628},{"text":"the","s":54.708,"e":54.788},{"text":"output","s":54.988,"e":55.188},{"text":"back.","s":55.348,"e":56.068},{"text":"As","s":56.148,"e":56.228},{"text":"Dex","s":56.308,"e":56.468},{"text":"Horthy","s":56.548,"e":56.868},{"text":"says:","s":57.028,"e":57.588},{"text":"there's","s":57.628,"e":57.828},{"text":"nothing","s":57.988,"e":58.148},{"text":"special","s":58.348,"e":58.548},{"text":"about","s":58.708,"e":58.868},{"text":"tools.","s":59.108,"e":59.588},{"text":"It's","s":59.668,"e":59.828},{"text":"just","s":59.908,"e":60.068},{"text":"JSON","s":60.148,"e":60.548},{"text":"and","s":60.628,"e":60.708},{"text":"code.","s":60.788,"e":61.268}]},{"template":"code","chapter":"The loop","narration":"And here's the loop that ties it together. Send the conversation to the model. If it asked for tools, run them and append the results. Then go around again, until the model stops asking for tools and answers you. That's the core of Claude Code, Codex and Cursor alike.","params":{"file":"agent.py","lang":"py","lines":["messages = [system_prompt, user_request]","","while True:","    reply = llm(messages, tools=TOOLS)","    messages.append(reply)","    if not reply.tool_calls:","        break                  # done: answer the user","    for call in reply.tool_calls:","        result = run(call)     # read, edit, bash...","        messages.append(result)"],"hl":[{"from":3,"to":3,"at":"loop","label":"the loop","tone":"agent"},{"from":9,"to":10,"at":"append the results","label":"context grows","tone":"human"},{"from":6,"to":7,"at":"stops asking","label":"the exit","tone":"good"}]},"start":61.967,"dur":17.067,"words":[{"text":"And","s":62.267,"e":62.427},{"text":"here's","s":62.507,"e":62.747},{"text":"the","s":62.787,"e":62.827},{"text":"loop","s":62.907,"e":63.147},{"text":"that","s":63.227,"e":63.307},{"text":"ties","s":63.427,"e":63.547},{"text":"it","s":63.627,"e":63.707},{"text":"together.","s":63.787,"e":64.187},{"text":"Send","s":64.747,"e":64.907},{"text":"the","s":64.987,"e":65.027},{"text":"conversation","s":65.067,"e":65.787},{"text":"to","s":65.827,"e":65.867},{"text":"the","s":65.907,"e":65.947},{"text":"model.","s":66.027,"e":66.547},{"text":"If","s":66.747,"e":66.827},{"text":"it","s":66.907,"e":66.947},{"text":"asked","s":66.987,"e":67.227},{"text":"for","s":67.267,"e":67.307},{"text":"tools,","s":67.387,"e":68.187},{"text":"run","s":68.267,"e":68.427},{"text":"them","s":68.507,"e":68.747},{"text":"and","s":68.787,"e":68.827},{"text":"append","s":68.987,"e":69.147},{"text":"the","s":69.187,"e":69.227},{"text":"results.","s":69.507,"e":70.027},{"text":"Then","s":70.267,"e":70.507},{"text":"go","s":70.667,"e":70.747},{"text":"around","s":70.827,"e":71.067},{"text":"again,","s":71.267,"e":71.627},{"text":"until","s":71.747,"e":71.867},{"text":"the","s":71.947,"e":71.987},{"text":"model","s":72.027,"e":72.267},{"text":"stops","s":72.347,"e":72.747},{"text":"asking","s":72.827,"e":73.067},{"text":"for","s":73.147,"e":73.227},{"text":"tools","s":73.307,"e":73.707},{"text":"and","s":73.787,"e":73.867},{"text":"answers","s":74.067,"e":74.267},{"text":"you.","s":74.347,"e":74.907},{"text":"That's","s":74.987,"e":75.147},{"text":"the","s":75.227,"e":75.307},{"text":"core","s":75.387,"e":75.627},{"text":"of","s":75.667,"e":75.707},{"text":"Claude","s":75.787,"e":76.027},{"text":"Code,","s":76.107,"e":76.667},{"text":"Codex","s":76.787,"e":77.147},{"text":"and","s":77.227,"e":77.307},{"text":"Cursor","s":77.387,"e":77.707},{"text":"alike.","s":77.787,"e":78.427}]},{"template":"terminal","chapter":"The loop","narration":"In a real session, the loop looks like this. You ask for a fix. The agent searches, reads a file, runs the tests, edits the code and runs the tests again. You didn't tell it which tools to use. It chained them on its own.","params":{"title":"~/shop · coding agent","lines":[{"k":"you","text":"the checkout total is off by a cent, fix it"},{"k":"tool","text":"Grep(\"total(\", src/)","at":"searches"},{"k":"tool","text":"Read(src/checkout.ts)","at":"reads"},{"k":"tool","text":"Bash(npm test)","at":"runs the tests"},{"k":"err","text":"FAIL  expected 42.00, got 41.99"},{"k":"agent","text":"Rounding happens before tax. Moving it after."},{"k":"tool","text":"Edit(src/checkout.ts)","at":"edits"},{"k":"tool","text":"Bash(npm test)","at":"again"},{"k":"ok","text":"PASS  14 tests"},{"k":"agent","text":"Fixed: tax is applied before rounding."}]},"start":79.034,"dur":15.161,"words":[{"text":"In","s":79.334,"e":79.454},{"text":"a","s":79.494,"e":79.547},{"text":"real","s":79.601,"e":79.774},{"text":"session,","s":79.814,"e":80.374},{"text":"the","s":80.614,"e":80.654},{"text":"loop","s":80.694,"e":80.934},{"text":"looks","s":81.014,"e":81.094},{"text":"like","s":81.174,"e":81.334},{"text":"this.","s":81.414,"e":82.014},{"text":"You","s":82.294,"e":82.374},{"text":"ask","s":82.454,"e":82.614},{"text":"for","s":82.694,"e":82.774},{"text":"a","s":82.814,"e":82.854},{"text":"fix.","s":82.934,"e":83.574},{"text":"The","s":83.814,"e":83.894},{"text":"agent","s":83.974,"e":84.294},{"text":"searches,","s":84.454,"e":85.094},{"text":"reads","s":85.214,"e":85.334},{"text":"a","s":85.374,"e":85.414},{"text":"file,","s":85.494,"e":86.134},{"text":"runs","s":86.254,"e":86.374},{"text":"the","s":86.454,"e":86.494},{"text":"tests,","s":86.534,"e":87.334},{"text":"edits","s":87.414,"e":87.654},{"text":"the","s":87.694,"e":87.734},{"text":"code","s":87.814,"e":88.134},{"text":"and","s":88.294,"e":88.374},{"text":"runs","s":88.454,"e":88.694},{"text":"the","s":88.734,"e":88.774},{"text":"tests","s":88.854,"e":89.094},{"text":"again.","s":89.294,"e":89.774},{"text":"You","s":90.054,"e":90.214},{"text":"didn't","s":90.294,"e":90.454},{"text":"tell","s":90.534,"e":90.614},{"text":"it","s":90.694,"e":90.774},{"text":"which","s":90.854,"e":90.934},{"text":"tools","s":91.014,"e":91.334},{"text":"to","s":91.374,"e":91.414},{"text":"use.","s":91.494,"e":91.974},{"text":"It","s":92.134,"e":92.294},{"text":"chained","s":92.334,"e":92.534},{"text":"them","s":92.614,"e":92.694},{"text":"on","s":92.774,"e":92.814},{"text":"its","s":92.854,"e":93.014},{"text":"own.","s":93.094,"e":93.574}]},{"template":"statement","chapter":"Few tools, big reach","narration":"Boris Cherny says Claude Code gives the model a surprisingly small set of tools: edit files, search files, run shell commands. But a shell is everything an engineer has at a terminal. When the team first gave the model tools, he says, the model just wanted to use them.","params":{"eyebrow":"Boris Cherny, creator of Claude Code","text":"“The model just *wants* to use tools.”","sub":"A few tools (edit, search, bash) give it everything you have at a terminal.","art":"terminal","tone":"agent","sync":false},"start":94.195,"dur":18.112,"words":[{"text":"Boris","s":94.495,"e":94.815},{"text":"Cherny","s":94.895,"e":95.375},{"text":"says","s":95.535,"e":95.695},{"text":"Claude","s":95.855,"e":96.175},{"text":"Code","s":96.255,"e":96.495},{"text":"gives","s":96.575,"e":96.735},{"text":"the","s":96.775,"e":96.815},{"text":"model","s":96.895,"e":97.135},{"text":"a","s":97.215,"e":97.295},{"text":"surprisingly","s":97.415,"e":98.095},{"text":"small","s":98.255,"e":98.495},{"text":"set","s":98.655,"e":98.735},{"text":"of","s":98.815,"e":98.895},{"text":"tools:","s":98.975,"e":99.855},{"text":"edit","s":99.935,"e":100.095},{"text":"files,","s":100.175,"e":100.895},{"text":"search","s":101.055,"e":101.215},{"text":"files,","s":101.455,"e":101.935},{"text":"run","s":102.055,"e":102.175},{"text":"shell","s":102.295,"e":102.415},{"text":"commands.","s":102.655,"e":102.975},{"text":"But","s":103.455,"e":103.535},{"text":"a","s":103.615,"e":103.695},{"text":"shell","s":103.775,"e":104.095},{"text":"is","s":104.175,"e":104.415},{"text":"everything","s":104.495,"e":104.895},{"text":"an","s":104.935,"e":104.975},{"text":"engineer","s":105.055,"e":105.455},{"text":"has","s":105.615,"e":105.775},{"text":"at","s":105.815,"e":105.855},{"text":"a","s":105.935,"e":106.015},{"text":"terminal.","s":106.255,"e":106.735},{"text":"When","s":106.975,"e":107.055},{"text":"the","s":107.135,"e":107.215},{"text":"team","s":107.375,"e":107.535},{"text":"first","s":107.615,"e":107.855},{"text":"gave","s":107.935,"e":108.095},{"text":"the","s":108.135,"e":108.175},{"text":"model","s":108.255,"e":108.415},{"text":"tools,","s":108.575,"e":109.028},{"text":"he","s":109.082,"e":109.135},{"text":"says,","s":109.215,"e":109.775},{"text":"the","s":109.855,"e":109.935},{"text":"model","s":110.055,"e":110.175},{"text":"just","s":110.255,"e":110.415},{"text":"wanted","s":110.495,"e":110.735},{"text":"to","s":110.815,"e":110.895},{"text":"use","s":110.975,"e":111.135},{"text":"them.","s":111.215,"e":111.695}]},{"template":"context","chapter":"What it sees","narration":"Here's the part most people miss. The model is stateless. It remembers nothing between calls, so the harness replays the whole conversation every time. Everything the agent knows about your task sits in this context window: the system prompt, tool definitions, your memory files, your messages, and every tool result it has collected.","params":{"title":"Everything the agent knows","cap":"the context window","blocks":[{"label":"system prompt","kind":"sys","w":0.08,"at":"system prompt"},{"label":"tool definitions","kind":"tool","w":0.07,"at":"tool definitions"},{"label":"memory files","kind":"mem","w":0.05,"at":"memory"},{"label":"your messages","kind":"you","w":0.05,"at":"your messages"},{"label":"every tool result","kind":"out","w":0.38,"at":"every tool result"}],"note":"If it isn't in here, the agent doesn't know it.","note_at":"everything the agent knows"},"start":112.307,"dur":22.423,"words":[{"text":"Here's","s":112.607,"e":112.927},{"text":"the","s":112.967,"e":113.007},{"text":"part","s":113.087,"e":113.327},{"text":"most","s":113.407,"e":113.727},{"text":"people","s":113.727,"e":113.967},{"text":"miss.","s":114.047,"e":114.687},{"text":"The","s":114.927,"e":115.007},{"text":"model","s":115.087,"e":115.407},{"text":"is","s":115.567,"e":115.727},{"text":"stateless.","s":115.807,"e":116.727},{"text":"It","s":116.927,"e":117.007},{"text":"remembers","s":117.087,"e":117.567},{"text":"nothing","s":117.727,"e":118.047},{"text":"between","s":118.127,"e":118.447},{"text":"calls,","s":118.527,"e":119.247},{"text":"so","s":119.327,"e":119.407},{"text":"the","s":119.447,"e":119.487},{"text":"harness","s":119.527,"e":119.887},{"text":"replays","s":119.967,"e":120.367},{"text":"the","s":120.447,"e":120.527},{"text":"whole","s":120.607,"e":120.767},{"text":"conversation","s":120.847,"e":121.567},{"text":"every","s":121.727,"e":122.047},{"text":"time.","s":122.127,"e":122.727},{"text":"Everything","s":123.007,"e":123.407},{"text":"the","s":123.447,"e":123.487},{"text":"agent","s":123.567,"e":123.807},{"text":"knows","s":123.887,"e":124.127},{"text":"about","s":124.207,"e":124.367},{"text":"your","s":124.447,"e":124.527},{"text":"task","s":124.607,"e":125.007},{"text":"sits","s":125.167,"e":125.407},{"text":"in","s":125.487,"e":125.647},{"text":"this","s":125.727,"e":125.887},{"text":"context","s":125.967,"e":126.367},{"text":"window:","s":126.447,"e":127.247},{"text":"the","s":127.327,"e":127.367},{"text":"system","s":127.407,"e":127.727},{"text":"prompt,","s":127.807,"e":128.447},{"text":"tool","s":128.567,"e":128.687},{"text":"definitions,","s":128.767,"e":129.487},{"text":"your","s":129.727,"e":129.807},{"text":"memory","s":129.887,"e":130.127},{"text":"files,","s":130.207,"e":130.767},{"text":"your","s":130.847,"e":130.927},{"text":"messages,","s":131.007,"e":131.807},{"text":"and","s":131.927,"e":132.047},{"text":"every","s":132.127,"e":132.367},{"text":"tool","s":132.447,"e":132.687},{"text":"result","s":132.767,"e":133.087},{"text":"it","s":133.127,"e":133.167},{"text":"has","s":133.247,"e":133.327},{"text":"collected.","s":133.407,"e":134.127}]},{"template":"stack","chapter":"The harness","narration":"Simon Willison calls a coding agent a harness for an LLM. The model sits at the bottom. The harness wraps it with prompts, tools, permissions and memory. The tools reach into your repo. And on top, there's you, deciding what goes in and what counts as done.","params":{"title":"A coding agent, layer by layer","sub":"“A harness for an LLM” — Simon Willison","layers":[{"label":"Model","sub":"predicts the next token","tone":"ink","icon":"brain","at":"model sits"},{"label":"Harness","sub":"prompts, loop, permissions, memory","tone":"agent","icon":"layers","at":"harness wraps"},{"label":"Tools","sub":"files, shell, web, MCP","tone":"soft","icon":"tool","at":"tools reach"},{"label":"You","sub":"what goes in, what counts as done","tone":"human","icon":"user","at":"there's you"}]},"start":134.73,"dur":18.034,"words":[{"text":"Simon","s":135.03,"e":135.35},{"text":"Willison","s":135.43,"e":135.91},{"text":"calls","s":135.99,"e":136.23},{"text":"a","s":136.27,"e":136.31},{"text":"coding","s":136.39,"e":136.63},{"text":"agent","s":136.79,"e":137.11},{"text":"a","s":137.27,"e":137.35},{"text":"harness","s":137.51,"e":137.91},{"text":"for","s":137.99,"e":138.07},{"text":"an","s":138.15,"e":138.23},{"text":"LLM.","s":138.31,"e":139.11},{"text":"The","s":139.43,"e":139.51},{"text":"model","s":139.59,"e":139.83},{"text":"sits","s":139.91,"e":140.07},{"text":"at","s":140.15,"e":140.19},{"text":"the","s":140.23,"e":140.31},{"text":"bottom.","s":140.39,"e":140.95},{"text":"The","s":141.19,"e":141.27},{"text":"harness","s":141.31,"e":141.67},{"text":"wraps","s":141.83,"e":142.15},{"text":"it","s":142.19,"e":142.23},{"text":"with","s":142.31,"e":142.39},{"text":"prompts,","s":142.47,"e":143.19},{"text":"tools,","s":143.43,"e":143.83},{"text":"permissions","s":144.11,"e":144.39},{"text":"and","s":144.47,"e":144.55},{"text":"memory.","s":144.63,"e":145.11},{"text":"The","s":145.67,"e":145.75},{"text":"tools","s":145.83,"e":146.15},{"text":"reach","s":146.23,"e":146.47},{"text":"into","s":146.55,"e":146.63},{"text":"your","s":146.71,"e":146.79},{"text":"repo.","s":146.87,"e":147.51},{"text":"And","s":147.75,"e":147.83},{"text":"on","s":147.91,"e":147.99},{"text":"top,","s":148.07,"e":148.55},{"text":"there's","s":148.63,"e":148.79},{"text":"you,","s":148.87,"e":149.43},{"text":"deciding","s":149.55,"e":149.91},{"text":"what","s":149.99,"e":150.07},{"text":"goes","s":150.15,"e":150.31},{"text":"in","s":150.39,"e":150.63},{"text":"and","s":150.71,"e":150.79},{"text":"what","s":150.87,"e":151.03},{"text":"counts","s":151.11,"e":151.35},{"text":"as","s":151.43,"e":151.51},{"text":"done.","s":151.59,"e":152.15}]},{"template":"chat","chapter":"Why it matters","narration":"This explains a classic failure. A human colleague would push back on a vague request. A model won't. As Thorsten Ball points out, it says: you're absolutely right, I'll fix the bug with the upload. Then it guesses. Barry Zhang from Anthropic gives the antidote: put yourself in the agent's context window.","params":{"messages":[{"from":"you","text":"fix the upload bug","label":"vague"},{"from":"agent","text":"You're absolutely right! I'll fix the bug with the upload.","tone":"bad","at":"absolutely"},{"from":"you","text":"Uploads over 10MB fail with a 413 in prod. Find where the size limit is set, raise it to 50MB, and add a test.","label":"what it actually needed","at":"antidote"}]},"start":152.764,"dur":21.221,"words":[{"text":"This","s":153.064,"e":153.304},{"text":"explains","s":153.464,"e":153.784},{"text":"a","s":153.864,"e":153.944},{"text":"classic","s":154.024,"e":154.504},{"text":"failure.","s":154.584,"e":155.464},{"text":"A","s":155.544,"e":155.624},{"text":"human","s":155.784,"e":155.944},{"text":"colleague","s":156.024,"e":156.424},{"text":"would","s":156.504,"e":156.584},{"text":"push","s":156.664,"e":156.904},{"text":"back","s":157.064,"e":157.224},{"text":"on","s":157.264,"e":157.304},{"text":"a","s":157.384,"e":157.424},{"text":"vague","s":157.464,"e":157.624},{"text":"request.","s":157.704,"e":158.664},{"text":"A","s":158.744,"e":158.824},{"text":"model","s":159.024,"e":159.224},{"text":"won't.","s":159.304,"e":160.184},{"text":"As","s":160.264,"e":160.344},{"text":"Thorsten","s":160.424,"e":160.744},{"text":"Ball","s":160.824,"e":160.984},{"text":"points","s":161.064,"e":161.304},{"text":"out,","s":161.384,"e":161.784},{"text":"it","s":161.864,"e":161.944},{"text":"says:","s":162.064,"e":162.664},{"text":"you're","s":162.704,"e":162.904},{"text":"absolutely","s":162.984,"e":163.544},{"text":"right,","s":163.624,"e":164.104},{"text":"I'll","s":164.144,"e":164.264},{"text":"fix","s":164.344,"e":164.504},{"text":"the","s":164.584,"e":164.664},{"text":"bug","s":164.744,"e":164.824},{"text":"with","s":164.904,"e":164.984},{"text":"the","s":165.024,"e":165.064},{"text":"upload.","s":165.264,"e":165.944},{"text":"Then","s":166.024,"e":166.424},{"text":"it","s":166.504,"e":166.584},{"text":"guesses.","s":166.704,"e":167.704},{"text":"Barry","s":167.784,"e":168.024},{"text":"Zhang","s":168.104,"e":168.424},{"text":"from","s":168.504,"e":168.584},{"text":"Anthropic","s":168.704,"e":169.304},{"text":"gives","s":169.384,"e":169.544},{"text":"the","s":169.584,"e":169.624},{"text":"antidote:","s":169.704,"e":170.744},{"text":"put","s":170.864,"e":170.984},{"text":"yourself","s":171.104,"e":171.464},{"text":"in","s":171.544,"e":171.624},{"text":"the","s":171.704,"e":171.784},{"text":"agent's","s":171.944,"e":172.264},{"text":"context","s":172.504,"e":172.744},{"text":"window.","s":172.824,"e":173.384}]},{"template":"chart","chapter":"Errors compound","narration":"There's one more consequence of the loop. Every step is a chance to be wrong, and errors compound. Chip Huyen's arithmetic: at ninety-five percent accuracy per step, a ten-step task succeeds about sixty percent of the time. A hundred-step task, almost never. So keep tasks scoped and verify along the way.","params":{"title":"Success at 95% accuracy per step","kind":"bar","suffix":"%","data":[{"x":"1 step","y":95,"label":"95%","at":"per step"},{"x":"10 steps","y":60,"label":"60%","hl":true,"at":"sixty"},{"x":"100 steps","y":0.6,"label":"0.6%","at":"hundred"}],"src":"Chip Huyen, “Agents” (2025): 0.95¹⁰ ≈ 0.60, 0.95¹⁰⁰ ≈ 0.006"},"start":173.985,"dur":22.109,"words":[{"text":"There's","s":174.285,"e":174.605},{"text":"one","s":174.685,"e":174.765},{"text":"more","s":174.845,"e":175.085},{"text":"consequence","s":175.205,"e":175.645},{"text":"of","s":175.725,"e":175.805},{"text":"the","s":175.845,"e":175.885},{"text":"loop.","s":176.045,"e":176.285},{"text":"Every","s":176.845,"e":177.085},{"text":"step","s":177.165,"e":177.485},{"text":"is","s":177.565,"e":177.645},{"text":"a","s":177.725,"e":177.765},{"text":"chance","s":177.805,"e":178.045},{"text":"to","s":178.125,"e":178.205},{"text":"be","s":178.245,"e":178.285},{"text":"wrong,","s":178.445,"e":179.085},{"text":"and","s":179.165,"e":179.245},{"text":"errors","s":179.405,"e":179.805},{"text":"compound.","s":180.125,"e":180.885},{"text":"Chip","s":181.325,"e":181.365},{"text":"Huyen's","s":181.405,"e":181.805},{"text":"arithmetic:","s":181.885,"e":183.005},{"text":"at","s":183.085,"e":183.165},{"text":"ninety-five","s":183.245,"e":183.725},{"text":"percent","s":184.045,"e":184.125},{"text":"accuracy","s":184.605,"e":184.685},{"text":"per","s":184.845,"e":184.925},{"text":"step,","s":185.245,"e":185.645},{"text":"a","s":185.725,"e":185.805},{"text":"ten-step","s":185.965,"e":186.365},{"text":"task","s":186.765,"e":186.845},{"text":"succeeds","s":187.045,"e":187.458},{"text":"about","s":187.565,"e":187.725},{"text":"sixty","s":187.885,"e":188.045},{"text":"percent","s":188.285,"e":188.365},{"text":"of","s":188.405,"e":188.445},{"text":"the","s":188.485,"e":188.525},{"text":"time.","s":188.845,"e":189.485},{"text":"A","s":189.565,"e":189.645},{"text":"hundred-step","s":189.765,"e":190.205},{"text":"task,","s":190.605,"e":191.125},{"text":"almost","s":191.325,"e":191.485},{"text":"never.","s":191.805,"e":192.445},{"text":"So","s":192.525,"e":192.605},{"text":"keep","s":192.765,"e":192.845},{"text":"tasks","s":193.245,"e":193.325},{"text":"scoped","s":193.805,"e":193.885},{"text":"and","s":193.965,"e":194.045},{"text":"verify","s":194.525,"e":194.685},{"text":"along","s":194.845,"e":194.885},{"text":"the","s":194.925,"e":195.005},{"text":"way.","s":195.165,"e":195.485}]},{"template":"quiz","chapter":"Quick check","narration":"Quick check. Your agent decides a helper function doesn't exist and writes a duplicate. What most likely happened? Tap your answer.","params":{"q":"Your agent decides a helper doesn't exist and writes a duplicate. What most likely happened?","options":["The model got lazy and skipped the search","A narrow search came back empty, and it acted on what was in its context","It can't read files it didn't create","The harness hid the file on purpose"],"answer":1,"explain":"The agent only knows what lands in its context. An empty search result looked like proof. Geoffrey Huntley calls this a classic failure."},"start":196.094,"dur":13.938,"words":[{"text":"Quick","s":196.394,"e":196.634},{"text":"check.","s":196.714,"e":197.034},{"text":"Your","s":197.514,"e":197.674},{"text":"agent","s":197.754,"e":197.994},{"text":"decides","s":198.074,"e":198.474},{"text":"a","s":198.554,"e":198.594},{"text":"helper","s":198.634,"e":198.954},{"text":"function","s":199.034,"e":199.434},{"text":"doesn't","s":199.514,"e":199.754},{"text":"exist","s":199.834,"e":200.314},{"text":"and","s":200.394,"e":200.554},{"text":"writes","s":200.674,"e":200.794},{"text":"a","s":200.834,"e":200.874},{"text":"duplicate.","s":200.954,"e":201.514},{"text":"What","s":201.994,"e":202.154},{"text":"most","s":202.234,"e":202.474},{"text":"likely","s":202.554,"e":202.874},{"text":"happened?","s":202.954,"e":203.434},{"text":"Tap","s":203.834,"e":204.074},{"text":"your","s":204.154,"e":204.234},{"text":"answer.","s":204.394,"e":204.874}]},{"template":"exercise","chapter":"Try it","narration":"Now watch the loop yourself. Ask your agent to list its tools and plan the exact tool calls it would make for a small question about your code, without running them. You'll start to see your codebase the way it does.","params":{"title":"Try it with your agent","intro":"See the loop from the inside:","prompt":"List the tools you have in this session and what each one does.\nMark which ones can change files or run commands.\nThen, without running anything, show me the exact sequence\nof tool calls you'd make to find where we handle user login."},"start":210.032,"dur":13.149,"words":[{"text":"Now","s":210.332,"e":210.572},{"text":"watch","s":210.652,"e":210.892},{"text":"the","s":210.932,"e":210.972},{"text":"loop","s":211.052,"e":211.212},{"text":"yourself.","s":211.292,"e":212.012},{"text":"Ask","s":212.252,"e":212.492},{"text":"your","s":212.572,"e":212.652},{"text":"agent","s":212.732,"e":212.972},{"text":"to","s":213.052,"e":213.132},{"text":"list","s":213.212,"e":213.452},{"text":"its","s":213.532,"e":213.612},{"text":"tools","s":213.692,"e":214.092},{"text":"and","s":214.172,"e":214.252},{"text":"plan","s":214.332,"e":214.572},{"text":"the","s":214.612,"e":214.652},{"text":"exact","s":214.732,"e":215.212},{"text":"tool","s":215.292,"e":215.532},{"text":"calls","s":215.612,"e":215.852},{"text":"it","s":215.892,"e":215.932},{"text":"would","s":216.012,"e":216.092},{"text":"make","s":216.172,"e":216.332},{"text":"for","s":216.412,"e":216.492},{"text":"a","s":216.532,"e":216.572},{"text":"small","s":216.652,"e":216.892},{"text":"question","s":217.052,"e":217.372},{"text":"about","s":217.452,"e":217.612},{"text":"your","s":217.692,"e":217.772},{"text":"code,","s":217.852,"e":218.412},{"text":"without","s":218.612,"e":218.812},{"text":"running","s":218.892,"e":219.132},{"text":"them.","s":219.212,"e":219.372},{"text":"You'll","s":219.852,"e":220.012},{"text":"start","s":220.132,"e":220.252},{"text":"to","s":220.332,"e":220.412},{"text":"see","s":220.492,"e":220.572},{"text":"your","s":220.652,"e":220.732},{"text":"codebase","s":220.812,"e":221.292},{"text":"the","s":221.332,"e":221.372},{"text":"way","s":221.452,"e":221.532},{"text":"it","s":221.692,"e":221.852},{"text":"does.","s":222.052,"e":222.572}]},{"template":"recap","chapter":"Recap","narration":"Recap. An agent is a model using tools in a loop. Tool calls are just JSON that ordinary code executes. The model only knows what's in its context. And errors compound, so keep steps small and verified. Next: what agents are brilliant at, and where they reliably fail.","params":{"items":["Agent = model + tools + *loop*","Tool calls are JSON; the harness runs them","It only knows what's in its context","Errors compound: small, verified steps"],"next":"What agents are great at, and where they fail","next_at":"Next"},"start":223.181,"dur":22.902,"words":[{"text":"Recap.","s":223.481,"e":224.321},{"text":"An","s":224.601,"e":224.761},{"text":"agent","s":224.841,"e":225.321},{"text":"is","s":225.401,"e":225.561},{"text":"a","s":225.614,"e":225.668},{"text":"model","s":225.721,"e":226.041},{"text":"using","s":226.121,"e":226.361},{"text":"tools","s":226.441,"e":226.841},{"text":"in","s":226.921,"e":227.001},{"text":"a","s":227.041,"e":227.081},{"text":"loop.","s":227.161,"e":227.561},{"text":"Tool","s":228.041,"e":228.281},{"text":"calls","s":228.361,"e":228.681},{"text":"are","s":228.761,"e":228.841},{"text":"just","s":228.921,"e":229.081},{"text":"JSON","s":229.161,"e":229.641},{"text":"that","s":229.761,"e":229.881},{"text":"ordinary","s":229.961,"e":230.361},{"text":"code","s":230.441,"e":230.681},{"text":"executes.","s":230.761,"e":231.481},{"text":"The","s":231.961,"e":232.041},{"text":"model","s":232.121,"e":232.441},{"text":"only","s":232.601,"e":232.841},{"text":"knows","s":232.921,"e":233.241},{"text":"what's","s":233.321,"e":233.481},{"text":"in","s":233.521,"e":233.561},{"text":"its","s":233.641,"e":233.721},{"text":"context.","s":233.801,"e":234.521},{"text":"And","s":235.001,"e":235.241},{"text":"errors","s":235.641,"e":235.961},{"text":"compound,","s":236.041,"e":237.001},{"text":"so","s":237.081,"e":237.161},{"text":"keep","s":237.241,"e":237.401},{"text":"steps","s":237.561,"e":237.721},{"text":"small","s":237.801,"e":238.201},{"text":"and","s":238.281,"e":238.441},{"text":"verified.","s":238.521,"e":239.161},{"text":"Next:","s":240.281,"e":240.761},{"text":"what","s":240.921,"e":241.001},{"text":"agents","s":241.321,"e":241.401},{"text":"are","s":241.481,"e":241.561},{"text":"brilliant","s":241.641,"e":242.161},{"text":"at,","s":242.281,"e":242.521},{"text":"and","s":242.681,"e":242.801},{"text":"where","s":242.921,"e":243.001},{"text":"they","s":243.081,"e":243.161},{"text":"reliably","s":243.321,"e":243.881},{"text":"fail.","s":244.201,"e":244.521}]}],"total":246.483,"audio":"/audio/02-how-agents-work.mp3"}