Repository navigation
feat: Identify an inference server by name, so two servers can share one URL - #1983
Conversation
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>
|
Warning Review limit reachedYou'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. View limit details
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. |
…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
left a comment
There was a problem hiding this comment.
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.ForHostcomment incmd/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 inserver 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. |
There was a problem hiding this comment.
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) } |
There was a problem hiding this comment.
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.
What changed
Two or more
inference-routerservers 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.modify/routedwithDetails["server"]on each routed request.model.RoutedServerincore/modelis the only reader of that invocation. It reads no other router invocation, for examplewould_route.model.InferenceHostsgets a new method,LastNamedServer.LastServerkeeps its signature and its behavior, becausecore/is consumed outside this repo.InferenceServertogether withInferenceHost. A request that the router did not route setsInferenceServerto"".hostRuleVersionchanges, so a host table from an older session.json decodes as unknown. A non-stringinferenceServerdecodes as"".Resenduse the recorded name.routerconfigno longer refuses two servers on one URL.docs/inference-router-plugin.mdanddocs/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:
New tests include
TestRoutedServer,TestLastNamedServer,TestServerOf_SharedHost,TestRouter_SharedURLPathPrefix,TestSummaryFold_OldHostTableUnknown,TestSummaryFold_JSONRoundTripKeepsInferenceServerand the host-rule golden test.Size
core/session/testdata/inference-hosts.golden.json(8 lines), because no update flag writes it.docs/superpowers/plans/2026-11-18-server-by-name-1977.md.Review findings that were not fixed
core/model/inferencehosts_test.go,TestLastNamedServer, case "other", the entry hasLast: 3andLastUnrouted: 3. With these values the test cannot find a wrong version that counts atLastinstead of atLastUnrouted(rule 4). Give itLast > LastUnrouted, or add a second entry withLastUnrouted: 0that must return("", false). No case tests the tie rule ("on a tie the first entry wins").routerPluginliteral incore/modelequalsinferencerouter.Name. Check that this test is in the router package. If it is missing, a rename of the plugin makesRoutedServerreturn""in all cases, and no test fails.core/pipeline/model_alias.go:192: the newRoutedServerwrapper is on one line, with no blank line and no godoc, between the multi-lineSnapshotInvocationsandSnapshotPlugins. It works and gofmt accepts it, but its style is different from the lines around it.docs/inference-router-plugin.md:16: the newurlbullet 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 casehttps://gw.examplewithhttp://GW.example:4000inTestDecode_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".cmd/agentop/servers/servers.go, lines 156-157: theForHostcomment 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 addstill 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.docs/inference-router-plugin.md: the docs now say that two or more servers can share a URL, androuterconfig.Validateaccepts it. But agentop still finds the server of a session from its host:servers.ForHostreturns the first sorted name.ForHostsupplies the server column of the sessions pane, the server picker, and the session count thatrunningOngives toserver 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 useSessionSummary.InferenceServerfirst.For a human after review
Part of #1975and closes feature: Identify an inference server by name, so two servers can share one URL #1977. agentop (A2, feature: agentop names a session's server by name, and adds a second server on one URL #1978) still refuses a second server on one host until A2 lands.Fixes #1977
Part of #1975
Assisted-By: Claude (Anthropic AI) noreply@anthropic.com