Skip to content

feat: Identify an inference server by name, so two servers can share one URL - #1983

Merged
huang195 merged 7 commits into
rossoctl:mainfrom
huang195:feat/server-by-name-1977-pP1
Nov 19, 2026
Merged

huang195 merged 7 commits into
rossoctl:mainfrom
huang195:feat/server-by-name-1977-pP1

Conversation

@huang195

@huang195 huang195 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

What changed

Two or more inference-router servers can now have the same URL with different keys. Each place that needs the name of a server reads the name that the router recorded. The host is a fallback only when exactly one server has that host.

  • The router records modify/routed with Details["server"] on each routed request. model.RoutedServer in core/model is the only reader of that invocation. It reads no other router invocation, for example would_route.
  • model.InferenceHosts gets a new method, LastNamedServer. LastServer keeps its signature and its behavior, because core/ is consumed outside this repo.
  • The session store and the archive fold record InferenceServer together with InferenceHost. A request that the router did not route sets InferenceServer to "". hostRuleVersion changes, so a host table from an older session.json decodes as unknown. A non-string inferenceServer decodes as "".
  • The router's history scan, its host table read and Resend use the recorded name.
  • routerconfig no longer refuses two servers on one URL.
  • On a shared host, the router removes the longest path prefix of that host's servers, then adds the prefix of the server that it selected. Thus a request to a shared URL with a path prefix does not get the prefix two times.
  • Docs: docs/inference-router-plugin.md and docs/session-api.md.

A config where each host has one server keeps its behavior. Each existing test of such a config passes unchanged, except the tests of the deleted refusals.

How it was tested

The plan's gate passed on the tip of this branch:

(cd core && GOWORK=off go vet ./... && test -z "$(gofmt -l .)" && GOWORK=off go test ./... && GOWORK=off go test -race ./plugins/inferencerouter/... ./session/... ./model/...) && (cd cmd/agentop && GOWORK=off go vet ./...) && (cd cmd/cortex && GOWORK=off go vet ./...) && pre-commit run --from-ref b3ec2a3d545c16e8a80891f351707467229d0fb4 --to-ref HEAD

New tests include TestRoutedServer, TestLastNamedServer, TestServerOf_SharedHost, TestRouter_SharedURLPathPrefix, TestSummaryFold_OldHostTableUnknown, TestSummaryFold_JSONRoundTripKeepsInferenceServer and the host-rule golden test.

Size

  • Counted: 688 lines (added + removed). This count includes core/session/testdata/inference-hosts.golden.json (8 lines), because no update flag writes it.
  • Exempt: 180 lines, the plan document docs/superpowers/plans/2026-11-18-server-by-name-1977.md.

Review findings that were not fixed

  • [minor] T1: in core/model/inferencehosts_test.go, TestLastNamedServer, case "other", the entry has Last: 3 and LastUnrouted: 3. With these values the test cannot find a wrong version that counts at Last instead of at LastUnrouted (rule 4). Give it Last > LastUnrouted, or add a second entry with LastUnrouted: 0 that must return ("", false). No case tests the tie rule ("on a tie the first entry wins").
  • [minor] T1: Decision 1 of the plan asks for a router test that asserts that the routerPlugin literal in core/model equals inferencerouter.Name. Check that this test is in the router package. If it is missing, a rename of the plugin makes RoutedServer return "" in all cases, and no test fails.
  • [minor] T1: core/pipeline/model_alias.go:192: the new RoutedServer wrapper is on one line, with no blank line and no godoc, between the multi-line SnapshotInvocations and SnapshotPlugins. It works and gofmt accepts it, but its style is different from the lines around it.
  • [minor] T2: docs/inference-router-plugin.md:16: the new url bullet removes the rule for how hosts compare. The rule is: case is ignored, and the port is ignored except on a loopback host. The new text says "Two or more servers may have the same URL". But the code (Endpoint.Key, and the case https://gw.example with http://GW.example:4000 in TestDecode_SharedHost) also treats servers with different URLs as one shared host. That changes how the router reads their rows. The plan asked for this sentence, so the gap is in the plan's text. A possible fix is one clause: "a host is compared without case and, except on a loopback host, without port".
  • [minor] cmd/agentop/servers/servers.go, lines 156-157: the ForHost comment says "Unambiguous because the router refuses two servers on one host". After this change, that is false. routerconfig.Decode (servers.go:32) now accepts a hand-edited config with two servers on one URL. agentop then shows the server that is first in alphabetical order for each session on that host. agentop server add still refuses this case. Until A2 (feature: agentop names a session's server by name, and adds a second server on one URL #1978) is merged, the comment is incorrect.
  • [minor] docs/inference-router-plugin.md: the docs now say that two or more servers can share a URL, and routerconfig.Validate accepts it. But agentop still finds the server of a session from its host: servers.ForHost returns the first sorted name. ForHost supplies the server column of the sessions pane, the server picker, and the session count that runningOn gives to server remove. With a hand-edited shared config, agentop shows team-b sessions as team-a, and it counts 0 sessions on team-b. Add a note to the doc that agentop support comes with feature: agentop names a session's server by name, and adds a second server on one URL #1978, or let agentop use SessionSummary.InferenceServer first.

For a human after review

Fixes #1977
Part of #1975

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
…and shared-host path rule

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
The router records modify/routed with the server name on each routed
request. Read it with one helper, model.RoutedServer. Only a
request-phase modify/routed of inference-router counts.

- The InferenceHosts table key is now (agent, host, server).
  hostRuleVersion is 2, so a version 1 table decodes as unknown.
- Add InferenceHosts.LastNamedServer for a config where servers can
  share a host. LastServer does not change.
- SessionSummary.InferenceServer moves with InferenceHost in the
  store, the fold, session.json and the history merge.

Part of rossoctl#1977.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
Two or more servers can now have the same URL, for example one
server for each key on one gateway. The router names a server from
the server detail of the routed record, not from the host.

- routerconfig no longer refuses two servers on one host.
- byHost keeps the sorted list of the servers on each host. The host
  names a server only when one server has it.
- serverOf, wentTo and Resend read the routed record first. A row on
  a shared host with no routed record of a known server is no
  evidence.
- On a shared host the router takes off the longest server path that
  the request path starts with, and adds the path of the chosen
  server. So the prefix is not added two times.

Part of rossoctl#1977.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
team-a sorts first on the shared host. With the agent on team-a, a reader
that falls back to the first server of the host passed these cases. Now
the agent is on team-b, so that mutant fails.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
…e session list

Fixes review: foldJSON.InferenceServer was a strict string, so a non-string value failed SummaryFold.UnmarshalJSON and the archive skipped the whole session
Fixes review: SessionSummary.InferenceServer was a strict string, so one non-string row failed agentop's ListSessions decode of the whole list
Files:
- core/session/fold.go
- core/session/history.go
- core/session/hosts_test.go
- core/session/summary.go

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
@huang195
huang195 requested a review from a team as a code owner November 18, 2026 23:00
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ee265cd3-b1ec-450b-97cd-1616a75290cd
Commits

Reviewing files that changed from the base of the PR and between b3ec2a3 and 6fe22af.

Files selected for processing: 25

  • core/model/inferencehosts.go
  • core/model/inferencehosts_test.go
  • core/pipeline/model_alias.go
  • core/plugins/inferencerouter/decide.go
  • core/plugins/inferencerouter/history_test.go
  • core/plugins/inferencerouter/hosts_parity_test.go
  • core/plugins/inferencerouter/models.go
  • core/plugins/inferencerouter/models_test.go
  • core/plugins/inferencerouter/plugin.go
  • core/plugins/inferencerouter/plugin_test.go
  • core/plugins/inferencerouter/reload_test.go
  • core/plugins/inferencerouter/routerconfig/config.go
  • core/plugins/inferencerouter/routerconfig/config_test.go
  • core/session/fold.go
  • core/session/fold_test.go
  • core/session/history.go
  • core/session/hosts_test.go
  • core/session/inference_host_test.go
  • core/session/store.go
  • core/session/summary.go
  • core/session/testdata/inference-hosts.golden.json
  • docs/inference-router-plugin.md
  • docs/plugin-reference.md
  • docs/session-api.md
  • docs/superpowers/plans/2026-11-18-server-by-name-1977.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 18, 2026
…server prefix

On a host with one server, a request that starts with no server path
prefix and stays on that server keeps its path. On a shared host, the
router added the server's prefix to it. Thus a second server on a URL
changed the wire path of the traffic of the first server. Now the
router keeps the path in that case, as on a host with one server.

docs/plugin-reference.md now names the Server field of InferenceHosts
and tells readers to use LastNamedServer when servers share a host.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The change does what it says. A session's server is now taken from the router's modify/routed record first, and from the host only when one server has that host. RoutedServer is the single reader, serverOf (view scan) and LastNamedServer (table) follow the same rule, and the randomized parity test now mixes routed records into its rows (glm/glm2 share a host). I traced OnRequest on a shared host: the unrouted path, a route to a server on the host, a route off the host, and the two-path prefix swap. Credential dropping, addressed, and path handling all behave the same way they do on a one-server host. Resend now keys limits and refusals by the recorded server, and the record is always present when redirected is true, so single-host configs still resend as before. TestRoutedServerNameMatchesPlugin covers the routerPlugin literal drift that the PR body asks about.

Decoder probe, head vs base: I fed session.json a non-string inferenceServer (number and object) and a non-string hosts[].server. Head decodes all of them with no error, the same as base (LenientString, and the hosts table falls back to unknown). No regression.

Nothing blocks merge. Two non-blocking notes:

  • Docs (inline): the line about how hosts are compared was removed. It still decides which servers count as "shared".
  • Not in the diff: the servers.ForHost comment in cmd/agentop/servers/servers.go ("Unambiguous because the router refuses two servers on one host") is now false. With a hand-edited shared config, agentop shows the first sorted server for each session on that host and counts 0 sessions for the other server in server remove. You already list this under #1978. Until then, maybe add a short doc note that agentop follows later.

Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go (core/model, core/session, core/plugins/inferencerouter, routerconfig, pipeline alias), Docs
Agent/IDE config (.claude/.vscode): none
Commits: 7 commits, all signed-off: yes
CI status: passing (CodeRabbit/Spellcheck skipped)
Local: go vet, gofmt -l, and go test over model, session, inferencerouter and pipeline pass. The one failure, archive TestWriteSession_FailedEraseKeepsNumbering, also fails on base when run as root, so it is environmental.


- `servers` (map, required) — inference servers by name: lowercase letters, digits, `.`, `_` and `-`. Each has:
- `url` (string, required) — `scheme://host[:port][/path]`, `http` or `https`, no query, fragment or user info. A path is a prefix: the router puts it before each path it builds, which is a captured request's path, a path from `api`, or the path of a request moved off another server's host with that server's prefix taken off. A request sent to the server's own host and routed there keeps its own path, so the router never adds the prefix two times. One trailing `/` is dropped, so `https://h/inference/` is `https://h/inference`. A `.`, `..`, empty or escaped path segment is refused. The server's identity stays the host, with no path. A port must be 1–65535; the scheme's default is dropped, so `https://x:443` is `x`. No two servers may share a host, compared without case and, except on a loopback host such as `localhost`, without port, since one machine serves many things there: a session's server is named from the host its requests went to. A plain-`http` server on another machine logs a WARN at load, since routed requests would cross the network decrypted.
- `url` (string, required) — `scheme://host[:port][/path]`, `http` or `https`, no query, fragment or user info. A path is a prefix: the router puts it before each path it builds, which is a captured request's path, a path from `api`, or the path of a request moved off another server's host with that server's prefix taken off. A request sent to the server's own host and routed there keeps its own path, so the router never adds the prefix two times. One trailing `/` is dropped, so `https://h/inference/` is `https://h/inference`. A `.`, `..`, empty or escaped path segment is refused. A port must be 1–65535; the scheme's default is dropped, so `https://x:443` is `x`. Two or more servers may have the same URL, for example one server for each key on one gateway. The router names a session's server from the `server` detail of its `routed` record, not from the host. A plain-`http` server on another machine logs a WARN at load, since routed requests would cross the network decrypted.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: This rewrite drops the sentence about how hosts are compared (case ignored, and port ignored except on a loopback host). That rule still matters. byHost and serverAt use Endpoint.Key, so https://gw.example and http://GW.example:4000 count as one shared host (see TestDecode_SharedHost), and a row with no routed record on that host is no evidence. "Two or more servers may have the same URL" undersells this, because servers on different ports of one non-loopback machine are now accepted too and get the shared-host treatment. One clause would fix it, e.g. "Servers share a host when their hosts match without case and, except on a loopback host such as localhost, without port." It would also help to say that agentop still names a session's server from its host until #1978.

func SnapshotInvocations(ext *Invocations, phase InvocationPhase) *Invocations {
return model.SnapshotInvocations(ext, phase)
}
func RoutedServer(in *Invocations) string { return model.RoutedServer(in) }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This is a one-line wrapper with no godoc between two multi-line wrappers. It is fine as is, but a short // RoutedServer is model.RoutedServer. and the usual block layout would match the code around it.

@huang195
huang195 merged commit 9201b81 into rossoctl:main Nov 19, 2026
39 checks passed
@huang195
huang195 deleted the feat/server-by-name-1977-pP1 branch November 19, 2026 00:42
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feature: Identify an inference server by name, so two servers can share one URL

2 participants