27.5 Where it runs
- Approved by
- Panaversity ·
In everyday life. You must get a heavy box to your sister in another city. You can give it to a courier company. Then you choose what goes in the box before it leaves, and you check what arrives. The company decides everything in between: which truck, which road, and where the box waits for the night. Or you can carry the box yourself. Then every turn on the road is yours, and so are the ticket, the lifting and the long day. If you need to add one thing to the box in the middle of the trip, you can do that only when you carry it. In this section, the courier company is a hosted runtime, and carrying the box yourself is your own runtime. The choices on the road are the steps of your table.
What you will learn. You practice this in Lab 27, Task 2, where you read each row of your table against one hosted session.
- Which two runtimes does the exam name?
- Which decisions can your code hold in each place?
- What can you not take back into code on a hosted runtime?
- What does each place cost, and when is a hosted runtime still the fair choice?
Why it matters. A table that gives a step to code is only a plan. Where the loop runs decides whether your code can hold that step at all.
At work. Wednesday, May 5, 2027. Your table in docs/architecture.md gives code every step of Dave Kowalski's review except finding the policy line and deciding (27.1). Before building, you ask where this table can be built. The morning triage runs at 7:10 on a hosted runtime, inside a budget of $0.50. There the portal's code starts the session and checks the report, and inside the session the model picks every next step. The table asks for more than that. It asks code to take the invoices one at a time, between the model's calls. So you read the three places a worker can run once more, with one new question for each.
Which two runtimes does the exam name?
A harness you run yourself, and a runtime that a platform runs for you. The exam guide asks you to select "the execution environment: a self-hosted harness or a managed, sandboxed agent runtime".1 The harness is the program around the model that runs the loop (23.1). Self-hosted means it runs on a computer you control. Managed means a platform runs it for you, and sandboxed means the worker's tools run in a closed machine.
23.17 gave this choice as a table of three places: a hosted runtime, a hosted loop with your own sandbox, and your own runtime. This book matches the guide's two names to that table with one question: who runs the loop? In the first two places the platform does, so both are the managed runtime. In the third your program does, so it is the self-hosted harness. That table already says who holds the tokens, where the files stay and what you can test.
Which decisions can your code hold in each place?
On a hosted runtime, only the decisions between sessions. On your own runtime, the decisions between the model's calls as well. This is the new row, under 23.17's three columns:
| Hosted runtime | Hosted loop, your own sandbox | Your own runtime | |
|---|---|---|---|
| Which decisions your code can hold | Only what comes between sessions: what starts a run, the check on what came back, what is sent back, and when to stop | The same. Your computer runs the tools, and the platform still picks the next call | With your own loop, every decision. With an agent SDK, what comes between the model's calls, through its limits and its hooks |
In Claude. The first column is Claude Managed Agents, the hosted runtime of Chapter 23. A session can hand work to other agents in several ways. Its documentation says of them: "You decide which of these the agent can use, and the agent determines when to use them."2 You set what is allowed before the session starts. The model decides during it. What your code still holds is 23.16's outer loop, which runs outside the session.
The second column moves the tools and leaves the decisions where they were. In a self-hosted sandbox, "You run the sandbox on your own infrastructure. Claude still runs on Anthropic's side and determines which tool to call next."3 So this place answers a question about where files and tools must run. It does not answer a question about who decides a step. The same page says to choose it "only if tools must run on infrastructure you control."3
The third column has two forms. With your own loop (Chapter 21), every line between two model calls is yours, so your code can hold any step of the table. With the Claude Agent SDK, the SDK runs the loop. You hold what it lets you set around the model's calls: a turn limit, a budget, the tools, and a hook (22.5). One hook that answers deny "blocks the tool call."4 Inside those settings the model still chooses, and it decides the split (27.3).
What can you not take back into code on a hosted runtime?
A step inside a session. Take the review's second step, "take the next invoice". On Monday the model made that step happen, because nothing else could. Inside a hosted session there is no place to put a line of your own code between one model call and the next. Your code can end the session, or check it afterward. The check finds a skipped invoice only afterward (The point).
This is the case 23.17 named as a reason for your own runtime: "You need control between model calls". In this book's lab, the workflow is therefore your own code. It calls the model once for each invoice, and the loop over the invoices is a loop in that code. The orchestrator runs on the Claude Agent SDK, inside limits you set. The hosted worker is read in the lab and not rebuilt.
What does each place cost, and when is a hosted runtime still the fair choice?
Your own runtime costs everything a platform would have run for you. A hosted runtime is still fair when the steps you want in code can come between sessions. The more decisions your code holds, the more of the harness is yours to build, test and keep running. That means the sandbox, each person's tokens, the limits and the logs (22.9). Section 23.17 says most workers you sell will run on a hosted platform, and this row does not change that. The Claude Agent SDK's own hosting page gives the same advice: "If you don't need to run the agent loop itself on your own infrastructure, consider Managed Agents instead."5
A hosted runtime can also hold a workflow, if you move the fixed steps out of the session. When the steps are fixed, "your product can run them in order". It uses one session for a step that needs judgment, and tested code for a step that does not (23.18 in detail). Each session is then one step of the table, and your product holds the order. The price is one session for each such step, each with its own start and its own budget.
The operating rule: choose where the loop runs by the steps your table gives to code. A step between sessions fits any runtime. A step between model calls needs your own.
Do this now. Ask your coding agent to read your project against the new row. Copy this line:
List every place in this project where code starts a model call or a session. For each one, name which of the three places it runs in, and say which decisions my code holds there and which the model makes. Then name one step the model decides today that my code could hold only on my own runtime. Change no file.
Check its answer against the row above. Then say which step of your own worker you would most want back in code, and where that worker would have to run.
Check yourself
Question 1 / 7
0 answered
Which two execution environments does the exam guide ask you to choose between?
Sources
- Owner
- Panaversity