Skip to content

Claude Code

Typing “hi” into Claude Code crosses ten layers

5 min read

Written by an AI model from the linked sources and checked against them by a second model. How we work

All about: Claude Code versions and changes →
Image: the-agent-stack.com

Clifford and Gaurav at Nori Agentic have mapped what happens between typing “hi” into Claude Code and getting a reply. They count ten layers, from the terminal down to the model weights, drawn as a pixel-art trip taken by a single request tagged req_7f3a. Their site, The Agent Stack, went up on October 10 and divides the stack at one line: everything above the API call belongs to you, and everything below it belongs to the provider.

One step in the middle of the trip changes how the agent loop reads. A tool’s result does not go to the model. It goes back to the harness, which reads the output, decides what to do next, and only then calls the API. Every tool call makes that round trip.

The layers you shape

The interface is the part you look at, and the page says it handles presentation, not execution. That is why one agent can show up as a terminal, an editor panel, a native app or a chat bot. The Agent Client Protocol calls this role the client.

Context is everything the model sees before it answers, and most of it comes off your file system: AGENTS.md, skills, source files and the output of earlier tool calls. The authors separate this layer from the context window. The layer is where context comes from, and the harness decides what gets loaded and in what order.

The harness is the code that turns a model into an agent, and the page describes it as a single loop: read the context, call the model, evaluate the reply, run the tools it asked for, feed the results back in, and repeat until the work is done. Claude Code, Codex and Nori are each a harness. In a walkthrough of building one in Python, Edd Mann writes that the loop runs until the model stops asking for tools or a max_iterations cap trips.

Tools are what the agent can do outside the model: run a shell command, read and edit files, fetch a URL, call an MCP server. Each harness defines its own set and its own instructions for using them, so the same model behaves differently depending on which tools it gets. The Modular handbook adds the limit: a harness doesn’t make the model more capable, because the weights stay the same. A guide by Sidbharath says Claude Code, Codex, Amp and Factory can all run frontier models, yet take different routes when given the same repository and the same bug.

Where your control stops

The API is an HTTP POST, and past it you can neither see nor change how the request is served. The page lists two things you can still set at that boundary. One is enterprise plan policy applied across a whole team. The other is an AI gateway, a stand-in API that meters spend per user, limits which models can be reached and issues one key for many providers.

On the other side, the request lands in a provider region and gets routed to a machine. Two neighbouring services handle it there: a cache and the inference service. The GPUs sit inside the inference service, and the model weights are loaded onto them.

Two caches, two costs

The first cache is the provider’s prompt cache. Providers cache a prompt’s prefix, so anything that changes early, such as a system prompt or a tool definition, invalidates everything after it. These caches usually live from five minutes to an hour. The authors say that is why your choice of harness and long gaps between turns show up directly on your bill.

Harness choice also reaches the bill through how much context gets sent. In an aistack benchmark on GLM-5.3-Flash across 4×H200s in September, one 64-task sweep cost $22.8 through Codex and $45 through Claude Code or Pi. Claude Code pushed more context through the model in that run without resolving more tasks.

The second cache lives inside inference, and the page treats it as a separate mechanism. The inference service reads the whole prompt in one pass, then generates one token at a time, batching your request with other people’s to keep the hardware busy. Each new token would normally mean reading back over everything before it. So the service stores what that reading produced, two vectors per token so far (a key and a value), and reuses them. That store is the KV cache. It is why the second token costs much less than the first, and why a long conversation costs memory as well as time: the cache grows with every token.

Silicon and weights

A data center GPU, the page says, packs a few hundred small processors. Each holds tensor cores that multiply one tile of a matrix per instruction, next to high-bandwidth memory. Generation speed is limited by how fast the weights move out of that memory, and raw math is not the bottleneck.

The weights are the learned numbers that make up the model. A token enters at one end and goes through layer after layer of matrix multiplies until a single output token comes out the other end. A dense model sends every token through every one of those numbers. A mixture of experts splits each layer into many separate blocks, and a small router picks a few of them for each token while the rest sit idle.

The authors say this is why parameter count stopped predicting cost: “A sparse model can carry a trillion parameters and still do the work of a far smaller one on any given token.”

No comments yet. Be the first.

Join the conversation

Sign in to leave a comment. It appears after moderation.