Four choices behind a coding session
Pointing a coding application such as Claude Code at a different place to send requests can change four things without us noticing. They are the model that answers, the provider that serves inference, the account that pays for usage, and the tools that can read our project. A product name such as “Claude” leaves those details unclear. After each kind of change, we can follow one prompt and file read through the four roles to identify what to recheck.
The four terms name different choices.
- Client/harness: the client is the application we use, and the harness is its orchestration layer. Claude Code’s agentic loop shows how the harness sends model requests, manages the context the model receives, and handles tool requests. Claude Code is the client, and its file and command tools act on the project through the harness.
- Model: the model processes input and produces an inference response, and inference is that processing step. In Claude Code, the model reasons and can request a tool action in its response.
- Provider: the service or deployment that exposes inference through an endpoint, the address a client contacts. A provider may also host the model itself. Claude Code supports direct Anthropic access and cloud-provider options with different authentication arrangements. A gateway can sit between the client and provider to handle routing and authentication.
- Access plan: the account’s entitlements, usage limits, and billing terms. A subscription may include eligible API credits, which are separate from subscription usage limits.

Figure text
- Four roles, separate choices
- Bright lamp: the role in view
- Four roles, four separate choices. This is not a request path, and it says nothing about where each one runs.
- Harness: Coordinates requests and tools
- Model: Produces inference responses
- Provider: Serves or routes inference
- Access plan: Governs access or billing
- Entitlements
- Usage limits
- Billing terms
- Pointing the app at a different place to send requests can change any of the four without us noticing.
From a prompt to a file read and back
To see who opens the file and how its contents reach the model after the model requests a read, we trace one prompt: “Explain how format_label handles an empty string in labels.py.”
The file exists, the harness runs on our computer, and inference runs at a hosted provider.
The request follows the agentic loop.
- We give the prompt to the local harness. The harness packages the task context and a description of the available tools into a model request.
- The harness sends an inference request to the provider. Here the request leaves our computer for the hosted inference service. The model works only with the context in that request.
- The model returns a tool request.
Its response asks the file-reading tool to read
labels.py, and the harness must carry out that read request. - The harness runs the tool locally.
If the read is permitted, the file tool opens
labels.pyin this session’s execution environment. - The tool returns a result to the harness. The result is the file content.
- The harness puts the result in the next inference request. The content goes back to the hosted service and becomes context for the model’s next decision.
- The model produces the next response. It can explain the function from the returned code or ask for more if that read wasn't enough. The harness shows the answer or keeps handling tool requests.

- The request leaves our computer: the harness sends an inference request to the hosted inference service.
- The model returns a tool request: its response asks the file-reading tool to read
labels.py, and the harness must carry out that read request. - The harness runs the tool locally: if the read is permitted, the file tool opens
labels.pyin the execution environment of this session. - The result goes back: the result is the file content, and it goes back to the hosted service in the next inference request.
- The model produces the next response: it can explain the function from the returned code or ask for more.
The local file tool opens labels.py, and the model sees its contents only through the harness’s next request.
Because the harness, not the model, runs the read, the harness’s checks decide which tool calls happen, as Tool-call trust in coding agents explains.
MCP servers your coding agent should not trust covers what a server that supplies the harness with tools can do to the agent.
Moving the harness to a remote execution environment changes where its tools act. The inference location is set separately. Provider-hosted tools work differently from tools run by the local harness.

Figure text
- A tool request returns to the harness
- Harness request (upright card)
- Model reply (sideways card)
- Tool result (empty slot: asked)
- The model did not run the tool. The harness ran it in its own environment, and the result is context for a later request.
- 1 Task prompt
- 2 The request, goes to hosted inference
- 3 A tool request, returns to the harness
- 4 The harness runs, a permitted tool here
- 5 The result, context for a later request
- Tool: Run by the harness, if permitted
- Harness
- Model: Works only with what the request contains
- Harness execution environment: Where the harness's tools act, in this example
- Hosted inference service: The provider serves inference here, in this example
- Context for a later request
- The tool hands its result to the harness. The model will see it only in a later request.
The loop is short enough to run. This Python script follows the same steps without a network: a scripted stand-in plays the model and returns fixed responses, and a dictionary stands in for the files in the project.
"""A toy agent loop. The model is a scripted stand-in, so the loop runs offline."""
FILES = {"labels.py": 'def format_label(text):\n return text.strip() or "(none)"\n'}
TOOLS = {"read_file": lambda path: FILES[path]} # the tools this harness permits
SCRIPTED = [ # a real model decides each response; here they are fixed in advance
{"tool": "read_file", "argument": "labels.py"},
{"tool": "run_command", "argument": "python3 labels.py"},
{"answer": "format_label returns (none) for an empty string."},
]
def model(messages):
"""Stand-in for inference: return the next scripted response."""
return SCRIPTED[sum(1 for message in messages if message["role"] == "model")]
messages = [{"role": "user", "content": "Explain how format_label handles an empty string in labels.py."}]
print("prompt: ", messages[0]["content"])
while True:
print(f"harness: inference request with {len(messages)} message(s)")
response = model(messages)
messages.append({"role": "model", "content": response})
if "answer" in response:
print("model: answer:", response["answer"])
break
tool, argument = response["tool"], response["argument"]
print(f"model: tool request: {tool}({argument!r})")
permitted = tool in TOOLS
result = TOOLS[tool](argument) if permitted else f"refused: {tool} is not a permitted tool"
print(f"harness: tool result: {result!r}")
messages.append({"role": "tool", "content": result})
It prints each turn in order:
$ python3 agent_loop.py
prompt: Explain how format_label handles an empty string in labels.py.
harness: inference request with 1 message(s)
model: tool request: read_file('labels.py')
harness: tool result: 'def format_label(text):\n return text.strip() or "(none)"\n'
harness: inference request with 3 message(s)
model: tool request: run_command('python3 labels.py')
harness: tool result: 'refused: run_command is not a permitted tool'
harness: inference request with 5 message(s)
model: answer: format_label returns (none) for an empty string.
The stand-in asks for two tools.
The harness in this script permits read_file, so that read runs and its result goes into the next request.
run_command is absent from TOOLS, so this script refuses it and hands the refusal back as the tool result.
The numbered steps above cover only the permitted case, and what a real harness sends back after a refusal depends on the product.
To try a variation, add an entry for run_command to TOOLS, or change the responses in SCRIPTED.
The choices left after setting a base URL
We usually change the destination of requests that leave our computer. That settles one choice in a request and leaves the others open.
A base URL picks the destination address. The API contract is the request and response behavior that both the client and the service have to support. A gateway can expose one interface while forwarding requests to another provider, so the gateway’s API contract must match Claude Code’s expected format.
The model ID picks the model or provider-side deployment the request addresses, and it may differ from the friendly name in a model picker. Claude Code uses provider-specific IDs and mappings, and it warns that unfamiliar IDs can stop the client from detecting supported capabilities. A capability declaration tells the client what to turn on, so it must match what the deployment supports.
The credential source decides which authentication material the client sends. Authentication options include API keys, cloud credentials, and identity-based authentication. Each provider has its own authentication options, so a login that works for one service may still fail to give us access through another.
The gateway setup guide names ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY, and apiKeyHelper as gateway credential options.
When one of them supplies the credential, requests use it instead of the saved subscription login, and subscription usage limits do not apply to those requests.
Setting only ANTHROPIC_BASE_URL leaves the credential unchanged, so a saved subscription login can stay active with its usage limits and billing.
How we fund a request and which credential it uses
The credential a request carries also determines which account pays.
To spend the subscription’s eligible API credits in a self-run, non-interactive claude -p invocation, we give it an API key from the linked Console organization.
If we use the subscription login instead, the invocation draws on the plan’s usage limits.
We check which balance or billing arrangement pays for the request separately from checking which credential the service accepts.
Current plan terms decide whether eligible credits apply.
A documented cloud option and a hypothetical self-hosted route
We can use Amazon Bedrock for inference, authenticate with a Bedrock API key or AWS credentials, and pay for usage through AWS.
The self-hosted example is an operator-run inference server behind a gateway, with Claude Code as its client.
| Setup detail | Cloud example | Self-hosted example |
|---|---|---|
| Client/harness | Claude Code | Claude Code |
| Model | The exact Claude model ID (model-ID guidance) | We choose the model and ID. |
| Provider | Amazon Bedrock | Operator-run inference service |
| Endpoint and API | We choose the region and endpoint. | The interface exposed by the gateway |
| Credential source | Bedrock API key or AWS credentials | We choose the credential source. |
| Access plan | AWS usage billing | Your operating budget |
| Access or support limit | Model access depends on account and region | Anthropic does not support non-Claude routing |
Before we rely on either combination, we check five things:
- the exact client and gateway versions
- the API behavior the gateway accepts
- the model-ID mapping
- provider-side availability
- credential requirements
After that we send a text request and make a harmless tool round trip.
A running session and its launch environment can differ
After we change a setting, we also need to know whether the session we are already running has picked it up.
An environment variable is a name-value pair handed to a process. GNU Bash documents that executed commands inherit the environment supplied at launch. When we later change an exported value in the parent shell, a child that is already running doesn't see it, while a new child gets the environment supplied at its own launch.
Applications reload configuration through a separate mechanism.
Claude Code watches its settings files and applies many edits mid-session, including changes to credential helpers such as apiKeyHelper (settings reload guidance).
Some settings are read only at session start.
The model setting is one of them.
To switch models mid-session, we use /model instead of editing the file.
We use what the running client reports to decide whether the model caused the mismatch.
/status reports the provider, base URL, and proxy, and /model selects the model.
We check which credential is active without printing its value.
If another client’s reload behavior is undocumented, we inspect a freshly launched session, because that client may reload settings differently from Claude Code.
Choose the row that matches your change
What to recheck after each change.
Sources: How Claude Code works - Claude Code Docs, Enterprise deployment overview - Claude Code Docs, Model configuration - Claude Code Docs, Monthly API credits for Max, Ultra, and Team plans | Claude Help Center.
| Role | Choice it names | What to recheck | Then confirm |
|---|---|---|---|
| Harness (tools) | Client and tool workflow | Tools, permissions, execution location | Tool result and resulting state |
| Model (model configuration) | Model revision or deployment | Exact ID and capabilities | Deployment availability |
| Provider (deployment options, gateway credentials) | Inference service and route | Endpoint, API, credential source | The exact route |
| Access plan (API credits) | Access and billing terms | Eligible usage and paying account | Credential permission, checked separately |
If we change only the inference endpoint, we recheck the API contract and exact model ID first, followed by the credential source, provider-side availability, and billing.
Sources by topic
Check these pages against your client version and current account terms.
- Anthropic: How Claude Code works: harness, model, tools, and execution environments.
- Anthropic: Enterprise deployment overview: inference options, authentication categories, billing arrangements, and route inspection.
- Anthropic: Model configuration: provider-specific IDs, model mappings, and capability detection.
- Anthropic: Settings: when edits take effect: application reload behavior and settings that wait for a new session.
- Anthropic: Other LLM gateways: gateway credentials, subscription behavior, and Anthropic's support limits.
- Anthropic: Connect Claude Code to an LLM gateway: gateway credential variables and setup checks.
- Anthropic: Monthly API-credit guidance: funding, eligibility, and credential distinctions.
- GNU Project: Bash Reference Manual, section 3.7.4: Environment: how child processes inherit the environment, independent of application settings reload.
What an attacker targets here
This loop gives an attacker two ways in: the text that reaches the model, and the harness that turns the model's requests into actions.
- A file, web page or tool result an attacker wrote goes into the next request and can carry instructions, which MITRE ATLAS calls indirect prompt injection. The control is a harness that checks every later call on its own terms, as Tool-call trust in coding agents shows.
- An MCP server's tool descriptions reach the model in full while the user sees a simplified version, so a malicious server can hide instructions there. We pin a hash of every description and check it before use, as MCP servers your coding agent should not trust explains.
- A rule written only into the prompt, such as one that limits a tool to administrators, falls to a user who claims to be an administrator. Authorization belongs in the harness, as the section on prompt rules explains.