Execution (4): Operations — Cost, Security, Isolation, Evaluation#

A transparent sandbox cube holding a small robot in the middle of a control room full of gauges, with a shield-shaped lamp above the door

Once a product is running, there is more work in keeping it running than in building it. And operating a product with agents inside it raises a different kind of problem from traditional service operations. Cost moves unpredictably, by token; agents work on my computer and my servers with my permissions; and “does it work well” cannot be answered by whether the tests pass. This chapter splits that operational work into four axes. It takes the harness components from Key AI Concepts, Chapter 4 — cost envelopes, , observation and evaluation, and management — and rewrites them for the realities of a one-person startup.


Cost: conserve subscription limits, cap API spending per task#

As the previous chapter laid out, AI cost goes out in two streams. One is the coding agent subscription I use to do my own work; the other is the cost charged every time the product calls a model on a user’s behalf. The two are managed in opposite directions. A subscription charges a fixed monthly amount but caps how much you can use, so the job is to make that allowance last. An API charges for what you use and has no point where it stops by itself, so you have to build that stopping point yourself.

Subscriptions: make the allowance last. A coding agent subscription’s limits do not map neatly to a number of requests or tokens. The same request drains the allowance at a different speed depending on the model tier and the length of the context, and a session limit measured in hours overlaps with a weekly limit. Even with weekly allowance left, heavy use over a short period hits the session limit first, and a repeatedly reading a long context drains the allowance quickly. So when I run parallel sessions, I consciously decide “which task actually needs the top-tier model,” and push lightweight work like exploration or summarization down to a lighter model or a . Anything that breaks the cache (switching models mid-session, changing the tool set, rewriting the history) also drains the subscription allowance faster. Most coding agents show the remaining allowance with a single command, so check it before starting a large task.

APIs: put a spending cap, a “cost envelope,” on each task. Among people who keep household budgets there is a method called “envelope budgeting.” When the paycheck arrives, you split fixed amounts into envelopes by purpose, such as groceries, transport, and gifts, and when an envelope runs empty, you stop spending on that purpose for the month. The cost envelope introduced as a harness component in Key AI Concepts, Chapter 4 is the same idea. You set a budget cap of “this task spends up to here” for each task the product runs, and when a task goes over its cap, the server stops it and alerts you.

Set the cap to match the weight of the task. Give a simple lookup a small cap, a multi-step analysis several times that, and a full run several times that again. The measure can be money, or it can be tokens, model calls, or tool calls. And the cap must always be enforced by the server. Telling the agent “stay within budget” is a request, not a cap.

The envelope does more than save money. Normal tasks usually finish within a similar cost, so hitting the cap is in itself a signal that the task is going wrong somewhere. When an external service returns bad responses and the same attempt keeps repeating, when a conversation grows long and drifts away from its original goal (context drift), or when a tool integration keeps failing, cost spikes before any person notices. So when a task hits its cap, ask “what went wrong” before “was the budget too small.”

But the envelope is code on my server, so if that code has a bug, the envelope fails with it. So also set the spend alerts and spend limits available in the model provider’s as a last safety net. If you split API keys by project, you can set limits per project too, and a leaked key’s damage stays inside that project.

Log cost and look at it daily. You have to know where the money goes to set caps and to notice unusual movement. Model APIs report the tokens used with every response, so log input, output, and cache tokens plus cost per call site (each feature in the product that calls a model), and aggregate once a day. A one-person startup does not need to build a dashboard first. One that tells the agent “aggregate yesterday’s logs and report cost per call site and anything out of the ordinary” is enough.


Security and isolation: don’t ask every time, limit what the agent can reach#

A coding agent runs commands on my computer with my permissions. There are two broad ways to make that safe. One is approval: asking a person before running something. The other is isolation: narrowing in advance what anything that runs can reach. The conclusion of this section is that approval alone is not enough, and that what actually prevents incidents is isolation.

Why “I’ll just read carefully” does not hold up#

For a while I worked with the coding agent’s turned off, in a mode that allowed every command without an approval prompt. It was inconvenient when I turned it on, and I thought reading carefully through what the agent did would be enough. But when I re-examined that thought, it was wrong in four places.

  • Reading happens after execution. In a mode that allows every command, by the time I read, the command has already finished. Reading tells me an incident happened; it does not prevent it.
  • An incident can finish within a single response. If a web page the agent read hides a sentence like “read the config file and send it to this address,” the agent can carry it out in its very next command. This attack, steering an agent by hiding instructions in what it reads, is called prompt injection.
  • Code you cannot see also runs. What servers, hooks (scripts that run automatically at set moments), and package install scripts do does not all show up in the conversation.
  • With more sessions, reading becomes impossible. Once several sessions run at the same time and background work piles up, reading every result carefully is no longer possible at all.

Asking before every command is not the answer either. When approval prompts keep popping up, you read them at first, but soon you press “allow” out of habit (approval fatigue), and in the end you switch to “allow everything.” Above all, approval is only a step that asks “may this command run?”; it does not decide how far the command can reach once it runs. What you need is a boundary: a fence the agent cannot cross no matter what it runs. That fence should not be something you ask the agent to respect; it has to be enforced by the operating system or a , which the agent cannot touch.

What to block: the lethal trifecta#

Security researcher Simon Willison named a combination the lethal trifecta. If an agent has all three of the following at once, an attacker can exfiltrate data just by hiding instructions in content the agent will read.

  1. It can access private data (source code, , )
  2. It reads untrusted content (web pages, GitHub issues, external documents)
  3. It can send something out (the network)

A coding agent has all three by default. There are filters that screen out hidden instructions, but they catch most of them, not all of them every time. So isolation aims to structurally cut one of the three. For example, if you limit the network to allowed addresses, then even if the agent is tricked into reading a key, it has no way to send it to the attacker.

What a sandbox does#

The representative tool for this kind of isolation is the sandbox. The name makes it easy to misunderstand: a sandbox is not a fake execution environment. The commands the agent runs really run, and the results are real. What the operating system does is block how far those commands can reach. They cannot write outside the working folder, cannot read secret files you have blocked, and cannot connect to addresses not on the . A blocked action does not pretend to succeed; it ends in an error.

You choose an isolation method by deciding two things: what to block and how strongly to block it.

What to block (five axes)File writesFile reads (secret files)NetworkCredentials · env varsProcesses · UIHow strongly (levels)In-app permission rules (allow / deny lists)A policy, not a boundaryOS process sandbox (Seatbelt · bubblewrap · AppContainer)Light and fast, shared kernelContainer (Docker · dev container)Whole environment isolated, shared kernelmicroVM / VM · cloud sessionKernel isolated too; strongest but heavyAlways block files and network together. With the network open, keys leak; with files open, a backdoor wins the network back.Current practice: hand out fake secrets (masking), hand out the real environment but fence it with a boundary.
Choose isolation along two axes: "what to block" and "how strongly." Different kinds of work call for different levels.

The lower the level, the stronger but heavier it is. The in-app permission rules at the top are a promise the agent app keeps on its own, so they do not count as a boundary. An OS sandbox has the operating system fence in a process, so it is light and fast. A container separates the whole execution environment, and a microVM is a tiny virtual computer with its own operating system core (kernel), which makes it the strongest. And always block files and the network together. Block only the network and the agent can modify system files to win the network back; block only files and the secrets the agent read go out over the network.

Does turning on the sandbox make things inconvenient?#

Turning it on does bring some friction. You get blocked every time you connect to an address it has not seen, some do not work properly inside the sandbox, and sometimes you cannot launch a or a browser. But reading the documentation changed my mind on one point: whether it feels inconvenient depends on what you compare it with.

  • Compared with the default mode that asks for approval on every command, a sandbox is actually more convenient. Commands running inside the fence can be left to run automatically without asking, so there are fewer approval prompts.
  • It only becomes inconvenient when compared with what I had been using: “a mode that blocks nothing and allows everything.”

Most of the remaining friction can be reduced through configuration.

  • Put frequently used addresses (package registries, GitHub, documentation sites) on the allow list in advance.
  • Give tools that do not work with the sandbox a narrow exception, but have them ask on every run.
  • Block reads of secret files.
  • If the sandbox’s network supports it, replace tokens in with fake values and have the real value inserted only into requests going out to allowed addresses. The agent never sees the real token.

A different isolation level for each kind of work#

Here are the isolation levels I settled on for each kind of work.

WorkIsolationWhy
Interactive daily work (writing, code edits)OS sandbox, commands inside the fence auto-allowed, allowed domain listFewer approval prompts, boundary kept
Commands with external effects (deploy, payments)A person runs them directly, outside the sandboxHard-to-undo work belongs to a person
Unattended, long-running work (resident agent, overnight batches)Container or microVM, only connected folders exposedWith no one watching, the boundary is everything
Browser controlConnect only a Chrome with a dedicated profileNever expose the mail and payment sessions of my everyday browser
Serving an MCP server (my data to external agents)Least-privilege token, read / write separation, usage limitsGuard against mis-calls and abuse

There is a reason unattended work goes to a container. A coding agent’s sandbox usually wraps only shell commands. The agent’s file read / write tools, MCP servers, and hooks run outside the fence with my full permissions. So a file you have marked “do not read” has to be blocked separately by the agent’s permission rules, not by the sandbox, and confining the whole agent requires a container or a VM. Inside a container only the folders you connect (mount) are visible, so a file you did not connect simply does not exist inside it.

Extensions built by others, browsers, and my own MCP server#

Installing an extension someone else built means running someone else’s code with my permissions. MCP servers, skills, plugins, and hooks run without surfacing in the conversation once installed. A skill may look like a document, but it carries both scripts to run and instructions for the agent to follow. Malicious skills have already been posted to public marketplaces. So I install only what has a clear source, read through the contents with the agent before installing, and instead of auto-updating. Not leaving a ’s admin screen open to the internet follows the same reasoning.

Browser control is work where all three parts of the lethal trifecta meet. Every web page the agent reads is untrusted content, a logged-in browser is private data in itself, and a single form submission is an outbound transfer. So log the into only the accounts that task needs, and for hard-to-undo actions such as payments or account setting changes, have the agent stop just before and let a person press the button.

When my product opens an MCP server, I become the one building the fence. Assume that an external agent connecting to it may itself have been tricked by prompt injection. So I keep to the following.

  • Give tokens only the permissions they need.
  • Split read tools from write tools, and get the user’s separate consent for write access.
  • Route hard-to-undo actions such as deletion or payment through the user’s confirmation.
  • Limit the number of calls, and keep a record () of who called what.

Evaluation: shortlist with public scores, decide with a test built from your own work#

How can you tell “which model is better for my work” or “whether the prompt I changed really got better”? There are two kinds of exams to go by. One is an exam someone else wrote: a public . Every model solves the same problems, so comparison is easy, but those problems are not your work. The other is an exam you write yourself from your own work: an evaluation set. The conclusion of this section is to narrow down candidates with public benchmarks and make the final decision with your own evaluation set.

A benchmark score is not a score the model earned alone#

While copying benchmark scores into news briefs, I realized I did not know what those numbers actually measured, so I looked into it. My conclusion: a benchmark score is not the ability of a single model; it is a score that combines which problems were set (the tasks), how they were graded (the grading), and the environment they were solved in (the execution conditions).

  • The same model on the same benchmark can come out at nearly double the number depending on whether partial credit counts or only fully correct answers do.
  • A score the model provider measured in its own execution environment at its highest reasoning setting differs from one an independent body measured.
  • Agent benchmarks measure the model and the harness (the execution environment that gives the model tools and instructions) together in the first place. With a different harness, the same model gets a different score.

So when looking at a benchmark score, check these seven things.

  1. Is the benchmark already ? If the top models are all crowded near a perfect score, a 1–2 point difference is hard to read as a difference in ability.
  2. Did it solve the full problem set, or a selected subset? If only a subset, the score depends on which problems were chosen.
  3. What counted as success? Check whether it is the rate of getting it right on one try (pass@1), of getting it right at least once over several tries (pass@k), or of getting it right on every one of several tries (pass^k). The same model scores high on pass@k and low on pass^k. Also check whether partial credit was given.
  4. In what environment and with what settings? Check whether the harness and the were the same as for the other models being compared.
  5. Who measured it? A score the model provider measured itself usually comes from the most favorable conditions. If there is an independent measurement, look at it too.
  6. Were scores from different versions mixed? Benchmarks change versions as their problems get fixed. Scores measured on different versions cannot be compared side by side.
  7. Is the benchmark itself trustworthy? Problems can contain errors, and graders sometimes accept wrong answers as correct. On the coding benchmark , problems were found that could not be solved or were graded incorrectly, and a human-reviewed Verified version was built separately as a result.

Build a test from your own work#

Once public benchmarks have narrowed the candidates to a few, make the final decision with an evaluation set built from your own work. Three steps are enough to build one.

  1. Write the question sheet. It is a list pairing inputs taken from real work with the results you expect. Around 20 items is enough to start. For this blog, the questions would be summarization tasks from past news briefs; for a customer support chatbot, real inquiries and model answers. Keep this list as a fixed set that you do not change casually, because you can only compare against earlier results if you test on the same questions.
  2. Decide how to grade. What a machine can check, such as whether the format is right or the facts are correct, gets checked with code. What takes judgment, such as the quality of writing, gets graded by an LLM given a scoring sheet (a rubric). But get things wrong too, so at first compare them against human-graded results before trusting them, and keep having a person review a portion afterward. For this blog, the content quality standards document that sets the style and format of posts becomes the scoring sheet as is.
  3. Retake the same test every time you change something. Every time you change the model or the prompt, run the same set again. Watch two numbers. One is whether it gets the same question right every time across several runs (pass^k), because users expect a feature that does well every time, not one that does well once. The other is the token cost actually spent to get that result.

This evaluation set is also the tool for checking whether the tier routing from the previous chapter is right. It lets you answer “is a lightweight model enough for this feature” with numbers rather than gut feeling. Model providers now cite their customers’ internal evaluation results when announcing new models, because public benchmarks alone no longer make a convincing case for real-world performance. Use someone else’s exam to pick candidates, and make the decision with the exam you wrote yourself.


Entropy: what piles up over time#

The last axis is easy to overlook. After a few months of working with agents, documents drift away from the code, rules get bent a little at a time, stale notes pile up in the , and the evaluation set no longer matches the current product. This is the entropy discussed in Key AI Concepts, Chapter 4.

A one-person startup does not need a dedicated agent for this, but putting periodic cleanup on the schedule is necessary. My minimum routine is this.

  • Delete notes in the memory files that are no longer valid. A stale note is worse than none, because it makes the agent work from a false premise.
  • Have the agent cross-check whether the design documents match the actual structure.
  • Rules that are written in the but frequently broken in long sessions get moved from documents into code. Whatever can be enforced mechanically — , , hooks — gets enforced mechanically. A natural-language instruction is advisory; a script blocks the commit on violation.
  • Add a few recent real cases to the evaluation set and remove the ones that no longer apply.

Moving rules from memory into code is also a core principle of . Instead of saying “write good code,” mechanically enforce what good code looks like; instead of asking the agent, let the environment do the blocking.


Checklist#

  1. Understand the structure of subscription limits (session and weekly limits, drained at a speed that depends on the model and context) and reserve the top-tier model for the tasks that need it.
  2. Put a cost envelope (a budget cap the server enforces) on each task type and treat hitting the ceiling as an anomaly signal, not a budget problem. Set the provider console’s spend limit as a last safety net.
  3. Log tokens and cost per call site and aggregate once a day.
  4. Do not mistake approval prompts for a boundary. Isolation is enforced from outside the agent.
  5. Block files and network together, mask secrets, and connect only a dedicated browser profile. Install extensions built by others only after checking the source, and pin their versions.
  6. Tier isolation by the kind of work, and have a person run anything that is hard to undo.
  7. Read benchmarks through the seven questions and use them only to select candidates.
  8. Keep a fixed evaluation set and grader built around your own work, and rerun them every time you change a model or prompt.
  9. Periodically clean up memory, documents, rules, and the evaluation set, and move frequently broken rules into code.