Jev's sure of an intent had to reach jevSure, a fixed 0.4, for every
group. zminds measured 39 of 237 turns in one day (16.5%) refused at sure
0.153 to 0.395, and those turns went by the group's routing as if it had
no intent rules. A group can now set its own threshold: intentSure, from
0 (take Jev's likeliest intent however unsure) to 1. Missing keeps 0.4.
readJev keeps Jev's likeliest intent, its sure and Topic (an answer of
intents rather than levels). ruleFor applies the group's own sure through
intentOf, so two groups sharing one classifier and its cached answer each
judge it at their own. "none of these" is never an intent, at 0 too.
Levels and effort are as before.
Set from a terminal: magpie group set <group> intent-sure=0.25, empty to
unset. SaveGroup and the CLI refuse a value outside 0 to 1, NaN too: the
patch's `v < 0 || v > 1` let intent-sure=NaN through the CLI, which
SaveGroup then failed on as "json: unsupported value". cloneGroups copies
the new pointer, since TestCloneGroupsSharesNothing went red on it.
Changed from ggbdpq's patch on #5101:
- The group editor's "Intent sure" row is left out. Its hints were long
secondary text, it showed for every classifier when only Jev answers
with a sure, and it had no GUI test. The Routing page instead carries
intentSure through each save it makes of a group (the editor's Save,
the routing menu, the manual pick), so a value set from the CLI isn't
wiped by the next GUI save.
- Its i18n strings and site/public/docs/intent.html are left out. A
site/ change waits for the maintainer (docs/contributors.md). The site
diff was documentation text only: a paragraph id="sure", a sentence
in "Match the rules" and one table row. It had no links or scripts.
- docs/subsystems/gateway-routing.md has a bullet for IntentSure.
Run on mote (mote-run):
- gofmt -l internal/: clean.
- go vet -tags nogui, also with GOOS=linux and GOOS=windows, on
internal/gateway, internal/cli and internal/provider: clean.
- go test -tags nogui -run 'TestGroupIntentSure|TestJev|Rule|Classif|Decide'
./internal/gateway: ok.
- -run 'Group|Apply' ./internal/cli: ok.
- -run 'Group|Save|Clone' ./internal/provider: ok.
- go test -run Budget ./internal/gui: ok.
- node --test group-intent-sure (new), routing-group-strategy and
group-first-token, in Chromium and WebKit: 42 pass, 0 fail.
- i18n-keys has one red, "a plugin's words are its own". It fails the
same on origin/main b712adb84 and is filed as #5327, #5332 and #5426.
i18n-en-no-cjk: ok.
Broken by hand, each red, then restored:
- sureNeeded always returns 0.4: TestGroupIntentSureThreshold,
ZeroTakesTheArgmax and IsPerGroup FAIL.
- The patch's `< 0 || > 1` checks put back: TestGroupIntentSurePairs
FAILs on "NaN" and "nan"; TestGroupIntentSureRange FAILs on NaN.
- The cloneGroups copy removed: TestCloneGroupsSharesNothing FAILs.
- The editor's Save sending intentSure null: group-intent-sure FAILs 4/4
("the editor's Save keeps it").
- The routing menu's pick sending null: it FAILs 4/4 ("a routing pick
keeps it").
Not tried: a real Jev account with a group at 0.25; the full suite.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
A routing group's intent classifier (askChat) and System One (askJev)
were each given a fixed 8s. A slow subscription classifier can now be
given longer in Settings > Models > Replies > Intent classifier timeout.
settings.json's classifyTimeout takes 1..60 seconds; 0 or missing keeps
8s. save() refuses below 0 or above 60, and ClassifyWait clamps a value
edited by hand (below 1 gives 8s, above 60 gives 60s). A settings file
that can't be read gives Shared()'s defaults, so 8s, never no timeout.
Both askChat and askJev read it per call. The GUI row is the app's own
segmented control (8, 15, 30, 60, plus a value set by hand), and other
saves carry the value on (prefsKeep, api.go). zh, zh-TW, ja and de
strings; the routing reference and the en, zh, ja docs say it.
Ported from reyoung's classify-timeout-2934 (author kept). On top:
- askJev's defer reworded any error once ctx had expired, so a refusal
(decideRefused) or an answerError read as the wait ran out lost the
type askDecideTries rests an account by. Now only errNoAnswer, which
systemOne returns when postDecide failed with ctx done, is reworded
to "<provider> gave no answer in <wait>".
- ja intent.html: a stray space in "遅いモデルだと 設定した".
- app.js: the Image generation timeout row and the new row share
waitRow (~350 bytes less). TestCoreScriptBudget was red (app.js
1,337,982 > 1,337,000); budgets raised to the exact sizes, app.js
1,337,633 and core 1,529,393, no room added.
Run (macOS, Go env pinned, sandbox HOME):
- Full go test -tags nogui -timeout 45m ./... at 766cf1cf9: 68 packages
ok; internal/gui red on TestCoreScriptBudget only, fixed above.
- At ed008ca9f and again after rebasing on 65e80405b: internal/gateway,
internal/settings, internal/gui ok; gofmt -l clean; go vet (darwin),
GOOS=linux go vet -tags nogui, GOOS=windows go vet all ok.
- Whole GUI suite at ed008ca9f, chromium and webkit, 4 wide at load
~30: 11,930 tests, 52 red, none in the files this change reaches
(classify-timeout-setting, image-timeout, i18n-keys all pass). The
red files rerun alone: 44 red in 10 files, the same 44 on origin/main
65e80405b. All have issues (#2228, #2399, #2150, #2448, #2276, #3091,
#2549, #2163, #3099, #3104) except library-mcp-health-wsl's ja case,
filed as #3350.
Broken by hand, each red then restored:
- classifyTimeout fixed at 8: TestClassifierTimeoutSetting and
TestJevGivenTheClassifierTimeout red.
- askJev fixed at 8: TestJevGivenTheClassifierTimeout red.
- save()'s bound removed: TestClassifyTimeoutKeptAndBounded (-1
accepted) and TestSettingsClassifyTimeout (61 gives 200) red.
- ClassifyWait's clamp removed: red (600 waits 10m0s).
- api.go's keep removed: TestSettingsClassifyTimeout red.
- prefsKeep's classifyTimeout removed: the GUI test's "sent on with
other saves" red in chromium and webkit.
Not tried: a real slow classifier or account; Linux and Windows at
run time; the native Linux desktop build; a test that pins the askJev
refusal-at-deadline race (it is timing-only, so no deterministic red
was written for it).
The classifier's pick was recorded but never applied when the agent asked for none, costing a classifier call per turn. The outer effort in the routing record is what the agent asked; the effort sent is tries[].effort on the try marked picked:true, which the groups help now says. Thanks to ggbdpq for the reproduction.
Run at this head (on 6485056e1, with the #2245/#2246/#2247 fixes together): gofmt -l clean; go vet ./... for darwin and windows, and linux -tags nogui; the full go test ./... in a sandbox HOME, all green. The new test fails on the old code and passes with the fix.
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.