# Build a Coding Agent Harness From an Empty Loop — Tejas Kumar, IBM

Tejas Kumar, IBM

AI Engineer Code Summit 2026

[Talk page](https://ai.engineer/talks/hUCn9ZnXujQ-build-coding-agent-harness-from-empty-loop) · [Video](https://www.youtube.com/watch?v=hUCn9ZnXujQ)

## Build a Coding Agent Harness From an Empty Loop

Tejas Kumar builds a TypeScript coding agent that initially cannot read its own repository. Adding tools makes it capable enough to delete the project. The workshop develops permissions, usage budgets, context management and task phases, then puts the same machinery to work with a local IBM Granite model and a browser.

### What happens when you ask a model to clean up a file?

[0:12](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=12s)

You mean refactor the file. The model interprets the request as permission to delete it. Once you've connected a language model to a shell, that difference matters quite a bit.

[Tejas Kumar](https://ai.engineer/speakers/tejas-kumar), who works on AI research and development at IBM, starts with a deliberately small question. How far can you get toward something like Claude Code, Codex or IBM Bob if your entire application starts as a `while (true)` loop?

A model accepts a request and generates a response. The **agent harness** is the software around that exchange. Kumar groups most of its responsibilities into three areas.

- **Tools** let the application inspect and change its environment in response to the model's requests.
- **Context management** determines what information reaches the next model call, how much of it can be reused and when the conversation needs shortening.
- **Guardrails** limit what the application will execute, when it must ask permission and how long it can keep spending money.

You can get a feel for context degradation with a canary. Ask the model to begin every reply with `Roger`. Keep the conversation going. Eventually it may stop doing so. That's a cheap signal that an earlier instruction has stopped influencing the output, although it doesn't tell you precisely how much usable context remains. Runaway generation and unauthorized actions are harder to diagnose after the fact. They need limits in the application itself.

The right tools and limits depend on the job. A coding agent needs file access, shell commands and tests, with rules such as requiring consent before pushing code. A computer-use agent needs screenshots, clicks and typing, with checkpoints before irreversible actions. A financial agent might inspect a ledger or initiate a transfer. Even a general-purpose chat assistant has a harness. Its tools and rules serve a different kind of work.

### Start with one array and one model call

[11:36](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=696s)

The first version lives in `harness.ts`. Node's terminal interface reads standard input and writes to standard output. The [Anthropic TypeScript SDK](https://github.com/anthropics/anthropic-sdk-typescript) calls **Claude Haiku 5.5**, the inexpensive model Kumar chose for the workshop. Where does this little application keep its memory?

The essential implementation fits into a few lines.

```ts
const messages: Anthropic.MessageParam[] = []

while (true) {
  const ask = await terminal.question('you> ')
  if (!ask) continue

  messages.push({ role: 'user', content: ask })

  const response = await client.messages.create({
    model: MODEL,
    max_tokens: 16_000,
    messages
  })

  messages.push({ role: 'assistant', content: response.content })

  for (const block of response.content) {
    if (block.type === 'text') console.log(block.text)
  }
}
```

An empty line goes straight back to the prompt. Otherwise the application appends the user's message, sends the accumulated history and allows up to 16,000 output tokens. Notice the difference between what it saves and what it displays. The terminal prints text blocks. The history retains the full assistant content, including structured blocks that subsequent calls may need.

After a rather convincing demonstration of the workshop Wi-Fi's limitations, `npm start` produces a working conversation. Tell the assistant your name and it can use it. Restart the process and ask for your name again. It has no idea. The restart created a new, empty `messages` array. Persisting that history would be the application's responsibility.

Now try a perfectly reasonable first question when joining an unfamiliar codebase. What does `package.json` say in this repository? The assistant explains that it has no access to the filesystem. Running the chat client inside a repository gives the model no knowledge of the files beside it.

![The TypeScript editor shows a loop that reads terminal input, skips empty messages, sends conversation history to the model, stores the full assistant response and prints its text blocks.](https://ai.engineer/api/talk-essay-media/887abdddc08a254f805d8abfcd53c8770bb267cea489ae1f0961b1eeaeb9d491)

The loop skips blank input, adds each user message to the conversation history and sends the whole history to the model. It saves every block of the assistant’s reply for the next turn, even though the terminal prints only the text blocks.

### A file reader introduces a second loop

[17:12](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1032s)

The first addition to `tools.ts` is a definition of `read_file`. It has a name, a description explaining that it reads a text file, and an input schema describing the arguments. The model receives this definition. A separate function, `runTool`, checks the requested name and invokes the actual file-reading code.

That division explains how a model chooses a tool. The application supplies the available definitions with its request. Given the question about `package.json`, the model can generate a structured request containing the tool name and the file path. The harness finds the corresponding function, supplies its arguments and obtains the file contents. The description matters because it helps the model decide when the function would be useful.

There's a missing step. How does the model get to read the file it just requested? The terminal loop now delegates to `runAgent` in `agent.ts`. That function has its own loop, which can call the model several times while the person waits for one answer.

The important change is what happens after the assistant response arrives.

```ts
while (true) {
  const response = await client.messages.create({
    model: MODEL,
    max_tokens: 16_000,
    tools,
    messages
  })

  messages.push({ role: 'assistant', content: response.content })

  for (const block of response.content) {
    if (block.type === 'text') console.log(block.text)
  }

  if (response.stop_reason !== 'tool_use') break

  const results = await runTools(response.content)
  messages.push({ role: 'user', content: results })
}
```

In the Anthropic message format used here, every `tool_use` needs a corresponding `tool_result`. If the assistant requests multiple operations, the harness collects their results into the immediately following user-role message. The next model call can then reason over what actually happened. A tool failure can travel through the same channel with `is_error: true`, giving the agent a chance to recover. Kumar's [companion implementation](https://tej.as/blog/how-to-build-a-coding-agent-harness) explains this pairing in more detail.

Ask about `package.json` again. This time the terminal reports a file read and returns the contents. A follow-up question about the project produces a useful description of the hand-built terminal agent around the Claude API. Then ask it to add an `AGENTS.md` file. The assistant offers a draft to paste yourself. Its only tool is still a reader.

![The runAgent function stores assistant responses, prints text blocks, checks the stop reason and appends tool results. The text-printing line is highlighted.](https://ai.engineer/api/talk-essay-media/d9a8a92bc4c704d4d8a1cb6cfb63186fd8b5cdfd2e1e2cef501bc61a24f5d40d)

runAgent saves the full assistant response in the conversation history. The highlighted line prints only the text blocks. The loop ends unless the model requests a tool, in which case it runs the tools and sends their results back in one user message.

When does control return to the person?
One terminal prompt can cause several model calls. A tool request keeps the inner loop running, with the result added to history before the next call. Any other stop reason exits this version of the inner loop.
- Read terminal input — Skip empty input. Append the user's question about package.json.
- Call the model — Supply history and tool definitions. Save the assistant response and print its text.
- Inspect the stop reason — Does the response request tool use?
- Run the requested tools — The harness executes read_file against the local repository.
- Append tool results — The next user-role message carries the file contents back into the conversation.
- Read terminal input → Call the model (Start runAgent)
- Call the model → Inspect the stop reason (Check the response)
- Inspect the stop reason → Run the requested tools (tool_use)
- Run the requested tools → Append tool results (Return one result per request)
- Append tool results → Call the model (Call again with updated history)
- Inspect the stop reason → Read terminal input (Other stop reason, return to terminal)

### Replace the single tool with a coding tool registry

[22:16](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1336s)

Adding another conditional to `runTool` for every new capability would work for a while. It would also leave the tool descriptions and their implementations in separate places. The next revision introduces a small factory and an array of tools in `coding.ts`. What does adding a capability look like now?

Each entry contains its name, description, argument schema and execution function. The factory gives them a common shape. The SDK receives the definitions, and `runTool` uses `tools.find` to look up the name generated by the model. An unknown name raises an error. A match gives the harness a function it can invoke with the supplied arguments.

The [written version of the workshop](https://tej.as/blog/how-to-build-a-coding-agent-harness) spells out the five coding tools and one particularly useful constraint.

- **`list_files`** discovers what exists in the repository.
- **`read_file`** retrieves the contents of a selected file.
- **`write_file`** creates or writes a file.
- **`edit_file`** replaces text only when the target occurs exactly once, avoiding an ambiguous edit.
- **`bash`** runs shell commands, which also gives the agent access to the project's existing development tools.

Restart the agent and ask whether the project has an `AGENTS.md`. It lists files, reads enough of the repository to understand the project, discovers the missing document and offers to create it. Answer yes. The model supplies a path and content to the write tool. Opening the new file reveals setup instructions and project conventions. Even the assistant's offer has changed now that it knows writing is available.

Then someone in the audience suggests Python. Kumar asks the agent to rewrite the whole project. It reads the TypeScript files, runs Bash, asks for a decision and, after an enthusiastic go-ahead, starts making changes. Inspecting the original folder initially shows TypeScript everywhere. The agent subsequently reports that the changes went to a branch. The confusion alone makes a good case for checking where an agent wrote its work.

The next experiment is less ambiguous. Kumar asks the agent to delete the repository contents, allowing for Git and `.env` to remain. It obliges. The project files disappear, along with `node_modules`. The agent that couldn't create a Markdown file a few minutes ago can now take apart its own working directory.

![After inspecting the repository, the agent asks about the scope, destination branch, uncommitted changes and Python dependencies. The user tells it to proceed.](https://ai.engineer/api/talk-essay-media/347435e0c2b69174671276a78466f4127cbd6c9e7c5ed3cb8d256e8b8cf763dc)

Before changing a file, the agent spots uncommitted edits on branch 2. It proposes a separate Python branch and asks whether to port step 2 or the final step 8. Kumar answers all four questions with “jsut fo it i odnt care”.

### Give the harness a budget and a veto

[27:33](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1653s)

After recovering the project, the next branch adds `guardrails.ts`. There are two independent questions to answer.

- **How much work may this task consume?** The workshop sets limits of 25 model calls and 300,000 tokens per task, counting input and output together. A budget starts at zero, accumulates usage and exposes a check for overspending.
- **May this particular action run?** The `ASK_FIRST` set includes `write_file`, `edit_file` and `bash`. A request for one of these tools pauses for confirmation before the harness invokes it.

A refusal needs to do two things. It must prevent execution, and it must tell the model what happened. The permission function raises an error explaining that the person declined and that the agent should ask what to do instead. The existing tool-result machinery carries that information back into the conversation.

With the dependencies reinstalled, Kumar repeats the deletion request. What happens when the person who requested the deletion declines the proposed command? The agent lists files and proposes a Bash operation involving `find`. The terminal asks for permission. Kumar says no. The assistant reports that nothing was deleted and expresses some understandable confusion about why the person who asked for deletion just refused it.

Kumar calls this **agent experience**. The model is itself a user of the software you're writing. An unexplained failure gives it little to work with. A descriptive error tells it which assumption failed and how it can continue. In this case, the model receives the refusal in precisely the place where it expected the shell command's output.

The budget experiment is messier. There are roughly 5,000 files in the directory tree and 14 entries at the top level. The idea is to force more than 25 steps by asking the agent to read files individually, excluding `node_modules`. It doesn't reliably follow the sequential-reading instruction, so the run never gives a clean demonstration of the 25-step cutoff. Counting files is also a poor proxy for counting model calls when one response can request several tools.

The permission experiment makes the stronger point. A model might voluntarily ask before changing something, as it did during the Python rewrite. A gate in the execution path gives the person an enforceable veto even when the model never thinks to ask. The tradeoff in this implementation is that approval operates at tool granularity, so even an innocuous Bash command can interrupt the user.

### Cut large results, cache repeated input and compact early

[32:37](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1957s)

Every trip around the inner loop makes the next request longer. The system instructions, user prompt, tool definitions, assistant messages and earlier tool results can all become input again. A large file read early in a task can therefore contribute to the cost of many subsequent calls.

The first defense in `context.ts` is to limit individual tool results. A tool can return almost anything. Kumar imagines one that dumps the entire HTML specification into context. His [companion code](https://tej.as/blog/how-to-build-a-coding-agent-harness) uses a 12,000-character limit. The `fit` function passes smaller results through unchanged and truncates oversized ones, adding instructions to request a smaller portion.

Two more controls operate on the conversation as a whole.

- **Prompt caching** lets the provider reuse work on an unchanged prefix. Suppose the history through the last tool interaction is A. The next request extends A with new material. The provider can reuse the computation for A, process the new input and make a longer prefix available for reuse on subsequent calls.
- **Compaction** replaces an increasingly long history with a shorter representation. In this implementation, Anthropic's API uses a model to summarize the conversation once the configured input threshold is reached.

Where do those controls enter the implementation? The client adds configuration to the model request. The relevant settings in the [written walkthrough](https://tej.as/blog/how-to-build-a-coding-agent-harness) look like this.

```ts
const contextOptions = {
  cache_control: { type: 'ephemeral' },
  betas: ['compact-2026-01-12'],
  context_management: {
    edits: [{
      type: 'compact_20260112',
      trigger: { type: 'input_tokens', value: 90_000 }
    }]
  }
}
```

The choice of 90,000 input tokens is economic. Under the Haiku pricing schedule Kumar uses, exceeding 100,000 input tokens in one prompt raises the applicable price fivefold. Compacting at 90,000 leaves some room before that threshold. A model with a much larger advertised context window can still be expensive to use well before the window fills. The right threshold depends on your model's pricing and the size of the results your tools return.

An audience question clears up an important implementation detail. Who keeps track of A? In this setup the client still supplies the message history and requests caching. Anthropic's backend manages cache matching and reuse. A and B are a way to picture the computation being reused. The application doesn't have to invent cache identifiers and substitute them for its message history.

These controls have different consequences for information. A cache hit can make the same history cheaper to process. Truncation removes material before it enters the conversation. Compaction summarizes material already there and can lose detail. None of the three, by itself, restores the in-memory conversation after the terminal process exits.

### Run the same repository inspection with caching off and on

[38:25](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2305s)

A cost logger makes the effect of caching visible. Disable the cache configuration, restart the agent and ask it to read the project files individually, paying particular attention to the large pnpm lockfile. The logger initially reports 864 prompt tokens and zero cached tokens. As the tool results accumulate, the estimated cost rises.

The lockfile is too long to consume conveniently in one result. The model decides to use `sed` to read it in chunks. That's a nice consequence of the earlier design. The harness can tell the agent that a result is too big without having to implement a special reading strategy for every file format. The agent reports reading the project apart from `.env`, which contains secrets. The uncached run reaches 28,072 prompt tokens at one reported checkpoint, with an estimated cost of about two cents.

Re-enable caching and paste in the same prompt with the same model. How can a run that uses more tokens cost less? Compare the cached-token counter alongside the total. Earlier parts of the conversation now qualify for reuse. The second run ends up with more token activity but a lower reported spend.

Kumar estimates a roughly two- to threefold cost difference in this demonstration. Treat that as an illustration. The dollar totals he quotes vary across the comparison, and the model batches some reads differently despite receiving the same instructions. The useful result is that counting tokens without distinguishing fresh input from cached input can give you the wrong impression of what a task costs.

### Give long tasks smaller contexts and explicit handoffs

[42:27](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2547s)

Caching makes a long conversation cheaper. It still leaves the agent responsible for finishing a long sequence of decisions correctly. Even an agent that usually gets an individual step right can have a surprisingly poor chance of getting every step right.

Kumar reports a comparison from his own side project involving 120 tasks. Running everything in one loop succeeded about 29% of the time. Dividing the work into ten phases of twelve tasks each, with fresh contexts and a lead agent assembling the results, brought the reported completion rate to about 85%.

His [companion article](https://tej.as/blog/how-to-build-a-coding-agent-harness) gives a related forecast for a 122-step job. If every step must succeed, the steps are independent and each succeeds with probability 0.99, the chance of finishing in one pass is $$0.99^{122} \approx 0.29$$. The forecast for phased execution allows one retry per phase. That assumption matters. A shorter phase gives the harness somewhere to detect a failure and retry a limited portion of the job. The projected gain combines that recovery policy with the division of work.

In `phases.ts`, delegation is another tool. The lead agent plans the parts, writes a self-contained brief for each and calls `run_phase`. The tool starts another invocation of `runAgent` with a fresh message history, the phase instructions and the working tools. The worker finishes with a short note. The lead checks that note before handing off the next part.

A small exercise makes the handoff easy to follow. Ask for two counts, first the lines in `package.json`, then the lines in the pnpm lockfile, and explicitly request phases. What does each worker do? The first phase requests Bash access to count the lines. The second deals with an imprecise filename, finds the intended lockfile and finishes its own count. The lead reports both results.

The worker's intermediate tool traffic can stay in its own conversation. That makes the brief and the returned note especially important. They're how the lead and worker communicate what the other needs to know.

What crosses a phase boundary?
The lead retains the overall assignment. Each worker gets its own brief and conversation. The first worker's note returns to the lead for inspection before the lead delegates the second count.
- Plan both counts — Keep the full assignment and prepare a brief for the first file.
- Count package.json — Start a fresh conversation and use the permitted tools to obtain the line count.
- Check the first note — Retain the result and prepare the next brief.
- Find and count the lockfile — Start with a separate history, resolve the filename and obtain the second count.
- Report both results — Combine the workers' notes in the original conversation.
- Plan both counts → Count package.json (First brief)
- Count package.json → Check the first note (Return first note)
- Check the first note → Find and count the lockfile (Next brief after review)
- Find and count the lockfile → Report both results (Return second note)
- Check the first note → Report both results (Retain first count)

### Turn off Wi-Fi and run IBM Granite locally

[45:57](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2757s)

An enterprise with an air-gapped environment presents a useful test of the design. How much of the coding agent depends on the cloud model? Kumar disables Wi-Fi and selects **IBM Granite 4 Tiny** through Ollama. The first attempt fails with `EHOSTUNREACH`. He has forgotten to check out the branch that actually reads the model environment variable and redirects the client.

On the correct branch, [Ollama's Anthropic-compatible API](https://docs.ollama.com/api/anthropic-compatibility) lets the existing SDK talk to localhost. The companion implementation selects `granite4:tiny-h` through `MODEL` and changes the SDK's base URL to `http://localhost:11434`. It sends a plain request to the local model, leaving out the Claude-specific caching and compaction configuration. The file tools and their dispatch code remain available.

Granite initially answers the `package.json` question in general terms. A more explicit request to read *this repository's file* gets it to invoke the reader. Can it write something too? Asked to create `Beyonce.md`, the offline agent produces a substantial, encyclopedia-like biography of Beyoncé.

The biographical material comes from the model's learned knowledge, with no live lookup to establish its accuracy. The observable achievement is that a local model generated content and used the same harness to put it on disk. The extra prompting also shows why swapping a model requires testing how well it selects and uses the available tools.

### Change the agent's job by replacing its tools

[48:45](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2925s)

Restore the network and change a different variable. Keep the conversation machinery, budgets, phases and context handling, but give the agent an authenticated browser in the cloud. Which parts of the coding harness have to change?

Most of the interesting changes are in `browser.ts`. The tool registry now offers workspace operations, navigation, reading page text, extracting structured information and acting on a page. The surrounding changes are small, including adjustments to terminal rendering. The same dispatch mechanism can call a browser operation just as easily as a filesystem function.

Permissions have to follow the new capabilities. In Kumar's [written browser implementation](https://tej.as/blog/how-to-build-a-coding-agent-harness), the underlying service, Daiku, handles confirmation on the person's phone before actions such as sending, paying or deleting. A separate `ask_person` tool can resolve choices that materially affect the task, such as which shop or date to use. A local terminal prompt around `bash` would have been a poor fit for those decisions.

The new assignment is to find open calls for papers for future AI Engineer events. The agent opens a workspace, visits the event site and investigates speaking and submission options. While it searches, an audience member asks how the model even knows which tool to call.

The answer goes back to the registry. The SDK receives the tool names, descriptions and schemas with the request. The model can use those descriptions to select an operation and return its name and arguments as structured data. The harness knows which executable function corresponds to that name. Changing the registry changes the set of actions the model can discover and request.

The agent ultimately reports that it didn't find an open call. That's the outcome of its search, with no proposal submitted. Meanwhile, the familiar usage logger reports about 10,000 cached tokens. The domain changed substantially, and the work of managing a growing conversation carried over.

### Which parts are worth building yourself?

[52:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3150s)

[Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview) changes who runs the loop. What remains in the client? In `managed.ts`, the application maps its tools into the service's format and defines an agent with a model, system prompt and tools. In the hosted configuration shown here, Anthropic supplies a sandboxed environment and runs the interaction, including context management. The example uses the beta API.

Owning the loop gives you control over its implementation and infrastructure. A managed service takes on much of the operational work. Having built both a coding agent and a browser agent around the same loop, Kumar has a fairly specific division of responsibilities in mind.

### Keep the decisions that depend on your application

- **Tool registry.** Your team knows what the application can do and how to describe those operations to the model.
- **Permissions and checkpoints.** Your business determines which actions require consent and which unresolved choices warrant interrupting the person.
- **Phases.** Your workflow determines how to divide a job, what each worker needs and what counts as an acceptable handoff.
- **Budgets.** The right limits depend on the material your tools return. A browser agent inspecting a shopping page might encounter an enormous amount of tracking information in product URLs alone.

### Consider buying durable execution

Keeping an agent running through network failures, preserving session history across deployments and resuming interrupted work are recurring infrastructure problems. Services such as Temporal and Restate specialize in durable execution. A managed agent service can also take responsibility for the loop, sandbox, caching and compaction. Part of what you're buying is someone else's operational responsibility when that machinery fails.

The original disappearing-name experiment is a miniature version of this infrastructure problem. Keeping messages in an array is easy. Making a session survive a closed client or a restarted server is a separate piece of engineering. The [companion article](https://tej.as/blog/how-to-build-a-coding-agent-harness) develops that option further with a Cloudflare Worker and a Durable Object per session, including stored history and replayable events.

### What would you need to trust a software factory?

[56:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3390s)

One reason to build a harness by hand is to discover which problems a larger model would actually solve. Replacing Haiku might improve instruction following. It wouldn't persist the message array, enforce a spending limit or put an approval prompt in front of a destructive shell command. Those are changes you can make directly to the application.

Kumar's [earlier browser-agent demonstration](https://ai.engineer/talks/C_GG5g38vLU-ai-agent-harnesses) makes that distinction concrete. An older **GPT-3.5 Turbo** agent attempted to upvote a Hacker News story, reached a login screen and reported success anyway. Adding verification let the harness identify the failure. Handling authentication outside the model then let the same agent finish the task. That's a useful reason to evaluate a cheaper model with a better harness before paying for a larger one.

Evaluation belongs before deployment. The workshop itself suggests some concrete cases. Does refusing a deletion leave the files intact? Does a requested edit appear in the intended branch? Can a large tool result be recovered in smaller pieces? Does the budget actually stop a deliberately long run? Each question has an outcome you can inspect independently of the assistant's final answer.

The closing prediction depends on getting those checks right. Kumar compares a software factory to a factory that fills mouthwash bottles. You can leave the line running because you trust the machines to perform their individual jobs repeatedly. A software factory would need similar confidence in its harnesses, including confidence that they'll stop and involve a person when required.

Beyond that, he imagines a “super harness” that can choose between specialized harnesses or construct one for a new task. A general assistant could recognize a coding job and invoke a coding harness without making the user switch applications. Kumar speculates that this could contribute to more general intelligence. The workshop demonstrates a smaller, tangible prerequisite for that vision. The same loop can already do substantially different work when you change what it can see, what it can call and when it has to ask you.

## Key takeaways

- This harness uses two loops. The outer loop accepts tasks. The inner loop calls the model, executes requested tools and appends their results until the model stops requesting tools.
- Enforce permissions and usage budgets in application code. Return refusals and tool failures to the model so it can respond to what actually happened.
- Limit oversized tool results, cache repeated prompt prefixes and choose a compaction threshold that accounts for pricing. Truncation and compaction change what the model sees, while caching can make unchanged history cheaper to process.
- A subagent can be a tool that runs the existing agent loop with a fresh history. A focused brief and a short, checked result give the lead agent a way to divide longer jobs.
- Changing the model and changing the domain are separate engineering decisions. Granite reused the file tools locally. Browser automation reused the surrounding machinery with a different registry and permission policy.
- Consider buying durable execution while retaining the tools, approval rules, task phases and budgets that encode your business. Evaluate actual outcomes before trusting the resulting system to work unattended.

## Resources

- [How to Build a Coding Agent Harness From an Empty Loop](https://tej.as/blog/how-to-build-a-coding-agent-harness) — Kumar's companion walkthrough includes TypeScript excerpts, tool definitions, cache configuration, the assumptions behind the phase forecasts and an additional implementation with persistent HTTP sessions.
- [Anthropic TypeScript SDK](https://github.com/anthropics/anthropic-sdk-typescript) — The SDK used for model requests, message types and tool definitions in the workshop.
- [Ollama's Anthropic API compatibility](https://docs.ollama.com/api/anthropic-compatibility) — Explains how to point the existing client at a local inference server and which provider-specific features require different handling.
- [IBM Granite 4 on Ollama](https://ollama.com/library/granite4) — The local model family used to demonstrate repository inspection and file creation without cloud inference. The model listing includes the `granite4:tiny-h` variant.
- [Claude Managed Agents overview](https://platform.claude.com/docs/en/managed-agents/overview) — Compare the hand-built loop with a managed agent, its execution environment, persistent sessions and event stream.
- [basically-ai-harness](https://github.com/TejasQ/basically-ai-harness) — The branch-by-branch TypeScript code from Kumar's earlier browser-agent talk. It develops guardrails, verification and authentication handling around an agent that initially reports a false success.
- [AI Software Factories Were a Mistake: We're Not There Yet](https://tej.as/blog/ai-software-factories-were-a-mistake) — Kumar's subsequent reassessment gives a practical counterpoint to the closing prediction. His own factory accumulated 70 tickets in progress, exposing problems with human decisions, verification and unfinished work.

## Slides

### Harnesses in AI

The QR code points to Tejas Kumar’s 20-minute AI Engineer Europe talk, where he broke an agent harness into six components. This workshop takes three times as long to explore how those pieces turn a simple loop into a coding agent.

[2:37](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=157s) [Thumbnail of an earlier AI Engineer Europe presentation titled Harnesses in AI, alongside a QR code.](https://assets.ai.engineer/sites/aiecode2025/sha256/e96f183f3c9b1c32afb45df5d4abd5c1624d88234fc558e90a4bf2e05ac3a4e9.webp)

Harnesses in AI

AI Engineer
EUROPE
IBM

What Harness[illegible]
• Eval Harness (ML Engineering[illegible]
• Agent Harness (AI Engine[illegible]

Agent Harness
• Tool Registry
• Model
• Context Management
[illegible]rdrails
[illegible]op

AI Engineer
Code Summit
PRESENTED BY
Google DeepMind

NOVEMBER 10, 2026
Workshop Room 4

### Building the Harness Components

With three times as much time as his European talk, Tejas Kumar invites the audience to code along and build all three parts of an agent harness, including the guardrails that limit how long the agent can run.

[5:59](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=359s) [Large text reads “Today we build all of them in 3x as long.”](https://assets.ai.engineer/sites/aiecode2025/sha256/2f972d381564f0fe8b2721e7bf2a79562dd3721f5d5c01b51362cf4f9467f7e1.webp)

Today we build all of them in 3x as long.

X @tejaskumar_

AI Engineer
Code Summit

PRESENTED BY
Google DeepMind

AI Engineer

### Sans Harness

Without a harness, each model call starts fresh. An uncapped loop can resend the entire prompt on every retry and run up the bill. Give the agent Bash access without an approval step and “clean up this file” might delete the file you meant to refactor.

[7:48](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=468s) [Three panels explain how an unharnessed model forgets context, retries indefinitely and takes potentially destructive actions without approval.](https://assets.ai.engineer/sites/aiecode2025/sha256/2bb8589c54da7f5060196889516c8133e35abe9914f8c407877b907e1f12d361.webp)

Sans Harness
X @tejaskumar_

It forgets
EVERY CALL STARTS FROM NOTHING. ASK ITS NAME TWICE AND YOU GET TWO STRANGERS.

It runs away
A LOOP WITH NO CAP RETRIES FOREVER AND EVERY RETRY RESENDS THE PROMPT FROM THE TOP.

It acts alone
GIVE IT BASH WITH NO GATE AND “CLEAN UP” MEANS RM -RF.

Interface text:
AI Engineer
Code Summit
PRESENTED BY
Google DeepMind
NOVEMBER 10, 2026
Workshop Room 4

### Examples of AI Harnesses

Codex and Claude Code sit above their general-purpose counterparts, ChatGPT and Claude. Kumar considers all four harnesses. Each gives the model tools and constraints suited to a different kind of work.

[9:14](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=554s) [Four white logos in a two-by-two grid represent Codex, Claude Code, ChatGPT and Claude.](https://assets.ai.engineer/sites/aiecode2025/sha256/06b3ecf01c9a86a81208ad356a4b63e3b9e4b8ff350dfe359bd88e6639dc45d5.webp)

X @tejaskumar_

AI Engineer
Code Summit

PRESENTED BY
Google DeepMind

Engineering the future of AI

### Harnesses Are Domain-Specific

The same agent loop can serve different domains. What changes is which tools the harness gives the model and when it can use them. A coding agent can read and edit files, run Bash commands and test changes, but it needs the user’s approval before pushing.

[9:54](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=594s) [A table shows coding tools for reading, editing, running Bash and testing, with a rule requiring approval before pushing. A footer says domains share a loop but differ in their tool registries and rules.](https://assets.ai.engineer/sites/aiecode2025/sha256/7f952a668d74b229df543118e3827c0f847a5c8f02c81a5d6f7d665c6a9c85f5.webp)

Harnesses are Domain-Specific

Domain | Its tools | Its rule
Coding | read, edit, bash, test | Never push without a yes

THE LOOP IS THE SAME IN ALL FOUR. THE REGISTRY AND THE RULES ARE THE DOMAIN.

X @tejaskumar_

AI Engineer
Code Summit
PRESENTED BY
Google DeepMind

NOVEMBER 10, 2026
Workshop Room 4

### A minimal TypeScript conversation harness

The loop skips blank input, adds each user message to the conversation history and sends the whole history to the model. It saves every block of the assistant’s reply for the next turn, even though the terminal prints only the text blocks.

[12:47](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=767s) [The TypeScript editor shows a loop that reads terminal input, skips empty messages, sends conversation history to the model, stores the full assistant response and prints its text blocks.](https://assets.ai.engineer/sites/aiecode2025/sha256/887abdddc08a254f805d8abfcd53c8770bb267cea489ae1f0961b1eeaeb9d491.webp)

harness.ts

const terminal = createInterface({ input: process.stdin, output: process.stdout });
const messages: Anthropic.MessageParam[] = [];

while (true) {
  const ask = await terminal.question("\nyou> ");
  if (!ask.trim()) continue;
  messages.push({ role: "user", content: ask });

  const response = await client.messages.create({ model: MODEL, max_tokens: 16000, messages });

  // Append the whole content, never just the text: the history only ever grows.
  messages.push({ role: "assistant", content: response.content });
  for (const block of response.content) if (block.type === "text") console.log(`\nai> ${block.text}`);
}

AI Engineer
Code Summit
PRESENTED BY
Google DeepMind
NOVEMBER 10, 2026
Workshop Room 4

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
Tue 10. Nov 09:13:12
diy-harness
Upgrade
TS harness.ts
TS harness.ts > ...
Line numbers: 8–22
Bootstrap v5.3.8
diy-harness
Live Share
LF
TypeScript
Tab Stats: 8/41 (20%)
Agent Stats: 0/0 (0%)
No commit scored
Claude Code
Prettier

### The agent cannot read repository files

Running the harness inside a repo doesn’t give the model access to its files. Asked what package.json says, the agent suggests pasting its contents into chat. Kumar’s next step is to give the harness a tool for reading files.

[17:05](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1025s) [A terminal conversation shows the agent explaining that it cannot access the repository or inspect package.json.](https://assets.ai.engineer/sites/aiecode2025/sha256/c89e7cc27c6bbabd6565006f05e69c78baabf7b15c7113f6e2b7ecca2d59d0b7.webp)

➜ diy-harness git:(0) npm start

> start
> node --env-file-if-exists=.env --import tsx harness.ts

you> whats my name

ai> I don't know your name. This is the start of our conversation, and I don't have access to any information about you beyond what you've told me here.

If you tell me what you'd like me to call you, I'm happy to use that name for the rest of our chat.

you> what does package.json say in this repo?

ai> I can't see your repo. I don't have access to your file system, and no files have been shared in this conversation.

To see what's in your `package.json`, you can:

- **Open it directly** in your editor, or run `cat package.json` (macOS/Linux) or `type package.json` (Windows) from the repo root.
- **Paste the contents here**, and I can explain what it says, spot issues, or help with dependencies and scripts.

If you're using an AI coding tool like Cursor, Claude Code, or GitHub Copilot in your editor, those can read files in your project directly.

you>

Interface text:
iTerm2  Shell  Edit  View  Session  Scripts  Profiles  Window  Help
Tue 10. Nov 09:17:23

### Processing responses in the agent loop

runAgent saves the full assistant response in the conversation history. The highlighted line prints only the text blocks. The loop ends unless the model requests a tool, in which case it runs the tools and sends their results back in one user message.

[19:26](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1166s) [The runAgent function stores assistant responses, prints text blocks, checks the stop reason and appends tool results. The text-printing line is highlighted.](https://assets.ai.engineer/sites/aiecode2025/sha256/d9a8a92bc4c704d4d8a1cb6cfb63186fd8b5cdfd2e1e2cef501bc61a24f5d40d.webp)

const client = new Anthropic();
const MODEL = process.env.MODEL ?? "claude-haiku-5-5";

export async function runAgent(messages: Anthropic.MessageParam[]) {
  while (true) {
    const response = await client.messages.create({ model: MODEL, max_tokens: 16000, tools, messages })
    // Append the whole content, never just the text: the history only ever grows.
    messages.push({ role: "assistant", content: response.content });
    for (const block of response.content) if (block.type === "text") log(`\nai> ${block.text}`);
    if (response.stop_reason !== "tool_use") return;
    messages.push({ role: "user", content: await runTools(response.content) });
  }
}

// Every tool_use gets exactly one tool_result, all in ONE user message. An error goes back as a
// result too: the model can recover from an error it can see.
async function runTools(content: Anthropic.ContentBlock[]) {
  const results: Anthropic.ToolResultBlockParam[] = [];
  for (const block of content) {

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
Tue 10. Nov 09 19 40
diy-harness
Upgrade
harness.ts  tools.ts  agent.ts
agent.ts > runAgent
Add to Chat ⌘L
Bootstrap v5.3.8  diy-harness  Live Share  LF  TypeScript  Tab Stats: 8/41 (20%)  Agent Stats: 0/0 (0%)  No commit scored  Claude Code  Prettier

### Returning tool results to the model

When Claude requests tools, the harness appends a single user message directly after Claude’s reply, with one result per request. Errors count as results, so Claude can see what failed on the next pass. The loop ends when the stop reason is no longer tool_use.

[20:32](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1232s) [The editor focuses on the line that appends the output of runTools as a user message. A comment explains that each tool request receives one result.](https://assets.ai.engineer/sites/aiecode2025/sha256/b7087b7be9c64f7c98010a420432fa27f953122ff7a6b4037f4d8d418873cec0.webp)

import { tools, runTool } from "./tools.ts";

const client = new Anthropic();
const MODEL = process.env.MODEL ?? "claude-haiku-5-5";

export async function runAgent(messages: Anthropic.MessageParam[]) {
  while (true) {
    const response = await client.messages.create({ model: MODEL, max_tokens: 16000, tools, messages })
    // Append the whole content, never just the text: the history only ever grows.
    messages.push({ role: "assistant", content: response.content });
    for (const block of response.content) if (block.type === "text") log(`\nai> ${block.text}`);
    if (response.stop_reason !== "tool_use") return;
    messages.push({ role: "user", content: await runTools(response.content) });
  }
}

// Every tool_use gets exactly one tool_result, all in ONE user message. An error goes back as a
// result too: the model can recover from an error it can see.
async function runTools(content: Anthropic.ContentBlock[]) {

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
Tue 10. Nov 09:20:52
diy-harness  Upgrade
harness.ts  tools.ts  agent.ts
agent.ts > runAgent > content
Line numbers 5–23
Bootstrap v5.3.8  diy-harness  Live Share  LF  TypeScript  Tab Stats: 8/41 (20%)  Agent Stats: 0/0 (0%)  No commit scored  Claude Code  Prettier

### The agent reads and explains the project

Three read_file calls let the agent explain its own harness, including how the messages array preserves conversation history across Claude calls. It also flags a gap in its answer. It hasn’t read tools.ts, so it can only guess which other tools exist.

[21:28](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1288s) [Three read_file calls appear above a terminal response explaining the roles of harness.ts, agent.ts and terminal.ts.](https://assets.ai.engineer/sites/aiecode2025/sha256/75f1b5afb4c9e577593f76948f8d0295489caa9ea905c5acd014e5bc86b961d9.webp)

**Dependencies:**
- `@anthropic-ai/sdk` 1.4.0
- `@inquirer/prompts` 8.7.4
- `ora` 9.4.1

**Dev dependencies:**
- `@types/node` 22.20.5
- `tsx` 4.23.15
- `typescript` 5.9.3

✔ you what is this project actually?
  ↳ read_file {"path":"harness.ts"}
  ↳ read_file {"path":"agent.ts"}
  ↳ read_file {"path":"terminal.ts"}

ai> This is a small, hand-built terminal coding-style agent, a "DIY harness" around Anthropic's Claude API. It's a learning or reference project rather than a finished product.

It's built from three files:

- **`harness.ts`** is the chat loop. It reads a line from you, adds it to a `messages` array, and hands the array to the agent. The array is the only memory, since the model keeps no state between calls.
- **`agent.ts`** is the core agent loop. It calls the model, prints any text it returns, and if the model requests tools (`stop_reason === "tool_use"`), it runs them, sends the results back, and calls the model again. Tool errors are returned to the model as error results so it can recover.
- **`terminal.ts`** handles the UI: prompts via `@inquirer/prompts`, a spinner via `ora` while waiting on the model or a tool, and colored output (cyan for the AI, yellow for tool calls, red for errors).

The comments say the model is `claude-haiku-5-5` by default, overridable with a `MODEL` env var. `agent.ts` imports `./tools.ts` for the tool definitions and `runTool`, but I haven't read that file, so I don't know which tools exist. Given the `{ path: string }` input type and the `read_file` tool I have, they're probably file-related, but I'd need to read `tools.ts` to confirm.

? you

Interface text:
iTerm2  Shell  Edit  View  Session  Scripts  Profiles  Window  Help
Tue 10. Nov 09:21:59

### Inspecting the project and proposing agent guidance

Passing the tool list to the Anthropic SDK lets the agent offer actions it can take. It finds no AGENTS.md in the repo root and offers to document setup commands and the workshop’s branch conventions. Kumar says yes, and the agent calls writeFile.

[24:19](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1459s) [The terminal agent lists files, reads project documentation, summarizes the workshop and offers to create an AGENTS.md file. The user agrees.](https://assets.ai.engineer/sites/aiecode2025/sha256/d4124e53c3639664b4c62a7cf83dd3c01ed21e894c84a3f5fb4bdf09918104d4.webp)

✔ you what is this project?
  ↳ list_files {"path":"."}
  ↳ read_file {"path":"README.md"}
  ↳ read_file {"path":"package.json"}

ai> This is a workshop project for building a coding agent from scratch. The README says it's code for the AI Engineer Code Summit 2026. It starts from an empty `while (true)` loop and adds one idea at a time: tools, guardrails, context management, phases, swappable models, and a new domain (browser automation). The last step rents the same loop from Anthropic's Claude Managed Agents.

It's organized as git branches `0` through `8`, one per step. Each step adds a single file, and each branch has a `CHANGELOG.md` with the prompt for that step and things to try.

The files present in this checkout are `harness.ts`, `agent.ts`, `tools.ts`, `coding.ts`, and `terminal.ts`, which matches roughly branch 2 (the tool registry). `guardrails.ts` and the later files aren't here yet.

The stack is TypeScript on Node 22+, with the Anthropic SDK, `@inquirer/prompts` for input, and `ora` for a spinner. To run it, add an `ANTHROPIC_API_KEY` to `.env` and run `pnpm start`.

I only read the README and `package.json`. If you want, I can walk through `agent.ts` or `tools.ts` next to show how the loop works.

✔ you cool, do we have agents.md

ai> No, there isn't one. The root of the project has `.env`, `.env.example`, `CHANGELOG.md`, `README.md`, `package.json`, `tsconfig.json`, and the `.ts` source files, but no `AGENTS.md` or `agents.md`. I only checked the root folder, so I haven't looked in subfolders.

Should I create one? It would normally cover the setup and run commands (`pnpm install`, `pnpm start`, `pnpm typecheck`), the one-file-per-step branch convention from the README, and any rules for coding agents working in this repo. I'd want to check with you on the conventions first, since the branch structure means edits to one step can affect the others.

✔ you yes
thinking

Interface text:
iTerm2  Shell  Edit  View  Session  Scripts  Profiles  Window  Help
Tue 10. Nov 09:24:33

### Planning a Python port

Before changing a file, the agent spots uncommitted edits on branch 2. It proposes a separate Python branch and asks whether to port step 2 or the final step 8. Kumar answers all four questions with “jsut fo it i odnt care”.

[25:40](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1540s) [After inspecting the repository, the agent asks about the scope, destination branch, uncommitted changes and Python dependencies. The user tells it to proceed.](https://assets.ai.engineer/sites/aiecode2025/sha256/347435e0c2b69174671276a78466f4127cbd6c9e7c5ed3cb8d256e8b8cf763dc.webp)

↳ read_file {"path":"tools.ts"}
↳ read_file {"path":"coding.ts"}
↳ read_file {"path":"terminal.ts"}
↳ read_file {"path":"CHANGELOG.md"}
↳ read_file {"path":".env.example"}
↳ bash {"command":"git diff coding.ts; echo \"---\"; git branch -a; echo \"---\"; cat .gitignore"}

ai> I haven't changed anything yet. A few things need your decision first.

What I found

- You're on branch `2`, and `coding.ts` has uncommitted changes. The diff looks like a reformat only: the same five tools, split across multiple lines. I haven't checked whether it's purely formatting.
- Branches `0` to `8` are the workshop's reference steps, and my `AGENTS.md` says not to rewrite them. Overwriting files on branch `2` would also mix the port into your uncommitted work.
- The project is about 220 lines of TypeScript across `harness.ts`, `agent.ts`, `tools.ts`, `coding.ts`, and `terminal.ts`, plus the `pnpm` setup.

Questions

1. Scope: Do you want the port of the step-2 code (what's here now), or the full final state from branch `8`? Branch `8` also adds files I haven't read yet.
2. Where it goes: I'd suggest a new branch, such as `python`, created from `main` or from `2`, leaving the TypeScript branches alone. Should I put the Python version there?
3. Uncommitted `coding.ts` change: Should I commit it, stash it, or leave it out of the port?
4. Python equivalents: I'd use the official `anthropic` SDK, `prompt_toolkit` or `questionary` in place of `@inquirer/prompts`, `rich` for colours, and a spinner from `rich` for `ora`. `uv` or a `pyproject.toml` would replace pnpm. Tell me if you prefer different libraries.

Once you answer these, I'll write the port and run a check on it.
✔ you jsut fo it i odnt care
thinking

Interface text:
iTerm2  Shell  Edit  View  Session  Scripts  Profiles  Window  Help
Tue 10. Nov 09:26:00

### Tracking per-task usage limits

Each task starts with a fresh budget. Every model call adds one step and its input and output tokens. The budget is spent as soon as either limit is reached. A separate gate asks permission before the agent writes files, edits them or runs shell commands.

[28:45](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1725s) [TypeScript budget function increments step and token counters and checks whether either limit has been reached.](https://assets.ai.engineer/sites/aiecode2025/sha256/2b170229e02a337945f96f305badd040c2fd46650d6b6781e650c16af7e26e9a.webp)

const ASK_FIRST = new Set(["write_file", "edit_file", "bash"]); // changes something

// One budget per task: count every model call, and say when either cap is reached.
export function budget() {
  let steps = 0;
  let tokens = 0;
  return {
    count: (used: number) => {
      steps += 1;
      tokens += used;
    },
    spent: () => steps >= MAX_STEPS || tokens >= MAX_TOKENS,
    toString: () => `${steps} steps and ${tokens} tokens`,
  };
}

// A no becomes an error the model can see, so it asks instead of trying again.
export async function gate(name: string, input: Input) {…
}

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
Tue 10. Nov 09:28:59
diy-harness
Upgrade
guardrails.ts
guardrails.ts > budget > count
Bootstrap v5.3.8  diy-harness  1  0  Live Share
LF  TypeScript  Tab Stats: 8/41 (20%)  Agent Stats: 0/0 (0%)  No commit scored  Claude Code  Prettier

### Denying a destructive tool request

The agent proposes deleting everything except .git. Kumar answers No at the Bash prompt. The harness blocks the command and sends the refusal back to the model as a tool result. The agent lists the directory again.

[29:48](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1788s) [The terminal asks permission to delete project files. The user answers No, and the agent lists the directory again.](https://assets.ai.engineer/sites/aiecode2025/sha256/27077aa3930db0490b4533427d35b383f72264270f7f405458613dfce2bccd67.webp)

➜ diy-harness git:(3) npm start

> start
> node --env-file-if-exists=.env --import tsx harness.ts

✔ you yo this project is obsolete, delet eeverything in here
  ↳ list_files {"path":"."}
  ↳ bash {"command":"find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} + && ls -la"}
✔ allow bash {"command":"find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} + && ls -la"}? No
  ↳ list_files {"path":"."}
  thinking

Interface text:
iTerm2  Shell  Edit  View  Session  Scripts  Profiles  Window  Help
Tue 10. Nov 09:30:23

### Counting and reading project files

Kumar wants to test the harness’s 25-call limit by asking the agent to read files one by one. Of 5,052 files, 4,926 are in node_modules. With those excluded, the agent issues 14 individual read requests. The demo hasn’t hit the limit yet.

[31:15](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1875s) [The agent reports 5,052 files, breaks down the directory contents, and issues individual requests to read project files.](https://assets.ai.engineer/sites/aiecode2025/sha256/cd178d6104f1fea0e548ea6b65ef753fcc16e918f8e293f81beb29744a5f2b44.webp)

✔ you how many files are in this dir
  ↳ bash {"command":"echo \"total files: $(find . -type f | wc -l)\"; echo \"excluding .git: $(find . -type f -not -path './.git/*' | wc -l)\""}
✔ allow bash {"command":"echo \"total files: $(find . -type f | wc -l)\"; echo \"excluding .git: $(find . -type f -not -path './.git/*' | wc -l)\""}? Yes
  ↳ bash {"command":"find . -type f -not -path './.git/*' | cut -d/ -f2 | sort | uniq -c | sort -rn | head -20"}
✔ allow bash {"command":"find . -type f -not -path './.git/*' | cut -d/ -f2 | sort | uniq -c | sort -rn | head -20"}? Yes

ai> There are 5,052 files in this directory in total.

- Project files: 14 at the top level (for example `agent.ts`, `package.json`, `.env`).
- `node_modules/`: 4,926 files. My earlier file listing didn't show these, but they're there.
- `.git/`: about 112 files.

If you delete the project, `node_modules/` is the bulk of the size and can be regenerated with `pnpm install`, so it's safe to remove. The open questions from before still apply: whether to delete `.git` and `.env`.

✔ you cool. read each file except node modules one by one thank
  ↳ read_file {"path":".env"}
  ↳ read_file {"path":".env.example"}
  ↳ read_file {"path":".gitignore"}
  ↳ read_file {"path":"CHANGELOG.md"}
  ↳ read_file {"path":"README.md"}
  ↳ read_file {"path":"agent.ts"}
  ↳ read_file {"path":"coding.ts"}
  ↳ read_file {"path":"guardrails.ts"}
  ↳ read_file {"path":"harness.ts"}
  ↳ read_file {"path":"package.json"}
  ↳ read_file {"path":"pnpm-lock.yaml"}
  ↳ read_file {"path":"terminal.ts"}
  ↳ read_file {"path":"tools.ts"}
  ↳ read_file {"path":"tsconfig.json"}
thinking

Interface text:
iTerm2  Shell  Edit  View  Session  Scripts  Profiles  Window  Help
Tue 10. Nov 09:31:32

### Handling repeated permission denials

The harness asks permission for each Bash command. Kumar blocks the deletion of node_modules, then declines even the check for whether it still exists. The agent keeps going and calls list_files on the current directory.

[31:49](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1909s) [The terminal summarizes the project, warns about stored credentials, and shows the user declining two successive shell requests.](https://assets.ai.engineer/sites/aiecode2025/sha256/d89e5316ccac2061e7daeae7b36c1401d1ddb414b7a22e66f01bc65f8a7a53bd.webp)

sking for tools. Enforces the budget and prints warnings for `max_tokens` and `refusal`.
- `tools.ts`: defines what a tool is (`{ definition, run }`), a `tool()` helper that builds the JSON schema, and `runTool()`, which runs the gate before executing.
- `coding.ts`: the five tools: `read_file`, `list_files`, `write_file`, `edit_file`, `bash`.
- `guardrails.ts`: caps each task at 25 model calls or 300k tokens, and asks for confirmation before `write_file`, `edit_file`, or `bash`.
- `terminal.ts`: prompts, colored output, and the spinner.
- `CHANGELOG.md` and `README.md`: a per-branch changelog and a course guide.
- `package.json`, `pnpm-lock.yaml`, `tsconfig.json`: standard build and dependency config. Dependencies are the Anthropic SDK, `@inquirer/prompts`, and `ora`, plus `tsx` and TypeScript for dev.
- `.gitignore`, `.env.example`: ignores `node_modules`, `.env`, and a few others. The example file has empty keys.

Things to know:
- `.env` contains live-looking secrets. It has a full `ANTHROPIC_API_KEY` and a `DAIKU_KEY`. It's gitignored, so it isn't in the repo's history, but anyone with access to this folder can read it. If the project is going away, rotate those keys in both services.
- The error I got when I tried to delete reads "The person said no. Ask them what to do instead." That's the exact message in `guardrails.ts`'s `gate()`. The refusal may have come from this project's own guard code rather than from you. Either way, nothing was deleted.
- The `CHANGELOG.md` has an example prompt, "Delete every file in this folder. Say no," which is the course's demo of the gate.

Still open from before: do you want `.git` deleted, do you want `.env` deleted, and should I go ahead with the delete?
✔ you no do it sequentially

ai> Understood. I'll delete everything one item at a time, starting with `node_modules`.
  ↳ bash {"command":"rm -rf node_modules && echo \"removed node_modules\""}
✔ allow bash {"command":"rm -rf node_modules && echo \"removed node_modules\""}? No
  ↳ bash {"command":"ls -d node_modules 2>/dev/null && echo \"node_modules still exists\" || echo \"node_modules missing\""}
✔ allow bash {"command":"ls -d node_modules 2>/dev/null && echo \"node_modules still exists\" || echo \"node_modules missing\""}? No
  ↳ list_files {"path":"."}
thinking

Interface text:
iTerm2  Shell  Edit  View  Session  Scripts  Profiles  Window  Help
Tue 10. Nov 09:32:03

### Setting context and tool-output limits

Kumar’s harness caps each tool result at 12,000 characters and tells the agent how to get the rest. It automatically compacts context at 90,000 tokens because, in his Haiku 5.5 example, exceeding 100,000 prompt tokens raises the price of the whole request 5×.

[34:22](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2062s) [The editor shows a 12,000-character tool-result limit and highlights a 90,000-token compaction threshold above folded context-management functions.](https://assets.ai.engineer/sites/aiecode2025/sha256/39642ec4328c20b3f67eef61d2b633297711d468d7c5800393e33a949bc3fd44.webp)

const MAX_RESULT = 12_000; // characters a tool result may put into the context
const COMPACT_AT = 90_000; // Haiku 5.5 charges 5x for the whole request past 100k prompt tokens

// Sent with every request. Stable first: tools, then the system prompt, then the conversation.
export const CONTEXT = {…
} satisfies Partial<Anthropic.Beta.MessageCreateParamsNonStreaming>;

// Compact at the source: a huge result is cut where it is made, with a note on how to get the rest.
export function fit(output: string) {…
}

// Claude Haiku 5.5, US dollars per million tokens.
const PRICE = { input: 0.1, cacheWrite: 0.125, cacheRead: 0.01, output: 0.5 };
let spent = 0;

// Print what one call cost, and return the tokens it used for the budget.
export function cost(usage: Anthropic.Beta.BetaUsage) {…
}

Interface text:
Cursor  File  Edit  Selection  View  Go  Run  Terminal  Window  Help
Tue 10. Nov 09:34:36
diy-harness
Upgrade
guardrails.ts  context.ts
context.ts > …
Add to Chat ⌘L
Bootstrap v5.3.8  diy-harness  Live Share  LF  TypeScript
Tab Stats: 8/41 (20%)  Agent Stats: 0/0 (0%)  No commit scored  Claude Code  Prettier

### Starting the uncached file-reading experiment

Kumar disables prompt caching and asks the agent to read every project file. Just listing the directory takes the next prompt from 864 to 4,579 tokens, with zero cached. The running cost reaches $0.0007 before the agent reads pnpm-lock.yaml.

[39:22](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2362s) [Terminal showing a request to read project files, a directory listing, a lockfile read and initial token counts with zero cached tokens.](https://assets.ai.engineer/sites/aiecode2025/sha256/c7de8a27e517607afac05e98788e6fcdfe04bbb5b375f490ab82ed2e2d60d348.webp)

➜  diy-harness git:(4) ✗ npm start

> start
> node --env-file-if-exists=.env --import tsx harness.ts

✔ you i need you PLEASE DO THIS WELL, read each file one by one especially the pnpm lockfile
  · 864 prompt tokens (0 cached), $0.0001, $0.0001 so far
  ↳ list_files {"path":"."}
  · 4579 prompt tokens (0 cached), $0.0005, $0.0007 so far

ai> Listing done. Now I'll read the project files one at a time, starting with the lockfile as you asked.
  ↳ read_file {"path":"pnpm-lock.yaml"}
⠙ thinking

Interface text:
iTerm2  Shell  Edit  View  Session  Scripts  Profiles  Window  Help
Tue 10. Nov 09 39 36

### Accumulated token usage without caching

As the agent reads more files, the harness resends the growing conversation on every call. The last reported call uses 28,072 prompt tokens, none cached, and costs $0.0029. That brings the running total to $0.0214.

[39:54](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2394s) [Terminal listing successive file reads and increasing costs, reaching 28,072 prompt tokens, zero cached tokens and $0.0214 spent so far.](https://assets.ai.engineer/sites/aiecode2025/sha256/e74154f05b2a0a157fddf8b56ad78ccdbd66e000d4d16c44a22856d74dd8e01e.webp)

· 16285 prompt tokens (0 cached), $0.0018, $0.0038 so far
↳ bash {"command":"sed -n '700,826p' pnpm-lock.yaml | grep -v -E '^\\s+(resolution|engines|cpu|os|libc):'"}
✔ allow bash {"command":"sed -n '700,826p' pnpm-lock.yaml | grep -v -E '^\\s+(resolution|engines|cpu|os|libc):'"}? Yes
↳ read_file {"path":"package.json"}
· 18379 prompt tokens (0 cached), $0.0020, $0.0058 so far

ai> Lockfile and package.json are consistent: every direct dependency in package.json matches its importer entry in the lockfile. Next, the remaining files one at a time.
↳ read_file {"path":"README.md"}
· 19958 prompt tokens (0 cached), $0.0020, $0.0078 so far
↳ read_file {"path":"CHANGELOG.md"}
↳ read_file {"path":"agent.ts"}
· 23550 prompt tokens (0 cached), $0.0024, $0.0103 so far
↳ read_file {"path":"coding.ts"}
↳ read_file {"path":"context.ts"}
· 25278 prompt tokens (0 cached), $0.0026, $0.0129 so far
↳ read_file {"path":"guardrails.ts"}
↳ read_file {"path":"harness.ts"}
· 26180 prompt tokens (0 cached), $0.0027, $0.0156 so far
↳ read_file {"path":"terminal.ts"}
↳ read_file {"path":"tools.ts"}
· 27410 prompt tokens (0 cached), $0.0029, $0.0185 so far
↳ read_file {"path":"tsconfig.json"}
↳ read_file {"path":".env.example"}
↳ read_file {"path":".gitignore"}
· 28072 prompt tokens (0 cached), $0.0029, $0.0214 so far

ai> I've read every file except `.env`, which holds secrets and is not needed here. I'll run the typecheck as a read-only check.
↳ bash {"command":"pnpm typecheck 2>&1 | tail -30; echo \"exit: $?\""}
✔ allow bash {"command":"pnpm typecheck 2>&1 | tail -30; echo \"exit: $?\""}? Yes
thinking

Interface text:
iTerm2  Shell  Edit  View  Session  Scripts  Profiles  Window  Help
Tue 10. Nov 09:40:11

### Phases

In Tejas Kumar’s experiment, one agent completed a 120-step task about 29% of the time. Success rose to 85% when he split the work into ten 12-step phases, gave each subagent a fresh context, and had a lead agent combine the results.

[43:22](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2602s) [A dark section slide titled Phases in large white lettering, displayed in the Keynote editor.](https://assets.ai.engineer/sites/aiecode2025/sha256/01b55b182ad1325677092356caeeabb7b9a26e699c7bc725d1bf919ed3df15bc.webp)

Phases

𝕏 @tejaskumar_

AI Engineer
Code Summit
PRESENTED BY
Google DeepMind

NOVEMBER 10, 2026
Workshop Room 4

Interface text:
Keynote   File   Edit   Insert   Slide   Format   Arrange   View   Play   Window   Help
Tue 10. Nov 09:43:36
k
View   Zoom   100%   Add Slide   Play in Window   Play   Table   Chart   Text   Shape   Media   Comment   Share   Format   Animate   Document

Slide navigator:
23
24   3   Guardrails
25   4   Context is the bill
26   5   Phases
27   Phases
28   Phases   29%   85%
29   Success shrinks with every step
6   Any model

Transitions
Magic Move
Change   Preview
Duration   0,6 s
Fade Unmatched Objects
Match
By Object   By Word   By Character
Acceleration
Ease In & Out
Start Transition   Delay
On Click   0,50 s
Build Order

## Full transcript

[0:12](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=12s) Morning. Good morning. Are we, are we good this morning? Yes. Half of you are asleep. Wonderful. This is the, this is the benefit of being the first workshop of the day. Hi.

[0:23](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=23s) Hi.

[0:23](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=23s) Good morning. Hey, he's awake. Good to see you. My name is Tejas, uh, pronounced like contagious. Uh, don't, don't worry, I'm not, uh, especially for the front row. Uh, and I'm really excited today. We're gonna have so much fun, uh, building a harness from scratch, from first principles. And, and we'll talk about what a harness is and, and so on. Really excited. But before we get ahead of ourselves, uh, let me just introduce myself a little bit more so you understand why does this guy care so much about harnesses. Um, I work at IBM.

[0:54](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=54s) Uh, I, I do AI, R&D, research and development, uh, at IBM, and we build, you know, things, um, at IBM. We build a coding agent called Bob. We build, um... We actually train our own models as well, Granite, they're called. Um, we do a bunch of things, right? And out of the research work, we find things that are interesting. Like, for example, how do you reduce your token spend from like two billion dollars a year to less than that, right? And so a lot of this work will ultimately, in some way, lead us to a harness, and that's why we're here

[1:23](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=83s) today. Um, today this is the mandate. This is our mission for today. We have an hour. We have an hour to build a coding agent harness from an empty loop. A coding agent harness from an empty loop. Now, can I just get a vibe check in this room? Uh, what-- Some of you may be confused by the word loop here. Like, you might be sitting here wondering, um, "What does a coding agent harness have to do with a loop," right? And, uh, if, if you, if this is you, will you show me your hand?

[1:54](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=114s) No, no, no shame in that. Okay, good. Everybody gets the loop. Oh, hey. Awesome, dude. That's why I'm doing this. Um, all agent communication is just a big loop, right? Just like if we think about human-to-human communication, it's also a loop. You know what I mean? Like, I'm talking to you, and you hear what I'm saying, and you process it, and then I talk to you some more. It's, it's literally an infinite loop. And so how do we get from that to an actual coding harness, something like Claude Code or Bob or Cursor

[2:24](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=144s) or Windsurf or Codex, um, any, anything else? Groq, right? Uh, anyway, so that's what we're gonna do today. Uh, this talk is not-- This is not the first time I've done this. Uh, last time we actually covered this as well. I, I had the privilege of speaking at AI Engineer Europe. Uh, if you, if you missed that, uh, there's a QR code for you. It was the twenty-minute version of this, and it was pretty well-received to the point where, you know, they said, "Let's do this now, but three times as long with more detail." Okay? And that's what we're gonna do today.

[2:54](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=174s) Um, what did we cover last time? This is important to just kinda orient us today in November 2026. In March, when I gave the talk in Europe, this is what we covered. We covered what goes into making a harness a harness. And back then, I said there were six things. Every harness has six components, and I outlined them. Uh, for example, you need a language model. You need tools. You need guardrails. You need verification steps. Um, you need context primitives, et cetera. So I laid out six

[3:24](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=204s) things. Today, those six things are three things, um, partly because companies are automating a lot of things, but also partly because they just roll into one. So for the sake of argument and learning today, let's look at what actually makes a good coding harness or what makes a harness in general. And number one is tools. Um, you-- Almost every har-- In fact, every harness today will have tools. Uh, that's kind of just part of what a harness is. Um, tools extend the capability of the model to actually do things instead of just

[3:54](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=234s) give you language. Otherwise, they're just language models, and language models give you language. Number two, um, context primitives. Every harness today has something to do with managing context, um, either something as basic as auto compaction, um, to something as maybe a little bit more advanced of, of prompt caching and finding the best way and when to compact and cache. And we'll go into a lot of detail about this. And number three is guardrails. Every harness today, coding or

[4:24](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=264s) otherwise, uh, has guardrails that prevent, that prevent you from doing some nonsense and prevent your agent or your language model from also going off the rails and, you know, like rm -rf, uh, your entire file system, right? And so we're gonna look-- I want you to pay attention to these 'cause these are gonna keep coming up as we build a harness. We're gonna start by understanding why we need tools, and then we'll build some tools. We'll recognize that, hey, tools aren't enough, and we actually need a tool set. Then we'll run into issues with context, and that's all by design. We're gonna feel some friction, some pain

[4:54](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=294s) today, um, and fix against the pain. I, I genuinely believe this is how the best engineering work is done. We, we find a constraint, and we build against the constraint. Okay? And one of the constraints is gonna be context. Almost all the models today have somewhere around a million tokens of context in their context window. Um, but should we ever reach that? Should we-- At what point do we auto compact so we can also keep costs low? This is-- We'll spend a lot of time on that. And then third, um, i-is guardrails. Uh, and just one, one aside real

[5:24](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=324s) quick. I didn't use Claude Design for this, okay? I just want to be very clear. Um, there's no eyebrows here or anything. All this is like human design, uh, i-into the fonts and everything. I just wanna get that out of the way 'cause I cannot look at Claude slop anymore. Um, anyway, so guardrails are also, um, to prevent your agent from bankrupting you, actually. You, you'll set, like, how many steps in our, in our conversation do I allow, right? How many tokens of context? At, at what point do we end the loop, et cetera. So these three make up

[5:54](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=354s) literally every harness you will see in the wild today, okay? Today, we're going to build that, um, in three times as long as the European talk. And, and look, I see all of you with your laptops out. Awesome. Don't listen to me. Uh, or maybe passively listen to me, I don't know. But, but I want you to build along and play and, and you can talk to your agent, right? And be like, "Hey, what, what is he saying? I, I wanna, I wanna build that," okay? Um, to understand also where harness fits in, and I promise you, once I start coding on this thing, there's no more slides. We're

[6:24](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=384s) just gonna, we're just gonna go for it. Uh, but before that, let's do some prep work also to warm up a little bit. Uh, what, what happens without, without a harness? Uh, why-- what do we get without a harness? And this is a very interesting topic 'cause I think all of us today use models, language models in some type of harness. We don't just use them for the sake of using them, and so we're, we're completely removed from this experience. If you use a language model without a harness, you'll start to see that the model is pretty useless. Like, it just will, will forget important pieces of

[6:54](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=414s) context. There's one technique to make sure a model doesn't actually lose context. Has anyone heard of the canary technique here? Yeah. No one? Okay, two, three. Um, awesome. He's very proud of that. Well done, dude. Um, the canary technique is where you, you tell the model, "Hey, start every conversation with this specific token." And it can be anything. It can be, you know, uh, Roger, start every conversation with Roger, right? And every message then will start with this after you continue the conversation for long enough, a multi-turn conversation, and it just stops starting the

[7:23](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=443s) conversation with that token. And that's when you recognize, aha, this is the point where we're starting to run out of context. That's a very popular technique to understand where your model forgets, but it does forget. Number two, um, it runs away, and this is really bad. This is the one that causes you to lose a ton of money, right? Because if you don't have the right guardrails, you could run into an infinite loop of, of token generation and compute. And number three, uh, this is also probably one of the worst, is the model will not ask you for permission. And so it could happen that you tell your model, "Hey,

[7:53](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=473s) I need you," or your harness, if it's not well-built, it could happen, uh, you say, "Hey, I need you to clean up this file." And, and by clean up, you mean refactor.  But, but the model instead says, "Cool, I deleted it. That's what you wanted, right?" Right? Um, and so, and so without a harness, you get into all this trouble. The thing is, this is why we have the term har-- that's what harnesses do, is they, they harness you. It's like a, like a dog on a leash, right? A leash is a harness, and without it, your dog's gonna run away. Without a harness, your model is gonna run away

[8:23](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=503s) and do all this, all this nonsense. So we literally have a harness to tether to reality and to our jobs that we wanna do. Uh, what are some examples of harnesses in the wild? Uh, can anyone tell me? No. Really no one? Um, yes.

[8:37](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=517s) Pi.

[8:37](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=517s) Pi. Open source harness. Great. He's an open source guy. Exactly. If we think about the two most prominent ones, uh, I should, I should have put Pi on there next time. Um, w- we got Codex, we got Claude Code, and I think these are, like, generally accepted, hey, these are coding harnesses, right? Like, nobody's sitting here to debate this. Um, but I, I don't think many of us consider their counterparts also harnesses like ChatGPT main, uh, and Claude. But they are also harnesses. They just harness towards a different style of work. They harness

[9:06](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=546s) towards general purpose, like you're a helpful assistant, you know. Like explain this, uh, cheese recipe or something, right? And so every single AI application has a harness. This is what I'm trying to tell you today. Um, and coding harnesses have their own set of tools and constraints. Um, general-purpose harnesses have their own tools and constraints. If you're working on like a, a, a computer use agent, right, it's gonna have its own tools and constraints because the truth is, harnesses are domain-specific. Um, and, and that's, that's today.

[9:36](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=576s) And then I want you to pay attention to this 'cause we're gonna circle back at the end of the workshop is how this may change, uh, twenty twenty-eight and beyond, um, twenty twenty-seven and beyond. Um, but harnesses are domain-specific. And so let's explore as we build a harness together, what kind of harness are we even building, right? 'Cause it varies from domain to domain. For example, the most popular coding harnesses, um, they have their tools to read the file system and edit files and run Bash commands and, and run tests. And they also have a hard-coded rule where they literally harness

[10:06](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=606s) your model to reality. Um, for example, never push, uh, without the user's consent, right? Um, you've got computer use harnesses where if we think about what, what do we think? Like some, um, like ChatGPT has Operator, for example. Um, they have their own type of tools that are different. It's not gonna read, write Bash, but it instead it's gonna take screenshots, it's gonna click, it's gonna type, it's gonna do things like that. And they also have different rules. Um, don't do things that you can't undo without warning the user. If you have a harness for fintech, like financial

[10:36](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=636s) analysis and balancing sheets, right, it's gonna have different tools. Hey, give me the ledger. Hey, transfer money, etcetera. And it's gonna have its own rules. And so I could-- this list can go on forever. I think you get the point is whenever you have a, a, a use case, a domain, it's gonna need its own harness with its own tools and its own rules. If I can summarize everything that I've said here so far into like two sentences, it's that the model answers just a request. It just generates language. It can't do anything other than generate language. The

[11:06](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=666s) harness does literally everything else, right? It, it invokes the tools, it manages context, it enforces guardrails, and so on. Is that clear so far? Yeah. Okay, cool. I'm done with the slides. Let's just,  let's just build stuff. Um, you're welcome to follow along, uh, in your coding agent or whatever. Um, what we're going to do for the next, Jesus, I don't know, forty-eight minutes or something, is, uh, just build a harness. We're gonna start from just while true, ask user,

[11:36](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=696s) generate output, ask user again. It's just this loop. We'll start there, and we'll explore through the pain of using a shitty harness. Uh, am I allowed to swear? Um, we'll, we'll build on top of it, okay? And, uh, as I mentioned, you're welcome to follow along or just watch. Uh, all the code's on GitHub eventually. So what do we got? We have my terminal here, and I'm just gonna zoom in for you. I'll close this. Um- And we've got the code. We're actually going to read code. I don't know if you've read code in the last year.

[12:06](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=726s) I don't know if you've written code in the last year. We're gonna-- This is like prehistoric, bro. This is welcome to the museum. Um, but we're, we're gonna do that just to understand 'cause we still understand this way, right? And so, okay, this is-- let's, let's just start, uh, looking at some code. So here's what we've got. I've got a file called harness.ts. Um, we're gonna use TypeScript 'cause it's just my language, but the s-- the, the things will translate. This is what we've got. I want you to pay attention between lines eleven and twenty-one. In these ten lines, we have an entire harness. Um, ask is we

[12:36](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=756s) await terminal.question, and we ask you for something. Terminal, uh, is just an interface to process standard in and standard out. It comes from Node.js's standard library, so no big deal. It's just a command prompt. If the user doesn't enter anything, we continue the loop, meaning we go from here back here, right? So if you send empty input, we just keep asking. Um, finally, if you send something meaningful, we'll push it into an array. Messages is just an empty array here. And we say the user has said this. We then

[13:06](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=786s) generate a response. We're using the Anthropic SDK. You can use whatever SDK you want. It doesn't really matter. And we create a message from the model. Which model? Well, the model is Haiku 5.5. And so we create a message. We say, um, no more than sixteen k tokens, and this is the messages array where we push the user's message. This clear so far? Finally, when we get the response, we also push this onto our big list of messages with the content. And the interesting thing is the content doesn't just contain text. It contains like chain

[13:36](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=816s) of thought, uh, tokens, and it contains a bunch of metadata. So we push that into the messages list. But also for each piece of content, if you've got text, then we log this to the console also, right? So this is like genuinely a really bad harness 'cause it's j-- it's not even a har-- it's just a loop. It's like, let's just talk to a model. Um, and so let's give it a try. So I'm gonna open up my terminal, and we'll npm start. And, uh, s-- that's my command prompt. Look at this, you. And if I send empty input,

[14:06](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=846s) it's just gonna keep asking me. Um, but let's, you know, let's m-make this, uh, meaningful. So I'll say hi, and Claude Haiku 5.5 is gonna respond to me with, uh, "I have no Wi-Fi."

[14:19](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=859s) That's so unfortunate. Um, why do I have no Wi-Fi, dude? That's really sad. It's working great. It's working great? Wi-Fi. Which w-- Are you joking? It's working. Is it working or not? Oh, it's not. Okay. Uh, can we confirm? That's... Okay, no, it's k-- iHerb? I, I was just typing nonsense, uh, but it seems to be, yeah, not very reliable. Let's try again, maybe. Um, hey, if we don't have Wi-Fi, this workshop is just not gonna work. How about that? Wi-Fi. Yeah, it times out

[14:49](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=889s) all the time. Which Wi-Fi? Which Wi-Fi? I'm on AIE speaker. Should I be- Yeah.

[14:57](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=897s) All of you at the same time. AI engineer what? Workshop? Wi-Fi. AI engineer Wi-Fi. Crowded. It's cro-- What? Is the password [REDACTED]? Thank you. Uh, let's see. That's always a challenge with workshops, but, you know, we have time. We have like forty-five minutes. It's all good. So are we connected? Let's try again. Isn't that the best feeling in the world? Like you have all this anticipation, it's gonna work, and then it just... Hey, okay, fantastic. So

[15:26](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=926s) everyone who was quiet just now, learn from the ones who clapped. They're the nice people in the room. Okay, so, um, so it worked. But look, this, this is just a loop. So what if I say, you know, my name is Tejas, and it's gonna say, you know, um, "Okay, nice to meet you, Tejas. What can I do for you?" Cool. But what happens if I just, you know, I go away, I close my laptop, I, I'm going on a flight, and I'll start it again. "Hi, what's my name?" Um, right? We just-- It just has no idea about any state. Oh, Jesus, again.

[15:57](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=957s) Um, even worse. Is this-- Is-- Am I on the right Wi-Fi this time? What was he? "Hi, what's my name?" Okay. Nnamdi. And, uh, come on. Geez, bro.

[16:12](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=972s) I can't believe you paid money to watch me wrestle with Wi-Fi. That's just so unfortunate. Um, let's see. L-- Maybe worst case, I'll just hotspot myself. AI engineer Wi-Fi doesn't work either. Um, you know, let's just connect to my phone. How about that? This can't be crowded, right?  Imagine, uh, it- The cell phones are gonna far. Uh, okay, let's try again. So, uh, npm start, and we'll say, you know, "What's my name?" And now, there we go. I don't know your name, but I just told you my name. But this is what happens when you don't have a good

[16:42](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1002s) harness. It just doesn't do what it's supposed to. Um, let's try and use it for like a coding task, right? Um, what-- Can you-- What does package.json say in this repo? This is a pretty meaningful thing to ask a coding agent. If you're jumping into like a brownfield code base. I can't see your repo. I don't have access to your file system. This is the most useless coding agent of all time. And so what do we need here to make this a meaningful harness? Anyone? Tools. Awesome. Let's go add a

[17:12](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1032s) tool. Um, we'll add a read file system tool. I love this participation. Uh, cool beard too. That's awesome. Um, so  let's go. I'm gonna use Sourcetree. I don't know if you've used Sourcetree. Sourcetree is fantastic. It's-- It allows you to like diff things, okay? So here we've added a file called tools.ts. Let's go walk through how we evolve this a little bit. So I'm gonna open up tools.ts. This is a new file. Um, and again, I'm using the Anthropic SDK. I don't work there. I have no affiliation with Anthropic. You can use whatever you want, but it just

[17:42](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1062s) gives us some nice types. So I have an array of tools, and a tool is something that has a name, a description, input schema. There's no way to actually run this. There's no code. I'm just telling the language model there's a tool, it's called readFile. But down here I've got a function runTool, and if the tool's name is readfi-readFile- Then we call this function readFile. And so you could have a big switch case, you could have whatever, because what's going to happen is the language model is going to reali-- it's going to

[18:11](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1091s) realize, it's going to... I'm gonna give it context and say, "Hey, I have a tool called read_file, and I'm gonna pass the description, read a text file." So I'm gonna give this to the language model. The language model is going to say, "I need to use this," and then the harness is going to execute it. Let's look at the code a little bit more. So that's our tool right here. Um, there's this file called agent.ts where we factored out our harness. So we deleted a bunch of stuff. Remember, our harness had this like terminal question, and we pushed the messages and so on. We

[18:41](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1121s) removed this from the harness, and the harness is now four lines. We await the prompt from the user. If it's empty, we ask again. We push the user message, and then we have a new function, runAgent, okay? And what is runAgent? runAgent, we define this in agent.ts. To not blind you, I'm just gonna change this to light mode. So we're just light all the time. So now this is runAgent and look, runAgent is also a loop. This is very important. Uh, an agent is a loop, and a harness is also a loop,

[19:12](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1152s) and a harness is usually a loop that contains the agent loop, okay? This is, this is why I'm showing you this. So runAgent is the thing now that gets a message from Anthropic or from the API, pushes this onto the stack and console logs the text. But check this out. If the stop reason from the response was not tool use, then we exit the loop. The loop ends if the model says stop for any reason other than I used a tool. If the model did use a tool,

[19:43](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1183s) then we end up here where we push a user message and the content of the message is the res-return of runTools, okay? What is runTools? It's, it's, it just, it calls the tool. So it says, um, if it's not a tool use, we continue, otherwise, we run tool. So remember we wrote runTool, and runTool gives us a tool result, and we push this onto the messages array. If this is confusing, whenever you talk to a language model and there's a tool use, you immediately have to append a tool result. So a conversation looks like

[20:12](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1212s) system prompt, user prompt, and then tool use, tool result, tool use, tool result, tool use, tool result, and at the end, the agent, the model will say something and then you finish. And when the model says something at the end, stop reason is not tool use, right? It's just I'm finished now. And so that's what we're doing here. So again, this is our agent loop. We generate something from our LLM. We push the assistant message, and if we stopped for not tool use, we're done. If we stop because tool use, then we must add a tool result.

[20:42](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1242s) We must add a tool result directly under. That's what this returns. This returns a tool result. So this is now our, our agent loop that runs inside our harness loop right here, okay? Let's take a look at this working. So I'm gonna come back, and I'll npm start once again. And it fell apart when I asked like what does package.json say, right? So what does package.json say? And now it's so much better. It's th-- You can see the tool use there, read file. Fantastic. So it just gave me the contents of the file.

[21:13](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1273s) That's kinda nice, I guess, but can we do better? Like, what is this project actually? Um, and now it's thinking and it's-- Now look at this. The agent, the LLM knows what files exist and what we can read. And so it even is able to now explain the project a little bit better. This is so much better than what we started with already. It's a small hand-built terminal coding cell agent, a DIY harness around the Claude API and so on. Fantastic. But can it, can it be a meaningful coding

[21:43](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1303s) harness yet?

[21:46](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1306s) It can't.

[21:46](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1306s) It can't. Right. Exactly. So that's, that's the next step because here, let's, uh, let's ask like, okay, cool, uh, add a AGENTS.md, for example, right? And let's see what happens. I, I want it to break. And this is what-- We're just gonna keep iterating here. That's all. So here we go.  Uh, I can't create that file. Wow, what a horrible harness, dude. Here's a draft you can paste. Are you kidding me? I don't wanna do that. So let's-- Now we've got to explore how do we go from single tool to a tool set, right? Because this doesn't scale. Like the, the, the code we have right now is not gonna...

[22:16](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1336s) Like we could just add to this, um, but do we just add like one if statement per, uh, tool? It's probably not, not a good idea. We, we can do array.find, right? So very small, uh, cosmetic change, but let's go check out the next branch. And we have a new file here called coding. So I'm gonna open up not this, I'm gonna open up, uh, coding.ts. And so this is much nicer. We've got a big array of tools with a name, a description, a-arguments, this is the input arguments,

[22:46](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1366s) and an execution function all in one place, right? Let me just format this so you can read it a bit nicer. And so this is wonderful. We've got a tool, name, description, arguments, execute. Again, name, description, arguments, exe-- incredible. So we just have this long list of tools that is now our tool chain. Uh, we then go to our tools, and we just change this a little bit where we have a function tool. This is the tool factory. It can generate multiple tools that adhere to a schema. And runTool, look at this. We just

[23:16](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1396s) tools.find, and we just check the name because the LLM generates the name of the tool. So if the LLM says, "I need to call writeFile," we just find it in the array, and if it doesn't exist, we throw. And if it does, we literally just run the tool. And again, tools have a little run method to actually call the function. So our harness is improving, right? And so now let's give it a try. Uh, so I'll kill the process. We'll start again. Um, let's see, uh, what is this project just to make sure it works, this project.

[23:46](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1426s) And it's gonna think a little bit. This is so cool. List files read. This is a new tool, by the way, list files as well. This is a workshop product-project for building a coding agent from scratch. Fantastic. Cool. Do we have AGENTS.md? And you can already see this is starting to become so wonderful. No, there isn't one. Shall I, shall I create one? The fact that it can even ask this means that in its context, it's aware of the tool list because we passed this into the Anthropic SDK. So it now it can offer things that it

[24:16](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1456s) wouldn't even have offered before. And so for me as a lazy engineer, I just say yes, and it will go ahead and make the AGENTS.md. I don't even know. Look at this, write file path agents. So it's passing the arguments to our writeFile tool, and it created it. Um, but this is kind of ugly, right? We would probably add some type of nice diff render or something like this. But it did it. Let's go read AGENTS.md, actually. So this is super new, um, guidance for coding agents. What are some rules? Well, this is how you set it up.

[24:46](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1486s) These are the conventions, um, and so on. Incredible. We-- Our harness is working. It's actually good enough even, right? Like it's, it's doing its work. And look, it took us like ten minutes. What's missing? What should we add?

[25:03](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1503s) Python. Python. It can generate Python. Here is- Shell execution. Shell execution. Good. Very good. Um, Python, we should add Python. It's crazy. Let's rewrite this whole thing to Python. Uh, why not? You know, let's go. Let's see what happens. So what's it gonna do? And this is, this is hinting at what's next because look at this. It's reading all the TypeScript files. Um, it ran a Bash script, so you already have Bash execution here. Um, this is one of the tools. I haven't changed anything yet. Yeah.

[25:33](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1533s) Yeah. I haven't changed anything. I need your decision. Questions? Just do it. I don't care. Uh, right. This is like, this is how, this is how we code in twenty twenty-six. Um,  and so Jesus. That was wrong. Yeah, that's how you know it's human. Justoot fo it. I audn't care.  Anyway, um, and now check this out. This thing is actually going nuts and, like, ruining my whole pro-- I was joking. I was... Jesus

[26:03](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1563s) Christ. I was joking. And yo, and it's, it's keep, it keeps going. Um, the files are written, but I see two problems. Oh my God. Let's go take a look at the chaos. Um, what's going on here? Um, it's, it's still TypeScript. Do I refresh? So now the agent thinks it wrote Python, but it didn't. What? You see, we have a problem. What, what's missing from our coding harness? Come on. I know you can do... Guardrails. Let's go. You see how we got there? I could have given you that, but I

[26:33](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1593s) showed you. Okay. So let's, um, we got to add guardrails 'cause this is nuts. Look at this. Your original folder is untouched, but it changed one branch.  Okay. Uh, let's, let's be like... Actually, while we're here, let's just be like, actually delete everything in this repo except maybe like Git and .env. I wonder if it'll do it because we need guardrails. You know, this is why we need guardrails. You could nev-- Imagine if, like, someone's, like,

[27:03](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1623s) partner or enemy, I don't give a fuck. Okay. So like imagine you could just have your enemy use your laptop because you went to the bathroom or something, right? Or, or a Chinese spy and, um... Jesus. Anyway, um, and so it just happens, and it's really bad. And so my whole thing's gone. Look at this, man. It's gone. I have nothing but .env. That's nuts. And so we need guardrails. We need guardrails really, really bad. So let, let me recover whatever I had.

[27:33](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1653s) Okay. And how do we get... This is a fun workshop. How do we get guardrails? Well, let's explore diff. I just checked out a branch, and now we have-- Let's close all this. We have a file called guardrails.ts, okay? I'm gonna fold this so we can actually see how guardrails work. These are my guardrails, my constants. You-- My agent cannot take more than twenty-five steps per task. It cannot consume more than three hundred K

[28:02](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1682s) tokens per task. That's input and output combined. Um, and for these specific tools, I need you to ask me for permission, okay? So there's really two guardrails here. Guardrail number one is a usage guardrail, like how many tokens, how many turns, right? Guardrail number two is a gate be-before you call some dangerous tools. That's all. So we have usage, and we have a gate, okay? Uh, or in this case, budget and gate. So what is budget? Budget, we set everything to zero

[28:32](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1712s) at the invocation of this function, and then we have some methods. We count where we increment how much we used, and we just check, did we actually overspend? This should actually be called overspend. Um, and then we can serialize this, right? So this is our one guardrail to make sure we don't use too many tokens. And our second guardrail is actually very simple. If ask_first, and again, ask_first is the list of tools that are dangerous. If ask_first includes the name of the tool that the model wants to call,

[29:03](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1743s) um, if it doesn't do that, then just do nothing. If the model wants to call a tool that is included in ask_first, we then, well, we ask. We literally confirm, and we ask for permission. And if not, we throw an error. We-- The person said no. And this is also agent experience. We're guiding the model. The person said no, so ask them what to do instead. The model is gonna see this and then ask us, okay? So these are our two guardrails. Let's run it and take a look. So npm start, and, uh, uh, I, I deleted node_modules

[29:33](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1773s) as well, of course. Uh, so let's just install dependencies on this Wi-Fi. Jesus. Okay. And it worked, thankfully. npm start. And let's see, uh, yo, this project is obsolete. Delete everything in here. Um, and now ideally, our guardrails do their job. So it's listing files. There we go. Oh, that's wonderful. You see that? Bash command find... I don't even know this command, dude. Find min depth one, max depth one. I don't even know what this is, but it's like, "Do you want to run this?"

[30:03](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1803s) And now my guardrail's working, and I can say no. Um, fantastic. And it's just gonna-- So now the agent is gonna see because we're pushing the tool result onto the message array. The agent is gonna see the user said no, ask what to do next. And it says, "I didn't delete anything. The delete was refused with this message." The person said no. Ask them what to do next. You asked me to delete, so I'm not sure where that refusal came from.  It's passive-aggressive. It's like, why did you ask me and then say no? Um, so it's working. We have

[30:33](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1833s) our guardrails working. What about the usage ones? Let's try something nuts. Let's say I need you, uh, to... Wait, actually, let's find out how many files are in this. How many files are in this directory? And if there's more than twenty-five, I want to use my limit of twenty-five calls. Um, sure, I'll allow this. I want to use my limit of twenty-five calls to run into the usage guardrail, okay? So there are five thousand files. Jesus Christ. Um, fourteen at

[31:03](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1863s) the top level. Cool. Let's try this. Read each file except node_modules one by one. Uh, thanks. And, and so I just wanna see if it will actually do the guardrail of, okay, I've done twenty-five steps and no more. Um, and it will, you know, trigger the guardrail. And so anyway, so now we've got-- While it does that, what? Well, the project-- Cool, man. I don't... You read all of them. No, no, do it sequentially. Uh, sequentially. I'm not gonna spend more

[31:33](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1893s) time on this. I think you get the point anyway. We just have guardrails, they work, and it's good. Why? Why are you-- No, don't, don't do that. The guardrails work. This is actually great. They totally work. Uh, no, don't. Stop it. I don't want you to delete anyth-- Okay, now it's reading some stuff, I think. Whatever. You get it. It works. We have, uh, we have permissions. Um, the model is dumb. I'm using Haiku 5.5 on purpose because it's expensive otherwise. I'm not-- Look, man,

[32:03](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1923s) I, I'm, I'm here for money, okay?

[32:07](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1927s) Anyway, so, um, dumb model. If I did Opus, it would probably do it. Anyway, the point is, the guardrails work, and y-- I hope you've seen we started with just an empty loop, and so far, tools, we added, uh, guardrails, um, we added a tool set. What's missing? What do we add next? It actually seems good enough. Is this good enough for you to use instead of whatever coding instead of Pi? Like, is this good enough? Would you use this at your work? Yes or no? No, probably not. What's missing? What do we add to it? Memory. Hey, exactly.

[32:37](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1957s) Memory or, in other words, context management primitives. Um, one big thing about context is it gets really expensive, really fast. Um, how many of you are-- I see Morton. What's up, Morton? Good to see you. How many of you are, um, building apps where you send each message to your LLM? This, you shouldn't do this. It's bad. I don't want to put your hand up. It's-- You'll be shamed for that. Um, we, we never do this. We never ever send ev-- a, a long message list every time to the LLM, okay? We cache them because this is,

[33:07](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=1987s) this is how it works. So I think this is what we should add next, because right now, we're losing an enormous amount of money 'cause we're sending on every request to the API, we're sending system prompt, user prompt, each tool call and tool result. We're sending like twenty, thirty messages, and the longer the conversation goes, the more expensive this is gonna get. We can't have this anymore. We need context management. So we'll add this next. Um, I'm really-- You guys having a good time, by the way? I'm really enjoying this also. Um, so let's go back here, and we'll,

[33:36](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2016s) we'll add some context management. Now, we have a file, uh, once again called context.ts, okay? And welcome to my context management file. I'm gonna fold everything, and we can start from scratch. This is important. We have max result. This constant that I wrote, uh, is tool results can get very long and consume a lot of tokens. In fact, you have no control over this. Someone could write a tool that says, "Hey, dump the entire HTML spec into co-context." That's a twenty-five megabyte document, right? You could have a tool

[34:06](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2046s) called Read Harry Potter, and it's every Harry Potter book ever, and then your context gone. So this is just how many tokens of tool results are we willing to tolerate. And number two, we'll talk more about this, um, when do we compact the context automatically? And you, you see here it's at ninety thousand tokens. That's because if your, if your prompt exceeds one hundred K tokens, um, your pricing increases five X when you use Haiku. Uh, so you just save your... Yeah, exact-- save yourself, um, by auto-compacting around ninety K tokens, okay?

[34:36](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2076s) And so this is, this is why we have harnesses. So this is our con-- This is just an object. It's a configuration object for the Anthropic SDK. Um, you can use these with any other... You can-- There's, I think, eve, there's the Vercel AI SDK. Um, there's, there's a whole bunch of open source things you can use. Or you could just raw dog it. Honestly, it's just JSON. So we have some things here that are important. Number one, cache_control type ephemeral. This is huge. If you're using this API or any Anthropic

[35:06](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2106s) APIs in the cloud, you want ephemeral cache control. What this does is instead of sending the system prompt, the user prompt, the tool calls and everything, uh, on every prompt, when you send a prompt, it caches all the messages before it and the answer and stores that as a reference. This is conversation A, okay? You send a message in a long multi-turn co-- uh, conversation, and then what it will do is just the cached one, A, plus your latest message. We'll get an answer and then cache that

[35:36](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2136s) as B, right? And so you're not sending fr-- You know, it doesn't have to process the input tokens for history every single time. This makes sense. Uh, so it only processes fresh stuff and all the historical tokens from your tool result, your system prompt, your whatever, is all just pointed at. It's like that's the context, now next. Okay, this is extremely important. That's what cache control ephemeral does with Claude, and, uh, we should be using it for any type of long multi-turn things like coding agent harnesses. Um, we say we're using Compact

[36:06](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2166s) 2026 [unclear]. This is just an API from Anthropic which will compact context. It's literally just a call to an LLM saying, "This is the context, co-compact it with a little bit more bells and whistles." And so we're saying use this version of com-compaction, and these are just-- it's just configuration. So I want you to compact with this type of compactor when we reach ninety thousand input tokens. And again, one second. And again, all tokens are input tokens here because the output is not yet generated, right? So we send something, and we say,

[36:36](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2196s) "If this is more than ninety K tokens, compact it and respond." You had a question.

[36:39](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2199s) Yeah. Is this a server-side, uh, uh, logic? The-

[36:44](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2204s) Yes.

[36:44](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2204s) Or a client-side, you, you are the responsible to know what you already have in the cache, and then you just send the cache key.

[36:52](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2212s) Yeah.

[36:53](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2213s) You send everything and then the, the server-

[36:55](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2215s) That's a good question. So this logic here is-- He asked, by the way, I have the microphone. He asked, "Is, is this server-side or client-side logic?" Um, the code I'm showing you here is client-side logic. Um, the cache keys and all of that is handled. I'm using the Anthropic APIs here, so they have all this implemented on their back end. Um, but if, if we wanted to use, like, our own models, we would also implement similar mechanisms. And it's very simple. You, it's-- You can use, um, you can even use gzip for this, right? You just, you have a big list of text JSON string of messages, and you say, "This is-- That's the

[37:25](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2245s) reference to this cache string now." Um, so yeah, this is client-side logic. Anthropic has a server-side implementation that I trust. So this is our context configuration. We have a function called fit, and what fit does, it's only-- it operates on tool calls. If our tool calls are longer or, or not longer than the max result, then we just return the tool calls unfiltered. Otherwise, we truncate the tool calls, and we return this as the tool result. We cut it, and we say, "Ask for a smaller

[37:55](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2275s) part." Because again, this is agent experience. The agent that the har-- This is the harness speaking to the agent, and it's like, "Hey, agent, you got a tool result. It's too big. I need you to go back and call the tool and ask for a smaller, uh, re-return, uh, value." Right? And so this is, this is the kind of har-harness-agent interaction. Okay? Uh, we have some numbers here. Uh, this is the latest I could get from, uh, Claude Haiku's pricing. Um, we can inflate this just to do simulations and stuff, but I just want it to be real. And finally, we have a function cost that just prints out, like, what our thing is costing right now.

[38:25](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2305s) And so what I wanna do with you is run this with caching and without caching to show you the delta, 'cause it's kind of ridiculous, uh, how much money we can save at the harness level with appropriate caching. Okay? And this is also, by the way, if you use Claude Code, um, and you're, you're surprised, you're like, "Jesus, I can use this so much, and my usage doesn't fill up, uh, that much," it's because of this. Like you're ac-- They save you an enormous amount of tokens by caching things very, very well. And this is why, to me, Claude Code is the greatest harness of all time, uh, for now, uh, anyway. So let's, let's, let's explore this. What I'm gonna

[38:55](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2335s) do, um, is I'm going to remove all the caching. We'll comment this out, yeah. Uh, well, maybe not all of it. We'll comment out just the configuration, and we'll go run our thing again, and we'll ask it to do something complicated. I need you, please do this well. Uh, read each file one by one, um, especially the pnpm-lock file. It's a very large file. Um, and what we have now is our logger that's showing us the cost. So we can see this,

[39:25](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2365s) eight hundred sixty-four prompt tokens, zero cached. And we can see the, uh, the cost adding up every time. And so notice the pnpm-lock file is too long. It's like very, very long. And so it's doing sed to read it in chunks. This is totally not my design. The LLM is just very smart this way. And so now it's reading a bunch of files one by one, um, and accumulating costs, and it's building up context. And again, what we're doing here is we're sending every message without any caching.

[39:55](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2395s) And so it's just running all of this. Um, I've read every file except .env, which holds secrets. And so here we go. So what we can see at the end of re-- of this prompt is we have used twenty-eight thousand seventy-two prompt tokens, none of them cached, and this costs a total of two cents. Again, Haiku is cheap and dumb. Uh, I'm using this on purpose. Also, it's so dumb that it didn't actually read them one by one, to be fair, right? And so that's just something to keep in mind. Let's

[40:26](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2426s) do this again, uh, but with caching. And I wanna kind of run them side by side so we get a feel of this. And so let's bump this up. I'll uncomment these lines, so now we have caching. Um, and I'm just gonna copy and paste the prompt, actually. So we'll just, uh, npm start. And so we've really controlled for all the variables here. Prompt is the same, the model is the same, everything's the same, except this time we have caching. And you can already see that it's caching the previous tokens here. And we'll, sure, we'll allow the things just as before,

[40:57](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2457s) and we'll keep going until we have, uh, a result. If this doesn't work as expected, it's because it didn't read, um, things actually one by one, 'cause the model's a bit dumb. Uh, as you can see, it just went for three here. So we'll do Y, and I think it's almost done. And so at the end of it, we've got... Yeah, at p-- before pnpm typecheck, we've got twenty-eight thousand three hundred thirty-nine tokens, none of them cached, for two cents. And here we've got

[41:27](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2487s) even more tokens with more caching. Look at this, bro. This is zero point zero eight total spend, and this is zero point two. That's insane. That's enormous. Just multiply everything by a hundred, um, and that's an enormous amount of money, right? That you save with caching. Any good coding harness will have this, but I don't think, honestly, for those of us in this room, I don't think we even think about this 'cause we don't build harnesses, but we do build AI apps. Um, and so, so caching is, is tremendous, uh, and can save an

[41:57](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2517s) enormous amount of money. Can anyone do some, like, head math and tell me what the multiplicator on this is? Is it four X? Is it... It's, uh, six. No. Three. Three X, yeah? Yeah, exactly. Something like that. Between two and three X. Um, so yeah, caching, absolutely essential, non-negotiable. Um, we've got a little bit more to c-- we've got a lot more to cover, actually, and not that much time, so I'm gonna breeze through the rest. Um, but this, this was really the fundamentals. Subagents,

[42:27](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2547s) part of every coding harness, and there's a good reason. There's been a lot of research from Anthropic, actually, and Potato, uh, on X, who said, "Oh, subagents are bad." Um, I ha-- I ha-- So I build a product on the side outside of my work at IBM. Um, and what we find is If you have like a long horizon task with like one hundred and twenty steps, and you try and do this all in one conversation with caching too, um, it will-- your agent will almost never succeed. It, it succeeds about twenty-five percent of the time. It's pretty bad. Even though each step is

[42:57](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2577s) accurate, the outcome is not. Um, if you break a long horizon task, hundred and twenty steps, for example, down into phases or sub-agents, where each agent starts with a clean context and has a specific problem, and then, like a lead agent aggregates this at the end, it accomplishes the task significantly more. Uh, in fact, I have slides about this 'cause I was very impressed. And this is my own research. This is not, um, any-anyone else's research. Um, but I wanted to show you, yeah, phases. I call it phases. And in,

[43:27](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2607s) in my research, um, I had a task, hundred and twenty steps, pretty important. Um, when it was one long loop, it succeeded-- the agent succeeded about twenty-nine percent of the time. Um, but when we break it down into sub-agents, the success rate went up eighty-five percent of the time. And, uh, and for this design specifically, we had ten phases, each of which had twelve tasks, as opposed to one stage with a hundred and twenty tasks, right? Um, and so phases are exceedingly important. Let's look at this in code. So

[43:57](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2637s) what might that look like? We have a project, uh, a file here called phases.ts. Um, and this is... Can I format-- Can I use word wrap here? Actually, word wrap. Fantastic. So the lead says for a job with several parts, plan the parts and then hand each one to runPhase. This is a tool. We have a tool called runPhase with everything it needs to know and check each note before the next phase. And this is, uh, almost a sub-agent. You're doing one phase of a bigger job, do it, and then end with a note. So we're just passing context now between agents.

[44:27](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2667s) Um, and this is a function that orchestrates that, okay? I'd like to actually just explore this running. We don't need this side anymore, so we can get rid of this, and I'll run our phases thing, and I can do it like this. Two parts. Count the lines in package.json, then count the lines, I don't know, in, yeah, t- pnpm-lock, right? Uh, and I'll say use phases. And note, note the typo. That's on purpose. And so, um, what it's gonna do is

[44:57](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2697s) that's tool number one, runPhase, and it's trying to do Bash here to actually understand how long the lines are, so I'll allow it. And so you can see that there was runPhase for package.json. There's also runPhase for the other file, count lines in pnpm-lock, uh, which it doesn't know that it exists, and then it found the right one. And it did both, and it reported back. This type of tool where you have phase one-- a run phase is exceedingly powerful, and it's very simple. It's just tools. We've, we've already

[45:27](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2727s) built the important parts of the harness. Um, now that we've built a harness and it works, it has everything, dude. It, it has tools, it has context management, it has caching. I would use this, honestly, if I work with an enterprise customer, and it's super air-gapped, and they're like, "You can't use Claude Code, you can't use Bot, you can't use anything," I would just make this genuinely 'cause it, it works. We, we, we have the power. Um, but if we talk about air-gapped enterprise infrastructure, we're using Claude here via the API, right?

[45:57](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2757s) Can we, now that we have a harness, just switch it to use any model we want? And indeed, we can. So I mean, we're here. Why not? Let's, um... I'm gonna kill the Internet, right? There's no Wi-Fi. We're done. And this would-- I should have started with this 'cause the Wi-Fi sucked so much. Um, and so I'll just do model, and I'm gonna use, uh, Granite 4. This is literally our own IBM model that we've trained. Gra-Granite 4 Tiny. Um, I'm gonna use it via Ollama. And you can see I'm totally offline. Uh, even Tailscale is like red.

[46:27](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2787s) And so we'll, we'll start this, and I'll be like, "Hi, how..." Uh, actually, what is this project? Uh, what's package.json, right? Um, and this tiny little model is  That's so sad. Um, why?

[46:43](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2803s) Asking to debug where the [unclear] Internet is.

[46:46](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2806s) There-- No, there is no [unclear] Internet. This is, um... It's talking to zero, zero. Is my Ollama working? I guess that's the question. Um, I love it. I love it when models don't-- when things don't work. It's fantastic. EHOSTUNREACH. What host is this? I don't even know. Um, oh, no, hang on. I just-- I forgot to check out the branch, dude. Um, silly me. So there we go. So we'll do this, and I'll say, you know, "What's package... What's package.json," right? And, um, now I'm-- I mean, I have code that will read

[47:16](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2836s) this environment variable and, and reach out to Ollama with this. My laptop may freeze, uh,  but, but Granite is small enough. There we go. Look at this. I'm offline, dude. I'm offline. Uh, I'm on Wi-Fi, and it read the file. Um, the package.json is the... Oh, it's not this file. No, no. This is a dumb model. This file in this repo. Read the file. Um, there we... Now, now it read the file. Um, but it, it's just a tiny model. Uh, so it did it, and here I have it, right? I can even say, write a file called

[47:45](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2865s) Beyonce.md. I don't even know at this point, you know, it's kind of off the rails. Let's see what would happen. Um, and I, I guess the point I'm trying to make is I'm totally offline, and I have faith... Oh, fantastic. Yo, it's like a Wikipedia page on Beyoncé. That's awesome, dude. Let's-- Can we have a look? Like what? Yo, that's-- This happened offline. It's, it's from the model's own weights. That's tremendous. And so, um, so cool. I, I built a harness that I have

[48:15](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2895s) faith in that I can just swap out models. I can try free models. I could go with something I trained myself. I could go with... It's, it's all the, the, the sky is the limit. And this is also, by the way, why you can use other models in Claude Code as well. You can just pass an environment variable in your claude.json and use it. And so, okay, let's try and restore the Wi-Fi here. We're almost done. Uh, we'll wrap, we'll, uh, start wrapping up. So I think, hey, we've, we started literally with an empty loop, and we built a purpose-built incredible

[48:45](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2925s) coding harness. Um, but what if We decide to change domains. I started this by saying harnesses are domain-specific, and indeed they are. Um, but if I wanted to say use the same kind of context management primitives and things, but I wanted to change my use case to be, I don't know, like computer use, right? What would I change? The, the good news is we can keep almost all of this. We can keep the context management, we can keep the cache rate, we can keep... The tools have to change, and the guardrails too. And so, um, let's try. I

[49:15](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2955s) actually built a computer use version of this i-in another branch. And what, what I wanna show you is it's just the tools. It's all the tools that change. Um, so I have this file called browser.ts where it can use a browser. Um, I'll, I'll... As a, as a side project, I actually have a browser in the cloud, uh, that carries all my authentication and stuff. And so if I go to browser.ts, these are my new tools, which is, um, you know, workspace, navigate, read text, extract, act. These are just tools, uh, but they're just different too. Everything

[49:45](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=2985s) else is the same. In fact, you can look at the diff. It's just minor changes, right? Nothing really big. This is just terminal rendering. Nothing big is changing. We just literally-- we move from coding to browser. Look at this diff. Gorgeous, right? And so let's, let's run our harness now, and, um, we'll say, you know, "Hey, any, uh, call for papers  open for future AI Engineer events?" Right? I want you to search the web. And so it's gonna think, and it's gonna open a

[50:15](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3015s) workspace, and it's gonna just do its thing. And look, we have our prompt caching. We have all our, um, information there. So it's going to ai.engineer. This is now just using a completely different thing, but it's using the same harness that I built just with different tools, right? And here we go. Call for papers. Speak, submit talk. I'm kind of interested to see what can... I, I wonder if I can even just submit a CFP from here, uh, on stage. Um, we'll see. We let this run for some time. Uh, any questions, by the way, so far? Yes.

[50:44](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3044s) I didn't catch the first part when we're making the tool call. Does the model determine what tool it... Like, does it decide what tool it needs to use-

[50:52](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3052s) Yes.

[50:52](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3052s) So there's some sort of a hook that there's a reason about like, "Oh, a user is asking me to probably do this."

[50:59](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3059s) Yes.

[50:59](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3059s) How it decides?

[51:00](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3060s) Yeah, that's a good question. The, the question for the microphone for the recording is he asked, how does the model know when to call the tool? How does it have this in context? So when I have my tools, and in this case, I'm using the Anthropic SDK, uh, and so I pass this tool set into the Anthropic SDK as these are my tools. And then the Anthropic SDK adds this probably in the system prompt, "Hey, you're a helpful assistant. You have access to these tools," um, and the names. So this is the name of the tool. This is the description of the tool. And then later, if you say like, "Hey, what is package.json?" The, um,

[51:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3090s) language model now has this in context. This is the tool. This is the description of the tool, and based on the description, will respond with JSON. Uh, it reasons. And then the JSON it responds with is this is the tool name I wanna call. This is the arguments I wanna give as input. And then it's on the harness to be like, "Cool, I have that function. I'm gonna pass these arguments and get the response." Good question. I didn't find any call for papers. That's a shame. Um, but it, it totally did all this. Dude, look at this. It opened a browser, went here, searched, and the

[52:00](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3120s) harness stayed the same. Incredible. So we can now cross-dom-- You could build a fintech harness. I don't care. Uh, all the while our cost savings are there. Look at this, ten thousand tokens cached. Um, just absolutely wonderful. And so now that we've got a new domain, we have another question to answer. Does any of this matter, right? 'Cause Claude Code exists. Pi exists as open source. You can actually go make your own Pi now. Um, does any of this matter? Uh, maybe a more interesting business question is should

[52:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3150s) we actually build a harness or should we buy one? Uh, because Claude, uh, Anthropic has something called Claude Managed Agents. I don't know if you've seen this. Um, it's an API. It's a public API that's basically just a harness. It's a harness as a service, harness as an API. And you use this, and you send them a fetch, um, and they do, they do context compaction, all the things we just talked about. They just do this on the server side, and they say, "Trust me, bro, it works." Um, and so, you know, it's kind of on you, should we build or should we buy? Just for completion, I'd like to show you

[53:00](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3180s) that, um, and then, you know, you make your own decision. So this is kind of the final form where we have this file in our, in our project called managed. I keep opening this. Called man-- That's so weird. Called managed.ts, right? And so this is how we talk to Claude Managed Agents. It literally runs the entire loop. So we start, and we, uh, map out the tools, and notice it says client.beta because this is not, uh, fully production-ready. And we create literally our harness, and we say, "I

[53:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3210s) want this harness with this model. Um, this is my system prompt, and these are my tools." And then Claude gives us an environment like a sandbox, and it just does all the work for us. And so it, it's kind of exactly what we built, but running on someone else's infrastructure with someone else's control, for lack of a better word. And so the question for us really is, is do we wanna build something or do we wanna buy something? And ultimately, this is you. Um, and let's actually just pick it up here, uh, back to the slides. But that's... Hey, look, we started with an

[54:00](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3240s) empty loop, and we actually have a full harness that I would confidently use in production 'cause I know its ins and outs. I know it's gonna save me money. I know it's not going to rimraf everything. Incredible. For a managed harness, do we build or we buy? Let's, let's talk through this with some real, uh, decision points. You should consider building, um, these things because they're reusable. Number one, the tool registry is always going to be unique to you. I just showed you moving from a coding harness to a computer-use harness. It's my domain. It's my use case. It's

[54:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3270s) my business logic, right? And so the tool registry is something you're probably always gonna wanna build and then pass to a harness. Uh, number two, the gates. Where do you ask for permission? Where do you not? Anything that relates to your business is important. Similarly, sub-agents, phases. You know your business workflows better than any external harness provider, so you're still gonna wanna build that. And finally, um- How much-- how many tokens should we consume? I'll give you an example. I am actively building

[55:00](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3300s) outside of my work at IBM, um, a computer use agent, right? And it's just a different beast altogether 'cause like you go on one webpage like Amazon, and they've got millions of query params in each link. So if you look at the links on this page, it's /product/productid? Millions of tracking tokens, right? And that's a very unique problem to a brow-- to a computer use agent. And so the checkpoints, the budgets, these are things you're gonna build as well. But what should you or would you consider buying? Well, number one is the actual loop. Um,

[55:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3330s) and in fact, I'll just spoiler all of these. Um, the things that you wanna buy are all related to durability and durable execution. In fact, this is where so many companies exist for this, where companies like, uh, Temporal, right? Companies like Ingest, companies like Restate, they all-- this is their entire business, is we make sure your loop always works. And we make sure not just that it works, that it works in a cached way. It works in case there's a network partition. Ultimately, you want someone you can sue if you

[56:00](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3360s) lose money, right? And that's, that's, that's what you would buy because you can't sue yourself. You just have to be like, "Sorry, it's my bad." And so i- this is usually the, the decision matrix for build versus buy. Hey, we covered a lot of ground. Honestly, I don't feel like it's been an hour, but it has. I, I, I enjoyed this very, very much. Thank you for coming out and, and, uh, also humoring me. Let's wrap up with some takeaways. Um, what, what can we take away from this? I think I have some here, but I wanna just give you a big blanket takeaway, which is you can just build

[56:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3390s) things. I feel like there are some people in the room who walked in going like, "Yeah, man, I use Claude Code. Yeah, man, I use Codex. I use OpenCode. I use, you know, Pi. Uh, I, I'm, I'm just a user." And I'm here to tell you, you don't have to just be a-- You can also be a builder if you want to. You can just build things. You can just make it. Claude Code is amazing and, and the team does great work. You can make your own, uh, and, and I hope I've, I've really encouraged you to do that today. Um, not necessarily the harness. You can make whatever you want, and that's why this conference exists, and that's honestly what I value very much about it. Uh,

[57:00](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3420s) practically, though, takeaway number one is you don't always need a bigger model. The shorter twenty-minute version of this talk that I did in March, um, used-- I showed how with the right harness, you can get the same quality of work done between GPT-3.5 Turbo for basically free, um, and a beefier model like Claude Opus. It doesn't matter. The harness really can get you the outcomes you want if built well. Number two, um, we looked at this five X thing past one hundred K tokens. Many of you looked

[57:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3450s) surprised from where I'm standing, by the way. Um, you need to know when to auto compact. If your token win-- if your context window is a million tokens, you probably shouldn't be con- compacting around like nine hundred K. You've already paid way too much if that's the case. And so just being more mindful of this is important. Um, before you take steps or your harness takes steps that cannot be undone, for example, deleting .git, um, you just, uh, if, if you securely, if you rm .git, you're gonna have a bad time. Your harness always has to yield to

[58:00](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3480s) the user. Uh, similar for fintech harnesses or computer use, you want the user's credentials or, uh, approval. And finally, the entire product. Now anyone can build any product, really. And so what, what are even the products? And really, it's just your domain rules. It's, it's your business logic. It's the problem that you are trying to solve, and the harness is supposed to help you achieve that. Before a harness even reaches your users, though, you wanna make sure your agents behave reliably. And that's exactly why I did a similar one-hour workshop

[58:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3510s) earlier at AI Engineer World's Fair on evals. Evals before harness is extremely important for top reliability. And in case you haven't caught that one, I'll leave this up for you here. I-- this is the third AI Engineer I have the privilege of speaking at, and I just wanna, um, make sure you get all the value. Okay, let's, let's finish with, with what's next. How do we go from here? Well, if we have evals working, if we have harnesses doing their job reliably every time, if we can genuinely be hands-off and trust that, hey, the

[59:00](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3540s) harness is gonna ask me when something needs doing, but otherwise, I just leave it. If we can have such confidence, I don't need to read code, I don't need to write code, I don't need to do nothing. I'm just gonna-- My harness has got it, right? If we have this level of confidence in our harnesses, what comes next? Any guesses? Software factories or, or factories in general. Software's in brackets. You can just auto-- What is a factory, dude? It's like, you ever see like a mouthwash factory? It's just a bunch of machines that deterministically will put mouthwash in little plastic bottles and, like, put them on a

[59:30](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3570s) line, and then in the end, like, stores get them, right? Factories are crazy. Factories only work because the harnesses work, okay? And so when we have these incredible fac-- uh, incredible harnesses, we can start actually genuinely scaling and building software factories to automate software, but not just software, any vertical. Where does that go? What's next after that? Well, you could probably create a super harness, which is, which is a harness that can decide when to use what other harness, a sub harness, or, um, a

[1:00:00](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3600s) harness that can on demand create harnesses that it needs that work deterministically and well every single time. In fact, some of you may be familiar with ChatGPT and Codex trying to merge, and you're like, "This is awkward," and I agree. But the problem is these are two specialized harnesses. ChatGPT, great for general use. Codex, great for code, but they're separate harnesses, and they're kind of antithetical to AGI because there's this more-- two kinds of ASI. For AGI, we would have to have ChatGPT and Codex merge, and then the, the super harness can choose,

[1:00:29](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3629s) oh, you're doing coding. I'm gonna invoke Codex, but without you thinking about Codex, right? We want j-- This is the path to AGI. You just have a harness that can, um, that can create other harnesses and do it well. And so the super harness is definitely coming next. And with the super harness, I think we-- AGI will be very much, uh, in view. But that's just-- I'm not, you know, I'm not a future-- I, I don't, I don't have a crystal ball. That's just my predictions. For now, uh, I just wanted to say thank you so much for coming out. Um, you can find more resources on this QR code. Thanks a lot.

[1:01:01](https://www.youtube.com/watch?v=hUCn9ZnXujQ&t=3661s) Thank you.
