With one intent rule and a Clef classifier (@cf/cloudflare/clef or
clef-flash), every turn's classification failed. jevBody always asks the
"level" choice, whose options are the intents alone, and Workers AI turns
away a choice of fewer than two options: 422 "questions: Dictionary should
have at least 2 items after validation, not 1". The field it names is
misleading: a request of one question is accepted (a lone noul, score, or
two-option choice each answered 200). The rule never matched and the turn
went down the group's order, with only the trace saying why. Jev accepts a
one-option choice, so it went unseen there.
One intent is no scale either. jevLevelled asked about it anyway, and Clef
Flash called a single kind a level at 0.58; readJev then reads the
one-option level answer, so once the 422 is gone the rule would match every
message. askJev now asks whether the intents are levels only when there are
two or more, and jevBody asks the level question only then: one intent is a
topic, a message may be none of it, and "none of these" stands. Two or more
intents, and the effort question, are asked as before.
Tests:
- TestClefOnCloudflare's fake Clef turns away a choice of fewer than two
options with Workers AI's real 422 body. Without the jevBody change it
fails with the classifier error above.
- TestJevLevels adds one intent that Jev calls a level: "none of these"
stands, picking it matches the rule, and no levels call is made. Without
the askJev change it fails: `one kind picked: ... Intent: ..., 3 calls`.
- TestJevOnVercelTypeSafe, TestJevOnVercel and TestJevOnCloudflare check
the levels call on the wire (Vercel's noul as a boolean, Cloudflare's
account looked up once), so each gets a second intent to keep asking it.
Verified on macOS (go1.26.8, temp HOME, Go caches pinned): go vet -tags
nogui ./...; go build, GOOS=linux go build -tags nogui, GOOS=windows go
build; go test -tags nogui ./...; go test -race -count=20 on the tests
above; gofmt -l clean. Against the real Clef: a nogui build in a temp HOME
on 127.0.0.1:3499 with a one-intent group and @cf/cloudflare/clef as its
classifier. Before, both turns' classifier error is the 422. After, "hi,
how are you?" matches at 0.97 and a refactor request is "none of these" at
0.94.
kensenzhao saw a subscription's allowance spent by requests the agent
didn't make: a routing group's classifier, set to a subscription's model,
asks it as every turn begins, and those calls looked like the agent's own.
What changed
- usage.Group has an own share (calls, tokens, cost) of the calls magpie
made by itself, filled for models, keys and accounts. Record.ByMagpie
is the test: agent "magpie", or one of its own User-Agents
(magpie-router/1, magpie-search/1, magpie-vision/1) where the agents
aren't loaded. The calls still count in the group's totals, as they
went to the same key or account. A group with none sends no "own".
- The classifier's calls are Kind "routing": callKind marks RouterAgent's
requests, and the decision model's record (Jev / System One) is written
with it. A "Routing classifier" purpose names them in the ledger.
- Usage page: magpie's row among the agents and its ledger rows carry a
"magpie's own" mark; an account's, key's or model's row adds "{n} by
magpie itself"; an account's card says how many of the period's
requests were magpie's own, drawn again once the summary arrives after
the allowances.
- Routing page: /api/groups marks a model a subscription account serves
(modelRef.Sub, servedRef). Beside a classifier on such a model, or a
group whose first member is one, the editor says every turn starts
with a request to that subscription, two when it picks both intent and
effort in words. A classifier on a key or a free model says nothing.
- New strings in zh, zh-TW, ja and de. The mark is a muted chip with an
even border all round (no left stripe).
Tests
- TestSummaryCountsMagpiesOwnCallsApart, TestByMagpie (usage).
- TestIntentRoutesATurn and TestJevPicksTheIntent (gateway) now check
the classifier's records are Kind routing and magpie's own, and the
agent's records are not.
- TestServedRefSaysASubscription (gui).
- own-requests.test.cjs: Chromium and WebKit, 1100 and 390 wide,
en/zh/zh-TW/ja/de, the API faked; no click scroll, no sideways page.
- Broken by hand, each turned its test red: addOwn counting nothing;
callKind's routing case removed; decide.go's Kind blanked; the ledger
mark, the agents' mark, the "{n} by magpie itself" line, the card's
line, its redraw after the summary, the Routing hint, its group case
and modelRef.Sub each removed.
Run: gofmt -l; go vet on darwin, linux -tags nogui and windows; go test
for usage, access, catalog, gui (-tags nogui) and gateway in full; the
GUI tests above, the ledger, routing-intent and translation tests.
Not done: the warmups (warmClaude/askClaude) write no usage record at
all, so they can't be marked; that is left as it was. Not tried with a
real subscription classifier against a live account.
Distinguish decision-only providers from gateways that also serve conversations. Only Jev models use the decision API; ordinary models remain in the catalog, automatic groups and conversation routes. Keep the full model cache when probing a mixed provider’s decision endpoint, and allow conversation model tests in its editor.
Verified with go vet -tags gtk3 ./..., go test -tags gtk3 ./..., node --check internal/gui/assets/app.js, and an isolated browser fixture.
Amp-Thread-ID: https://ampcode.com/threads/T-01a0fe05-afd7-70df-97cf-fdb69c4f4680
Co-authored-by: Amp <amp@ampcode.com>
A Claude subscription is served through a Claude Code run that keeps the conversation for its next turn, started with --effort. The run waiting for that turn was found by turnKey, which hashed the effort: a turn the router picked another level for missed it, retire let it go, and a new Claude Code was told the whole conversation in one message, a prefix the cache had never seen (as #463 for a run let go too soon). turnKey now holds only whether an effort was asked for, and resume tells a waiting run a new level before its turn with the control request Claude Code's SDK sends for applyFlagSettings ({"type":"control_request","request":{"subtype":"apply_flag_settings","settings":{"effortLevel":"low"}}}); its control_response is read past like any other line that isn't a stream event. Checked against Claude Code 2.1.287 under a sandbox HOME and a local fake Anthropic endpoint (no real API call): started at --effort low and told high, get_settings answers applied effort "high", and the two upstream requests differ only in output_config.effort (system, tools, thinking {"type":"adaptive"} identical; the history is the same apart from where cache_control sits), which is what lets Claude Code keep its cache across a level change. A run started without an effort and a turn with one (or the reverse) still get separate runs, as --thinking-display is only set with an effort.
API-key and Responses upstreams already kept the prefix: withEffort changes only output_config.effort for an adaptive Claude (thinking left as it is) and only reasoning.effort for the Responses API (instructions, tools, input and prompt_cache_key untouched, Codex's instructions not involved), which TestWithEffortKeepsTheCachedPrefix now guards. TestClaudeRunKeptAcrossEffort (a fake claude logging its stdin) fails without the change (a second process for the turn at low) and passes with it: one process, the control request before the second turn, none for a third at the same level. go vet ./internal/..., go build -tags nogui ./... (darwin, GOOS=linux), GOOS=windows go build ./..., go test -tags nogui ./... pass (internal/gui's TestFXInState failed once in the full run and passes alone and with its package; untouched here).
* feat(routing): group requests by session with names and estimated costs
* fix(routing): address session view review feedback
Preserve Luna Reserve and other header fallbacks for ordinary Codex turn metadata; reuse metadata and the kind across trace and native accounting. Default to By request and persist the grouping choice. Store only token accounting fields in route history while retaining legacy JSON compatibility.
Add regressions for helper precedence, native kind accounting, history compatibility and grouping preferences.
Vercel and Cloudflare each serve one Jev, as typesafe-ai/jev and
typesafe/jev. jev-latest is that model, rewritten to the name the
channel lists; jev-preview is not on the channel and is 400.
A bare jev-latest with two providers that have not fetched a list
used to 404 (listed empty, then no single provider to alias). Both
would take it, so it is 400 "more than one" as when the lists are in.
usage.Append still fills Requested and Served on systemOne and
serveSystemOne.
Tested with TestRouteDeciderVercelAlias (preview refused, own name
kept), TestRouteDeciderCloudflareAlias, TestRouteDeciderUnfetchedAmbiguous.