Expand description
Model routes and the gateway that carries an agent’s model traffic (SPEC_AGENT_MODEL_ROUTES_ANY_MODEL_SPAWN_AND_SWITCH_2026_11_06.md).
Model routes and the gateway (docs/specs/SPEC_AGENT_MODEL_ROUTES_ANY_MODEL_SPAWN_AND_SWITCH_2026_11_06.md).
An agent runs a harness on a model route with a key. A route is an entry in [catalog]; its key is
a Vault entry that never leaves srv. The harness is pointed at /api/v1/model/<route>/... with a
per-agent token ([token]), and the handler (server::model_gateway_handlers) adds the real key
upstream, streams the answer back, and counts what each agent used ([spend], [usage]).
Modules§
- ask
- What an agent asks for when it names a route, resolved once for
Agents spawn,createandupdate, so the three cannot disagree (spec section 5.1). Pure: the key check is a closure the caller supplies. - bedrock
- The Bedrock route’s own rules (
docs/specs/SPEC_BEDROCK_MODEL_ROUTE_2026_12_01.md): the region and the cross-region profile the person chose, the model name Bedrock is asked for, the token count the gateway answers itself, and the one sentence each way Bedrock refuses a request. Pure, so each is tested without a network. - cap
- The spend caps (
docs/specs/SPEC_ROUTE_AGENT_BRAKES_2026_11_10.mdsection 3.2): how much an agent may use through the gateway in a UTC day, and how much a route may. The gateway reads them at each request, so a cap raised mid-turn lets the next request through. - catalog
- The routes AgentMux ships. A route’s address is fixed here and never read from an agent’s request.
- chat_
adapter - The adapter between the Anthropic Messages API, which Claude Code speaks, and OpenAI-style Chat Completions, which
Amazon Ergo on Bedrock speaks (
docs/specs/SPEC_BEDROCK_MODEL_ROUTE_2026_12_01.md, section 4.3). Pure: bytes in, bytes out, with no network, no async and no server state, so each rule is tested on its own. - launch
- An agent’s route and model, and the environment that points its harness at the gateway.
- pending_
route - The route a moved agent is waiting to take (docs/specs/SPEC_MOVE_AN_AGENT_TO_ANOTHER_COMPUTER_2026_11_24.md 7.3, “route and key”).
A move never copies a key’s value, and a route whose key is not in this computer’s Vault is not set: the agent arrives on its
harness’s own sign-in and says so (
needs a key) in My Agents. The route it came with is kept here, as a content blob beside the chosen one (super::launch::CONTENT_TYPE), and is taken, once, when the key lands: then it is the agent’s chosen route and this is cleared. A route the person chooses meanwhile wins: the pending one is dropped, never put over it. - request
- What the gateway forwards: which paths, which of the harness’s headers, and which model the request names. Pure, so each is tested without a network.
- spend
- What each agent has used through the gateway today, counted from the usage in each response times
the route’s price table. The live table is in memory; once
attachhas been called every change is also written to the history store (storage::spend_day) and the last two days are read back at start, so an srv restart does not start the day again. The day is the UTC day. - switch
- Moving an agent to another route or model in place (spec section 7a): what is recorded, and the guard on how often an agent may do it. The harness never changes. Restarting the panes at a turn boundary is the caller’s: the choice is read at every spawn, so recording it is what makes the next launch use it.
- token
- The per-agent token a harness sends to the gateway in place of a model key, minted the way a
container token is (
container::credential): kept by digest, valid for one route, attributed to one agent. It lives for this srv launch, as the instance key an agent is launched with does. - trial
- A change of route or model that is kept only once the first turn on it has worked (spec section 7a.3, “Thinking blocks across providers”). A backend that is not Anthropic’s may refuse a history it did not write: a thinking block’s signature, an image it cannot read, a setting it does not take. Left alone, the agent is on a place that answers every turn with a 400. So a change starts a trial: the place the agent came from is kept, the first turn the relaunched harness runs decides it, and a request the new place refuses puts the agent back where it was and says why.
- usage
- What a response used, read from the bytes as they pass: the usage block of a Messages response, or of
the
message_startandmessage_deltaevents of a stream. Nothing else in the body is kept.
Constants§
- PATH_
PREFIX - The path prefix the gateway is served under; the route id and the harness’s own path follow.