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.

Four separate objects stand apart, with no path between them and no boundary around them: Harness, coordinates requests and tools; Model, produces inference responses; Provider, serves or routes inference; Access plan, governs access or billing, with three rows named Entitlements, Usage limits and Billing terms. They are categories, not a request path, and no deployment location is implied.
The four roles in a coding session.
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.

  1. 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.
  2. 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.
  3. 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.
  4. The harness runs the tool locally. If the read is permitted, the file tool opens labels.py in this session’s execution environment.
  5. The tool returns a result to the harness. The result is the file content.
  6. 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.
  7. 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.
Two platforms with a gap between them. On Our computer: a file tool and the harness. On Hosted inference service: the model. Four lanes: 1 The request leaves our computer. 2 Replies come back to the harness. 3 The harness opens the file here, a lane that stays on our computer. 4 File content in the next request. At the end one pale card tagged Next response rests on the harness.
  1. The request leaves our computer: the harness sends an inference request to the hosted inference service.
  2. 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.
  3. The harness runs the tool locally: if the read is permitted, the file tool opens labels.py in the execution environment of this session.
  4. The result goes back: the result is the file content, and it goes back to the hosted service in the next inference request.
  5. The model produces the next response: it can explain the function from the returned code or ask for more.
In this example the harness runs on our computer, so the file tool acts there. The model sees the file only through the next request.

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.

Two platforms with a gap between them. On Harness execution environment: a tool, the harness, and a floor mark numbered 1 named Task prompt. On Hosted inference service: the model. Lane 2 carries a request from the harness to the model. Lane 3 brings a tool request back to the harness. Lanes 4 and 5 run between the harness and the tool and stay inside the harness execution environment. At the end a pale block tagged Context for a later request rests on the harness.
The harness runs a permitted tool locally in response to the hosted model’s output.
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:

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.

RoleChoice it namesWhat to recheckThen confirm
Harness (tools)Client and tool workflowTools, permissions, execution locationTool result and resulting state
Model (model configuration)Model revision or deploymentExact ID and capabilitiesDeployment availability
Provider (deployment options, gateway credentials)Inference service and routeEndpoint, API, credential sourceThe exact route
Access plan (API credits)Access and billing termsEligible usage and paying accountCredential 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.

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.