The model proposes.
A tool call is structured output: a tool name and arguments. It does not run itself.
An LLM generates messages. The software around it supplies context, runs tools, and decides what happens next. That software is the harness.
See the loopModel = message generator. Harness = context + tools + control loop. Cache = reused prompt computation, not a saved answer.
The model asks to use a tool. The harness validates the request, enforces permissions, and executes it.
The harness is the hub: the LLM requests tools; the harness runs them.
A tool call is structured output: a tool name and arguments. It does not run itself.
It can approve, reject, or ask you. A model requesting a shell command is not permission to run it.
It stops on a final answer, cancellation, error, or a step / token budget—not just when the task is done.
The model does not automatically remember a previous API call. The harness sends the relevant history again—or uses an API that manages it.
Token: a chunk of text, often part of a word. Requests consume input tokens; generated messages consume output tokens.
A file read is not knowledge until its result reaches the next model call.
It has a token limit. Harnesses may select files, truncate results, or summarize old turns to fit.
The pricing connection: history is input again on later calls. Prompt caching can make repeated prefixes cheaper.
Providers can reuse computation for a matching prompt prefix. You still send the context; the model still generates a new response.
Conceptual blocks, not token counts. A matching prefix is necessary, not a guarantee: minimum length, cache lifetime, routing, model, and provider rules also matter. Some APIs require explicit cache configuration.
Keep instructions, tool definitions, and reusable documents consistent. Append new turns after them.
A changing timestamp or reordered tools near the start can break reuse for everything after it.
Separate the bill into fresh input, cache writes, cache reads, and generated output. Rates differ by model and provider.
New or uncached input, billed at the regular input rate.
Creating a reusable prefix. Some providers charge a premium.
Reusing an eligible prefix, usually at a discounted input rate.
Newly generated tokens. Prompt caching does not discount them.
Call 1 writes the prefix. Later calls read it. Each call has fresh input and output.
Let N = calls, P = prefix tokens, F = fresh tokens per call, O = output tokens per call. Rates are dollars per million tokens.
No cache = [N × (P + F) × input rate + N × O × output rate] / 1,000,000With cache = [P × write rate + (N − 1) × P × read rate + N × F × input rate + N × O × output rate] / 1,000,000For automatic caching without a write premium, set the write rate equal to the regular input rate.
The harness runs the loop.
The model generates the next message.
The cache saves repeated input work.