I Let Agents Refactor My Codebase for 3 Weeks. Then I Read the Code. — Keiji Kanazawa, Microsoft

Loading slides…

Read the talk

I Let Agents Refactor My Codebase for 3 Weeks. Then I Read the Code.

A misplaced sentence sent Keiji Kanazawa looking for a trace his research assistant couldn’t produce. Rebuilding it taught him how to delegate the code while keeping a hand in the harder decision of what counts as a good result.

From a talk by Keiji Kanazawa

At a glance

Ideas worth remembering

  • A request for the trace of one bad digest exposed a mismatch that approving plans had missed. The new architectural names still led to the old workflow.

  • The most useful canvas criterion described how two pieces of information belonged together. Each blackboard equation needed its explanation beside it, in lecture order.

  • An agent can improve against a rubric that rewards the wrong thing. Five other videos gave Kanazawa a way to test the rubric itself before asking the agents to optimize further.

A podcast downloader grows into a personal research assistant

Keiji Kanazawa had more podcasts he wanted to hear than hours to listen. The Microsoft product manager, who started as a developer and had worked in AI research, had a practical reason to care about the debate over reading agent-written code. At one end of what he calls the L/Z spectrum, a builder delegates freely and spends the tokens to get the work done. At the other, a builder slows down and reads the code. Kanazawa put himself firmly at the delegation end. His podcast backlog gave him a reason to try it.

The first version downloaded podcasts, transcribed them and summarized the text. Then it started crawling X threads and linked pages. A scheduler kept the collection running, and an email inbox gave Kanazawa a convenient way to send in a link and get a summary back. What began as a few skills had grown into an LLM wiki with a steady supply of material.

Downloading a YouTube video and transcribing it had a known sequence of steps. The new jobs called for judgment. One would do deep research using the wiki. Another would look back over his coding-agent sessions each day, suggest improvements to the agents’ instructions and turn recurring work into skills. Kanazawa specified a runtime with a registry of agents he could create and run on schedules, including one to monitor the system itself. Claude Code and Codex took turns implementing changes, reviewing each other’s code and fixing bugs.

0:330:53
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

0:00 · section reference included

One misplaced sentence exposes the old workflow

One day a digest put a sentence in the wrong section, attributing material to the wrong source. Kanazawa wanted to find where the mix-up happened and use the failure to design an evaluation. He asked Claude Code for the trace of that particular session. There was no agent trace to inspect. Reading the code, he found that the digest still ran through the old deterministic workflow. He also recognized an uncomfortable detail about the design he disagreed with. He had approved it.

What did adding a skill actually change? The original workflow had steps that invoked actions such as downloading a video or transcribing it. The refactor gave skills and actions two names for the same thing. Agents appeared as a separate concept in the design, yet underneath Kanazawa found the same machinery again. A supposed agent skill had neither the SKILL.md nor the script he expected to find. The agents ran without an agent SDK. The plans he had approved used familiar terms like agent skills, and he had let those words stand in for an implementation decision.

4:024:06
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

4:02 · section reference included

The tests spent real tokens, and the daily reports came back empty

While Kanazawa was working with a coding agent on repairs, a token provider emailed him. It was the first week of the month, and he had already passed his normal monthly budget. Two checks revealed very different problems.

  • Unit tests. Codex had wired the tests to production inference. Running the suite therefore made real model calls, and the agent had run about 30 test cycles in the day before the alert. Spending had reached roughly $100, about five times his usual weekly spend.
  • Daily reflection. The scheduled job was supposed to read coding sessions and suggest improvements. It kept running, but opening the reports revealed empty content. The skill/action/agent refactor had broken the path that invoked the prompts. The schedule could still fire even though the work that gave the report its value never ran.

After three weeks of asking the coding agents to refactor this system, Kanazawa had little reason to commission another pass over the same codebase. He decided to start fresh. He still wanted the agents to write the code.

6:286:36
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

6:28 · section reference included

Four frameworks get the same agent-building task

The rebuild started with fresh specifications and goal rubrics that described the results the agents should produce. The new runtime treated each job as an agent and kept a registry of the different agents. That made the distinction missing from the first refactor concrete enough to try in a working interface.

Which agent was responsible for what the user saw? In the middle of the interface, Kanazawa could give a coding-agent SDK instructions for an agent he wanted built. The SDK created that agent. The new agent then had a canvas on the right where it could put the results of its own work. That division gave him a common task for a four-framework comparison. For the Claude version, he asked Claude Code to build the experience around the Claude Agent SDK. For the Codex version, he asked Codex to use itself to create and run the agents.

He settled on Claude Code and Codex for personal projects. Pi illustrates what mattered in that choice. It quickly produced an interface he liked, then asked him to make decisions about the SQLite database tracking the agents and the design of the TypeScript APIs. An engineer who wanted a say in those details might welcome the questions. As a product manager, Kanazawa wanted to spend that attention on what the experience should do. With his tools chosen, he added transcripts and summaries back into the system and built evaluation harnesses alongside them.

8:198:20
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

8:19 · section reference included

A blackboard lecture gives the video agent something to look for

The old YouTube summarizer only read transcripts. Then Kanazawa came across a blackboard lecture about LLM inference on GPU clusters. Roofline analysis was relevant to his day job, and some of the math he wanted to understand was on the board. His video deep dive agent extracted about 440 keyframes from that lecture. It used an AI evaluation rubric to select shots, pulled out the blackboard equations and incorporated them into the canvas.

What could he do when he got stuck on one equation? In the demonstration, the canvas divided the lecture into chapters and showed the equations with explanations. He could jump from a section back to that part of the video, or highlight an equation and ask the agent to explain that particular part in more detail. The chapter gave him a way back to the lecturer’s reasoning, and the selection let him ask a follow-up without having to describe which piece of mathematics he meant.

11:5512:04
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

11:55 · section reference included

Getting each equation next to its explanation

Kanazawa’s earlier practice had been to give an agent a specification and approve or reject its plan. For the deep dive, he also described how to judge the finished canvas. He wanted simple, well-explained material and links that landed at the right moments in the video. The same reading experience could work for a slide deck, a coding demonstration in VS Code or Cursor, or a terminal recording. He worked out much of what he wanted on the one blackboard lecture.

The agents wrote the rubric under his direction. Once he set it, they could hill-climb against it, iterating on the output to better satisfy the criteria. He would then read the resulting canvas. An early version put all the blackboard equations in a clump at the beginning, followed by a wall of explanatory text. It had recovered both ingredients and left the reader to match them up.

His correction specified a relationship the original criteria had missed. Each equation should appear with its own explanation, and the pairs should follow the lecture’s order. He asked the agents to put that requirement into the rubric. The next pass would then have a reason to preserve the pairing whenever it generated a canvas.

14:0014:07
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

14:00 · section reference included

Five other videos expose an overfit rubric

Kanazawa had been reading the canvases more closely than the rubrics. One agent-written rubric was tailored so tightly to the inference lecture that it was easy to succeed on that example. Running it on five other videos exposed the problem. Performance was poor away from the lecture he had used to develop it. He directed the agent to revise the criteria so they would apply beyond that one video. He reports better scores across the videos after the change, without quantifying the improvement.

When a canvas disappoints, what should change on the next pass? Kanazawa had two ways to act on the result. With a rubric held fixed, the agents could keep improving the canvas against its criteria. When he saw a layout that made him hunt for an explanation, or a rubric that worked on only one lecture, he could change the criteria themselves. That change gave subsequent runs a different target.

Code review served a separate purpose. Kanazawa still distrusted individual implementation decisions, so he had Claude and Codex inspect each other’s work closely and suggest fixes over several rounds. Reading the code himself had exposed the failed refactor. It had also helped him decide where he wanted to spend his own time afterward. He still delegates most implementation and rarely reads every line. What he keeps is the decision about what an agent should do, how its output should work for him, and when an evaluation that looks successful deserves another test.

Which feedback changes the canvas, and which changes the rubric?

Goal rubricThe agent writes criteria under Kanazawa’s direction, including how equations and explanations should appear together.
Generated canvasThe video agent produces a reading view for the lecture.
Assess against the current rubricThe agents optimize the output with the target held fixed.
Inspect the result and test its reachKanazawa reads the layout. Trying five other videos also reveals criteria specific to one lecture.
An evaluation can send the agents around another pass with the same criteria. Reading the output and trying other videos can send Kanazawa back to the criteria that guide every pass.
Read the diagram as text
  • Goal rubric. The agent writes criteria under Kanazawa’s direction, including how equations and explanations should appear together.
  • Generated canvas. The video agent produces a reading view for the lecture.
  • Assess against the current rubric. The agents optimize the output with the target held fixed.
  • Inspect the result and test its reach. Kanazawa reads the layout. Trying five other videos also reveals criteria specific to one lecture.
  • Goal rubric → Generated canvas: Guides generation.
  • Generated canvas → Assess against the current rubric: Supplies the output to judge.
  • Assess against the current rubric → Generated canvas: Guides another attempt at the same target.
  • Generated canvas → Inspect the result and test its reach: Shows what the reader actually gets.
  • Inspect the result and test its reach → Goal rubric: Changes what future runs are judged on.
16:3816:41
Suggest correction

This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.

16:35 · section reference included

Transcript download
Full transcript

Loading transcript…