Repository navigation
feat(desktop): pull the skill-recommendation toggle from Settings - #791
Merged
Merged
Conversation
The General page no longer surfaces "Skill recommendations", so the feature cannot be switched on from the UI while it is being evaluated. The persisted `skillRecommend` app setting stays (Rust store + TS schema) and is still honoured when set — only the UI that wrote it is gone. Both the Rust and TS fields now say so, since a setting with no surface otherwise reads as a bug. The settings-page i18n strings go with the row; the composer card strings stay (the card still renders when the setting is set out of band). Also note the agent side was already inert: `suggest_skill` returns null unless `FUTURE_SKILL_RECO_JEV_KEY` is set, so with no toggle the feature cannot run or spend anything.
huichen
marked this pull request as ready for review
September 23, 2026 02:12
huichen
enabled auto-merge (squash)
September 23, 2026 02:26
huichen
added a commit
that referenced
this pull request
Sep 23, 2026
* feat(demos): add a Jev skill-recommendation demo with a 100-question evaluation
A self-contained demo of using TypeSafe Jev (System One) to pick the right skill
for a user request out of a 141-skill catalog (15 builtin + 126 third-party from
the skills submodule), or to decide that no skill applies. Nothing here touches
the Rust workspace, the desktop app or the mobile app: `demos/` is not an npm
workspace and no CI job's path filter matches it.
## How it works
One request per recommendation, and the module contains nothing else. A single
Choice over the whole roster with an extra `none_of_these` option; the request is
refused when that option gets at least 0.15 of the probability
(NONE_GATE_THRESHOLD), otherwise the highest probability wins. The threshold
belongs to the model's own answer rather than to a cut-off we apply to a ranking,
because the Choice is asked to pick "none of these" when nothing fits. Asking
"does this need a skill at all" as a separate question is worse - cross-validation
shows it costs 8-9 false refusals - because a verdict with no candidates on the
table is much easier to get wrong.
Putting the whole roster in one Choice is deliberate: chunking it scores the
same under held-out validation but costs 9% more. Chunking stays in the code for
the one case that needs it - a Choice takes at most 255 options (measured, and
none_of_these is one of them: 256 options returns 400), so a chunk holds at most
254 skills, which is now CHUNK_SIZE's default and is enforced by a load-time
guard instead of failing per request.
`bench/second-call.mjs` holds an earlier design that is NOT in the serving path.
It is kept there, not in `suggest.mjs`, so the serving module has no dead branch
that could be mistaken for the real one, and the code that produced the recorded
comparison sits next to the comparison.
## The second call, and why it is gone
Measured on the same recorded stage-1 answers (a paired comparison, which matters
because stage 1 alone moves by ~2 questions between runs):
option first-answer 2nd calls p50 p90 cost/req
1. one call (shipped) 59/65 90.8% 0/65 488ms 1224ms CNY0.00265
2. second call only if unsure 62/65 95.4% 20/65 526ms 1338ms CNY0.00274
3. always two calls 62/65 95.4% 65/65 772ms 1410ms CNY0.00295
Removing it costs three questions (4.6 points) and buys p50 -284 ms,
p90 -186 ms and 10.1% of the cost. Its fit threshold never fired once in 100
questions, so refusal never depended on it - the two revisions score identically
on refusal (97.1%, 1.5% false).
Option 2 is strictly better than option 1 on this data; option 1 ships anyway
because the shortest link chain was the deciding criterion. Three edits restore
option 2 (see REPORT 2.2.5).
One caveat that belongs with that table: two of the three wins (p019, p035) came
from questions whose wording overlaps the winning skill's SKILL.md text but not
its description. The reference answers were written from SKILL.md, so the
questions borrow the document's vocabulary, and only the second call could read
the document. That makes its measured advantage an upper bound rather than an
expectation.
## The single call's prompt is already at a local optimum
The obvious next step after removing a request is to tune the remaining prompt,
so 14 variants were measured across 4 batches. Method first: because stage 1
moves by ~2 questions between runs, variants are NOT run in separate sessions;
several go into ONE request as separate Choice questions over the same `state`,
with the shipped wording included as a control in every batch. Contamination was
verified against an independent recording of the identical request: 100/100,
99/100, 100/100, 100/100.
No variant beats the shipped wording, and two things turned out to be
load-bearing:
* "Choosing it is a normal answer here, not a fallback." - dropping it leaves
first-answer accuracy unchanged but collapses refusal from 97.1% to 85.7%
(four extra false suggestions). Jev needs an explicit licence to decline.
* The shipped question's presupposition ("The request needs a skill from
criteria") helps: making it neutral costs two refusals.
* Writing the none option out in more detail also backfires (two extra
suggestions), as does telling the model that general assistance is enough -
it over-refuses.
* Halving the option descriptions loses four answers; not truncating them and
adding a category tag gain nothing (and cost more).
* A length sweep (110/150/180/190/220/240/untruncated) rises monotonically to
220 and then flattens: 220 is exactly the knee. Shorter drops answers one at
a time, longer buys nothing.
So the remaining gap to the two-call version is an information gap - those
questions need the SKILL.md body, which the option table does not carry - not a
wording problem. There are two ways to close it (accept the gap, or put the
second call back), and no third "try harder on the prompt".
## The one call carries exactly one escape option, and that is measured too
none_of_these covers "nothing fits", so two further cases look like they deserve
their own option: several skills fit (12 of the 65 answerable questions have a
multi-skill reference set), and the request needs a skill outside the catalogue.
Both were measured in one paired request per question (escape-options.mjs):
* "several of these would help" was chosen 0 times in 100 questions. The
question asks which ONE to invoke, and "several fit" is not an answer to it,
so the model hedges with it but never commits. Nothing needed fixing there
either - the shipped design already hits the multi-skill reference set 12/12.
* "the skill I need is not in this list" is used accurately (3 picks, all on
requests naming a tool outside the catalogue) but those questions already had
none at 0.34-0.40 and were refused anyway. Its one net effect is to take
probability mass from none: on n026 that pulled none from 0.16 to 0.14, the
gate let through a wrong recommendation it had been catching, and refusal
quality fell from 34/35 to 33/35.
The general lesson is structural, not a wording issue: the gate reads none's
SHARE of a distribution that sums to 1, so adding an option silently recalibrates
the only refusal signal the design has. Re-tuning the gate recovers the loss and
then buys exactly nothing (61/65 either way), and treating a high escape
probability as a refusal costs 5 correct answers.
Two method notes also in the report: ctx-limit.mjs shows a request holds six full
option tables (51k tokens) with every position identical to a standalone request,
which is what licenses the same-request pairing used by every variant experiment;
and a variant added to an already-full cache had been silently scored as "refuses
everything" because a missing record and a refusal were the same value - the
scorer now fails loudly instead.
## Measured (100 questions, top-1 only)
65 questions written by kimi-k3 from a skill's own SKILL.md (enforced: no skill
name, no vocabulary unique to that skill's docs - checked by check-dataset.mjs)
plus 35 hand-written questions no skill serves. Reference answers from kimi-k3,
which never sees which skill a question came from.
decision agreement 93.0% first answer correct 90.8% (59/65)
in the reference set 93.8% (61/65)
correct refusal 97.1% false refusal 1.5% (1/65) false suggestion 1/35
5-fold held out (thresholds chosen on training folds only): 93.8%
cost 8,765 input tokens / CNY 0.0027 per recommendation - against 21,357 /
CNY 0.0065 for the original 141-Noul design, and about 9x cheaper than
the comparison chat model (billed in credits at 1 credit = CNY 1)
latency p50 488 ms / p90 1224 ms, against 1,747 ms for the chat model and
15 ms for local embeddings (which cannot refuse at all, so cannot be
used alone)
## The reference answers carry their own 1-2 question noise
Two independent generations of the reference answers (`runs/gold-v1`, which every number
in the report was computed against, and `runs/gold-v1-b`) agree on the first answer for
99/100 questions but on the **whole set for only 84/100**. The error analysis uses the set,
so this matters:
* p037 ("which tool for 3x3 matrix inversion") is a refusal in one generation and
`["matlab"]` in the other, which decides whether it is a false suggestion or a correct
answer. The report's claim that this question is genuinely ambiguous now has direct
evidence - the reference answers disagree with themselves.
* p019 is `["benchling-integration"]` in one and `["benchling-integration", "biopython"]`
in the other, which decides whether the answer Jev gave counts as wrong. The "the
removed second call fixed 3 questions" figure is 3 or 2 depending on the generation.
`dataset/gold-v1.json` is committed to match `runs/gold-v1`, i.e. the same generation that
produced `dataset/score.json`; otherwise the reference answers in the repo would not
reproduce the scores in the repo. Because the references come from an LLM, regenerating
them yields different scores by 1-2 questions - that is a property of the evaluation, not a
bug in it, and it is stated in REPORT 2.5 and 5.1.
## Read the run-to-run variance before comparing anything
This limitation most affects how the numbers should be read, so it has its own
section (REPORT 5.6). Three independent recordings of the SAME request are in
`runs/`, and they disagree on the winner for ~9% of questions. The headline
first-answer accuracy across three runs of identical code: 93.8%, 93.8%, 90.8%.
So a 65-question set resolves differences down to about two questions, "Jev vs
the chat model" is not decidable at this size, and every "adding X fixed N
questions" claim in the report is a PAIRED comparison on one set of recorded
stage-1 answers - unaffected by this variance - while comparing absolute scores
across runs is not valid. `bench/stage1-stability.mjs` measures it.
## Documentation in the branch
- `demos/jev-skill-suggest/README.md` - how to start the service, the key
handling, the request shape, the scores.
- `demos/jev-skill-suggest/bench/REPORT.md` - the full evaluation: what Jev is
(request shape, the three question types, the three things to know before using
it), how the question set was built, every cost and latency figure, the
held-out validations, the removal decision with its three-way comparison, the
prompt sweep, the error anatomy, the limitations including the run-to-run
variance, and the commands that reproduce each number.
- `demos/jev-skill-suggest/bench/` - the scripts that regenerate the dataset, the
reference answers, each system's answers, the scores, and the routing, payload,
prompt, skip and stability measurements. Results are cached per question; the
fingerprint covers the request shapes and every threshold, so changing any of
them re-runs instead of silently reusing. `bench/ui-smoke.mjs` renders the page
in jsdom against a running server and fails on any console error or on a field
the page reads but the API no longer sends.
## Key handling
No key is stored anywhere in this branch. Every entry point reads
`process.env.TYPESAFE_API_KEY` with no hard-coded value and no default; there is
no `.env` and no example key in the tree. The key stays inside the server process
and is never sent to the browser, `runs/` (per-question API responses) is
gitignored, and `probe.mjs` prints only a masked prefix. Without a key the demo
still starts against a clearly labelled local fallback so the UI can be inspected.
* Revert "feat(desktop): pull the skill-recommendation toggle from Settings (#791)"
This reverts commit 442b57f.
* feat(desktop): recommend skills on any message, with a daily budget
Align the implementation with PRD v1.6, and fix a send-swallowing regression
introduced by #787 (see "Send fix" below).
- **Any turn, not just the first.** The recommendation hook was only wired into
the new-conversation composer; the in-conversation composer (AgentThread) now
wires it too, so a message later in a conversation can be recommended for.
- **Daily budget counts recommendations, not calls.** A new
`skill_reco_events` table (day, skill, message hash) answers all three of
"how many recommendations today", "has this skill been shown today" and "has
this message already produced one". Calls that recommend nothing leave no row
and do not consume the budget, so three misses still allow a fourth call; once
three recommendations have been shown, the day's calls stop entirely.
- **Same message is evaluated at most once**, keyed by an FNV-1a hash of the
draft (no message text is stored).
- **Length gate is 30 UTF-8 bytes** (10 汉字, or ~30 ASCII characters) instead of
6 characters; over-long drafts still do not trigger.
- **Timeout budget 1500ms** (was 1000ms).
- **Install failure now toasts** ("安装失败,请稍后再试") while leaving the card
up so the user can retry or send without the skill.
- **Toggle defaults to on** (PRD v1.6 §3); Settings can opt out.
Send fix: `submitValue` used to re-enter itself from the evaluate callback, and
the recursive call was refused by the in-flight guard (`.finally` clears the flag
only after `.then`), so the draft was never sent — Send looked broken on every
message that produced no recommendation. It also asked the recommender twice for
the same draft when the flag happened to be clear. The real send path is now a
separate `sendNow()`, with `evaluatedDraftRef` making one draft cost at most one
call. The bug shipped in #787 but was dormant there (the toggle defaulted off and
had no UI); it became reachable when this commit flipped the default on and wired
the in-conversation composer, so main needs the same Composer fix.
Tests: `Composer.skillRecommend.test.tsx` (6) pins both halves — a no-match or
erroring recommender still sends, a hit holds the draft, one call per draft,
install appends " /skill" and sends, dismiss sends the original. Verified by
reverting the fix: "sends when the recommender finds nothing" fails with 0 calls
and "does not ask twice" fails with 2. Plus 6 store tests (budget semantics, day
rollover, retention, schema re-application) and 18 hook tests. Full suites green:
desktop vitest 1247, src-tauri skill_reco/app_settings/skills 74.
* feat(agent): log every skill-recommendation attempt with its outcome
`suggest_skill` returns `Option<SkillCandidate>` and deliberately collapses
every failure to `None`, so from the client a declined recommendation, an
exhausted budget, a missing key and a broken upstream all look identical: no
card. Add the log line that tells them apart.
Each attempt now emits one event:
- recommended: skill, probability, none_probability, latency, tokens, cost, query
- refused: none_probability + the gate threshold, so "the model said nothing
fits" is distinguishable from "we never asked"
- failed: the reason (timeout / connection / HTTP status with Jev's own error
body / malformed answer), which is the only place a 4xx diagnosis exists
- not asked: no key configured, or nothing to ask (`debug`)
Levels follow how often each fires: `info` for real decisions and `warn` for
failures (the default filter keeps both), `debug` for "the feature is off",
which would otherwise log on every message. The query is logged truncated
(40 visible chars) — the agent already logs full user messages, so this is
narrower than existing practice, not wider.
To make the reason loggable the attempt now returns an explicit `Outcome`
instead of an `Option`, and the response's `usage` is decoded so the line can
report the call's price. Cost is rounded to 0.01 厘: the raw product is float
noise (0.0026611200000000003) that only makes the log harder to read.
Tests: `log_outcome_reports_the_decision_with_its_numbers` captures a real
subscriber and pins the fields (a change that dropped the skill, the
probabilities or the price would otherwise make the feature undebuggable
without failing anything), plus `prices_a_call_from_its_input_tokens` and
`decide_flags_a_malformed_response_as_failure`. Verified against a live agent:
a billing failure logs
`WARN skill reco: call failed ... reason=HTTP 402 Payment Required: {...,"message":"Your organization has no available TypeSafe API credits..."} latency_ms=818`,
and with no key the info level stays silent while `--verbose` shows the reason.
* feat(tui,desktop): recommend skills in the TUI, and drop the "checking" hint
TUI (PRD v1.6 in the terminal):
- `handle_submit` asks the agent whether a skill fits the draft and holds it
while it waits, so the message is not sent until the user decides — the same
interception the desktop composer does.
- The offer is one line above the input box (a card has no buttons in a
terminal): `/skill` plus its summary, `[a] install & use`, `[Esc] send
without it`. Escape on a suggestion therefore means "send the draft", not
"clear the draft".
- The candidate set is the catalogue minus what the agent loads (`get_commands`),
computed in the app; the catalogue comes from `future skills list --json`,
which `/skills` already runs.
- `/skill-recommend [on|off]` is the TUI's counterpart of the desktop toggle,
persisted as `skillRecommend` in `~/.future/tui/settings.json` (on by default).
A bare form reports the state.
- The daily budget is the TUI's own file, `~/.future/tui/skill_reco.json`, in a
new `skill_reco` module: `tui/src/skill_reco.rs` holds the day, the skills
shown and the message hashes, so a corrupt or stale file degrades to "nothing
spent yet" rather than disabling the feature.
Budget semantics stay as the PRD states them: only a *shown* recommendation
counts (a call that recommends nothing leaves no record, so three misses still
allow a fourth call), one skill is never shown twice in a day, and one message
is never asked about twice. Per-client storage is deliberate: desktop and TUI
each hold their own, so one user's daily total across clients is not capped at
three.
Desktop: no "checking for a matching skill…" hint. The product decision is that
the wait is invisible, which left `SkillRecommendationProp.pending` with no
reader — so it is gone from the hook's state, the prop interface and both
call sites rather than left as a value every caller computes for nothing. Its
i18n strings go too; the submit is still held while the call is in flight.
Tests: 7 budget tests (limit, rollover, dedupe, corrupt file, hand-edited file,
hash properties) + 11 flow tests (every gate, the budget stopping the question,
declining sends, showing spends once, a duplicate skill is skipped without
spending, a late answer for a stale draft is ignored, Escape sends the draft,
accept appends " /skill ", the slash command persists). 2039 TUI tests pass.
Also fixed while here: the test helpers gave every app the same derived state
paths in the temp dir, which coupled tests through the shared budget file once
the intercept went in — each app now gets its own directory. The help card's
autocomplete drift guard caught the missing `/skill-recommend` rows.
* feat(remote,mobile): relay the skill recommender to the phone, with its own budget
Groundwork for skill recommendation on mobile. The phone cannot reach the
agent directly — it goes through the paired desktop — so this adds the relay
legs and the phone's own daily budget. The UI (intercept, card, settings
toggle) follows separately.
Relay (desktop `remote_host::business`):
- `suggest_skill`, `skill_reco_today` and `record_skill_reco` join the
allowlist and are served by `settings`, next to the skill management they
belong with.
- `suggest_skill` forwards the phone's `query` + `candidates` to the agent.
A failure is reported as "no recommendation" (`skill: null` with the reason
in the error field) rather than as a failed command: the contract is
best-effort, so a phone whose desktop is mid-upgrade still sends its
message. Candidates are parsed leniently — the candidate set is the phone's
guess at the catalogue, so a malformed entry is skipped and the rest still
recommend, rather than the whole command failing.
- `skill_recommend` joins the settings patch, so the phone can flip the same
toggle the desktop UI does. Absent still means "leave it alone".
Mobile:
- `skillRecoBudget`: the phone's own record in AsyncStorage (the desktop has a
SQLite table and the TUI a file; per-client storage is deliberate, so one
user's daily total across clients is not capped at three). Same semantics as
the other clients: only a *shown* recommendation counts, one skill is never
shown twice in a day, one message is never asked about twice.
- Every failure degrades to "nothing spent yet": corrupt, wrong-typed, or
another day's record all read as empty, because a corrupt budget must never
disable the feature and the worst case is one extra recommendation.
- `messageHash` is FNV-1a over UTF-8 with a hand-rolled encoder (`TextEncoder`
is absent in the RN runtime), pinned against the same vectors the Rust
clients produce so a message recognised on one client reads the same in the
others' records.
- `useDesktopManagement` gains the three commands; `DesktopSettings` gains an
optional `skillRecommend` (absent on an older desktop must not read as off).
Tests: 3 relay tests (lenient candidate parsing, missing/wrong-typed
candidates, the settings toggle) and 12 budget tests (limit, dedupe, rollover,
corrupt/hand-edited storage, write failure, and the shared hash vectors).
* feat(mobile): offer a skill suggestion before sending, over the desktop relay
Completes the mobile client (PRD v1.6), reusing the relay and budget added in
the previous commit.
- `useSkillRecommendation` owns the phone's trigger rules, the same set the
desktop and TUI clients apply: the desktop's toggle on, a real message (no
slash command) inside the length window (30 UTF-8 bytes to 2000 chars), not
already naming a skill, the day's budget unspent, and this message not already
asked about. A recommendation spends the budget when it is *shown*.
- `sendFromComposer` asks first and holds the draft on a suggestion; every other
outcome (declined, timeout, error, offline) sends the message as before. A send
attempted while the card is up toasts instead of silently doing nothing.
- `SkillSuggestionCard` sits above the composer: the skill, its summary,
「安装并使用」 and 「忽略并发送」. A failed install keeps the card up so the
user can retry or send without the skill.
- The preferences page gains the recommendation switch, reading and writing the
desktop's setting like the other automation switches. It reads as on when the
desktop does not report it (an older desktop predates the toggle).
Two fixes this needed:
- `useSendMessage.send` takes an optional text override. Composing the skill
command calls `setMessage` and then sends in the same tick, so reading the
`message` prop would have sent the pre-composition draft — the skill command
would never have reached the agent.
- AsyncStorage is mocked in a shared jest setup file. It is a native module, so
importing it in Node throws, and the budget pulls it into every component that
renders the composer (ChatScreen, AppNavigation). The package ships the mock;
a test needing its own storage still overrides it.
Tests: 13 hook tests (every gate, the budget stopping the question, decline and
error paths, duplicate-skill and duplicate-message skips, install/append/dismiss,
the card surviving a failed install) and the settings switch count. Full mobile
suite: 123 suites / 1865 tests.
* feat(agent): call Jev through the FutureOS gateway with the account credential
Jev is now hosted at `{future base_url}/v1/systemone`
(`https://future-os.cn/api/v1/systemone`) and billed at provider cost, so the
agent talks to that instead of TypeSafe's public API. The credential is the
**Future account key** already in `auth.json` — the separately configured
`FUTURE_SKILL_RECO_JEV_KEY` is no longer needed, which was the point of waiting
for this move. All three clients reach it through the same RPC, so nothing else
changes.
The gateway's request shape is **not** the public API's, despite looking similar:
- the question goes in `instructions`, not `question`;
- `criteria` **is** the option map — nesting it under an `options` key is not an
error, the model simply reads `"options"` as a choice name and answers with it.
The live gateway was probed to establish this; both facts are pinned by
`build_request_matches_the_gateway_shape`.
- the judging guidance therefore rides in `instructions`, including the
load-bearing "choosing none is a normal answer, not a fallback" sentence whose
removal collapsed refusal in the evaluation.
Also:
- **`usage.cost` is now believed over the price list.** The gateway reports what
it charged, which stays correct when the upstream rate moves; the published
rate remains the fallback for a response that omits it.
- **The log names the backend that answered** (`served_by=typesafe/jev-1.13-…`):
a gateway can route the same request elsewhere without the reply's shape
showing it, and that is exactly what you want to see when diagnosing.
- **Cost rounding fixed.** It rounded to 0.01 厘, which printed a real
¥0.000137 call as ¥0.0001 — a quarter of the price. Now 6 decimals.
- Endpoint, key and model each have an environment override so a development
build can point at another gateway; the credential test runs against an
isolated home rather than whatever the developer has logged in.
Verified against the live gateway end to end, through the agent RPC with **no
environment key set** (the account credential is used):
"帮我把这张照片转成水彩风格" → future-image (0.99, none 0.01)
"帮我写个快速排序算法" → declined (none 1.0)
INFO skill reco: recommended a skill skill=future-image probability=0.99
none_probability=0.01 latency_ms=772 input_tokens=452 output_tokens=54
served_by=typesafe/jev-1.13-20260917 cost_cny=0.000137
agent suite: 1861 tests green.
* refactor(agent): drop the Jev credential overrides; the Future account is the only source
Jev is served by the Future account's gateway now, so the environment overrides
added for the migration window are gone: `FUTURE_SKILL_RECO_JEV_KEY`,
`_URL` and `_MODEL`, along with the resolution order that preferred them.
A call now reads exactly two things from `auth.json` — the Future provider's
credential (what authenticates it) and its optional `base_url` (where the
gateway lives, defaulting to `https://future-os.cn/api`) — and always asks for
the `jev` model. That is the whole configuration surface: no separate Jev
credential exists to set, go stale, or diverge from the account being billed.
Also reworded the module header and the "no credential" log line, which both
still described the override path.
Tests: the two override tests collapse into
`the_endpoint_is_the_future_accounts_gateway`, which covers the provider's own
base URL, the default when none is configured, and a non-production gateway
path — all under an isolated home, so none of it depends on the developer's own
login. agent suite: 1861 tests green.
Verified end to end against the live gateway with the three variables explicitly
unset, through the agent RPC: "帮我把这张照片转成水彩风格" → future-image (0.99),
logged as served_by=typesafe/jev-1.13-20260917 cost_cny=0.000137.
* docs(agent): correct two statements the later changes made false
- `suggest_skill`'s handler doc still said "first-turn text" and "new session,
first message"; the trigger has been any turn for a while. It also said
"missing key", which stopped being the unavailability condition when the
credential became the Future account's.
- The `skill_reco` header pointed at the evaluation report's path on a branch
that was never merged, so the reference resolved to nothing. The constraints
it summarised stay; the dangling path goes.
* refactor(demos): call Jev through the Future account's gateway
The demo was the last thing authenticating to TypeSafe directly with its own
key. Jev is served by the Future account now, so the demo reads the credential
and base URL from `~/.future/agent/auth.json`'s `future` entry — the same source
the agent, desktop and TUI use — with `FUTURE_API_KEY` (and `_BASE_URL` /
`_MODEL`) as overrides. One credential source across the product and the demo,
and none of it needs configuring once you are signed in.
`FUTURE_*` replaces `TYPESAFE_*` throughout (22 files).
Three fixes this surfaced:
- `Suggester` decided live-vs-local from the `apiKey` handed to it, before the
client had resolved anything, so the account credential was never consulted
and the demo silently ran its local BM25 fallback. The mode now follows the
client's resolution.
- The client's coalesce used `??`, but callers signal "not configured" with `""`
— which `??` lets through, so the account was again skipped. `||` now.
- `probe` printed `key: (missing)` whenever the environment variable was unset,
while the call it was about to make used the account credential: a diagnostic
reporting a state the pipeline is not in. It now prints the resolved
credential (masked) and its source.
The auth probe still uses `GET /v1/models` to validate the credential, but that
endpoint lists only the gateway's chat models — `jev` is reachable on
`/v1/systemone` and does not appear there — so the note says so instead of
printing a model list that looks like the answer.
Verified live: `probe.mjs "帮我把这张照片转成水彩风格"` → future-image (0.93,
none 0.05) with `credential: sk-d… (len 100) from auth.json (future)`, and
`server.mjs` + `/api/suggest` → `backend: gateway`, verdict future-image.
`bench/option-limit.mjs` re-confirmed the 255-option cap through the gateway
(`Too many choices. Must have at most 255 choices`), which is the limit the
agent's 254-candidate cap is derived from.
Cost figures in the report stay valid: the gateway charges the same rate the
evaluation assumed (447 in-tokens billed $1.8774e-05 = 447 × $0.042/Mtok).
* test(agent): resolve the endpoint from an injected credential store
`endpoint()` read the process-global HOME through `AuthStore::load()`, so the
tests had to redirect HOME with `TestHome` — a process-wide mutation that other
tests read concurrently without the same lock. One full run in eight failed that
way, and the victim could not be identified from the output, which is exactly the
kind of flake that gets re-run until it disappears and then blamed on someone else
later.
The pure part is now `resolve(&auth)`, which takes the store; `endpoint()`
supplies the loaded one. The tests build stores from JSON, so they no longer
touch HOME, take no lock, and cannot affect any other test. That also let them
cover cases the HOME-based version could not express cheaply: another provider's
key is not borrowed, a Future entry with an empty key counts as absent, and a
non-production gateway keeps its own path.
Not proof the flake is gone (it was ~1 in 8); the mechanism is simply no longer
reachable from this module. 6 consecutive full runs pass, and the live call still
works: future-image (0.99), logged as
served_by=typesafe/jev-1.13-20260917 cost_cny=0.000129.
* docs(demos): state what the demo shares with production, and guard the one thing it must
The demo is a second implementation of a feature the agent now ships in Rust, so
its relationship to production needs to be explicit rather than assumed.
Two things are documented and one is enforced:
- **The ablation scripts must stay in JS, by design.** Their purpose is to vary
what production deliberately fixes — prompt wording, payload shape, chunk size,
thresholds, option sets. Run them against production and there are no knobs, so
the current constants (0.15 / 254 / 220) could never have been derived. They are
the factory that produced production, not a copy of it.
- **The serving path is aligned, and was measurably not.** The demo sent
`instructions` as an object `{question, how_to_judge}`; the agent sends a single
string. The gateway accepts both, so nothing failed — but the demo was not a
faithful stand-in and the two could drift silently. `suggest.mjs` now exports
`INSTRUCTIONS`, byte-identical to the agent's literal, and the chunked fallback
(a path production lacks — it clamps at 254) uses the same string shape so there
is one convention.
- **`bench/check-instructions.mjs` enforces it**, reading the agent's literal out
of the Rust source and the demo's out of its module and comparing them by value.
Verified it fails on a one-character change and reports the offset.
Also corrects the two claim-level details the gateway move left behind: the
client's description says TypeSafe, and "can the demo just call production" is
answered in the README — it can, but `suggest_skill` returns only the verdict
(no top-3, probabilities or gate), which is what the UI explains; doing so means
adding those diagnostic fields to the RPC.
* refactor(skill-reco): move the experiment into scripts/ and its docs into docs/internals/
The evaluation lived under demos/, which the repository's own doc check rejects
(a .md outside docs/ is not whitelisted) and which no layout convention covers.
Split it the way the repo does:
demos/jev-skill-suggest/ -> scripts/skill_reco/ (executables + data)
bench/REPORT.md -> docs/internals/skill_reco/evaluation.*
README.md -> docs/internals/skill_reco/harness.*
PLAN-integration.md -> docs/internals/skill_reco/integration-plan.*
Every relative import survives unchanged: both layouts put the top-level modules
two levels below the repository root and bench/ three, so ../suggest.mjs,
../../skills, dataset/ and runs/ all still resolve. Verified by re-running
check-dataset (offline), score.mjs, and a live request through server.mjs.
Docs are bilingual now, as docs/ requires: the existing Chinese text became
*.zh-CN.md and an English counterpart was written for each. The integration plan
is marked historical — it is implemented, and its numbers were superseded by the
PRD — so nobody implements the old values.
Mechanism parity (the point of keeping the demo JS after "don't use Rust for the
experiments"): bench/check-parity.mjs replaces check-instructions.mjs and reads
11 values out of *both* sources — instructions, none gate, candidate cap, desc
chars, none option, model, base origin, provider key, endpoint path, price, FX —
plus the invariant CHUNK_SIZE + 1 == MAX_CHOICE_OPTIONS, exiting non-zero and
naming the first differing character on drift. Verified to catch a single-value
change.
That check forced two real fixes:
- the demo's prices were inlined across 9 scripts (15 occurrences of 0.042/7.2);
they now come from USD_PER_MTOK_INPUT / USD_TO_CNY in jev.mjs, so a report
cannot quote money at a rate production no longer uses.
- check-instructions.mjs's default agent path was off by one directory level, so
the guard only ever worked when AGENT_SKILL_RECO was passed by hand.
Adds check-doc-refs.mjs, which fails when the documentation names a script that
does not exist (it found two references to scripts deleted with the removed
second call) and when it cannot read the docs at all — "measured nothing" must
never print as a pass.
* docs(skill-reco): point the harness at main, not at a feature branch
The harness instructions told the reader to fetch feat/skill-reco-demo and clone
with --branch, because the demo lived on a branch that had not merged yet. With
this landing on main those steps are wrong — and they would be the first thing a
reader hits. The prerequisites are now two steps: clone (with the skills
submodule) and run.
* fix(mobile): drop a virtual jest mock that leaked into later suites
`jest.mock(path, factory, { virtual: true })` was left behind for a path that
does exist — the same module the next line mocks properly. A virtual mock of an
existing module does not stay inside its own file: with `jest --runInBand` (which
is what `npm test` runs, and what CI runs) it leaked far enough to break
`react-i18next` for suites that ran afterwards, and `ChatScreen.test.ts` then
failed to boot with "You are passing an undefined module! Please check the object
you are passing to i18next.use()".
Why it hid locally: running `npx jest` (parallel) gives each file its own worker,
so the leak had no neighbour to damage. The suite was green there and red in CI,
which is the shape of every "passes locally, fails in CI" report — the command,
not the code, differed. `npm test` from now on.
Verified with the CI command itself: `npx jest --runInBand` in mobile/ is
1865 passed / 123 suites, and `src/features/chat` alone is 295 passed / 28 suites
(it was 1 suite failing to run before this).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Removes the 「智能技能推荐 / Skill recommendations」 toggle from Settings → General. The page goes back to its previous 3 switches.
Why
No UI should be able to switch the feature on while it is still being evaluated. The feature itself stays in place; only its Settings surface goes.
Scope
UI surface only. Two deliberate choices:
skillRecommendapp setting stays (Rust store + TS schema); only the UI that wrote it is gone. Deleting the field would touch the settings DB and buy nothing — nothing writes it now, so it stays at itsfalsedefault. Both the Rust and TS fields carry a comment saying it is not surfaced yet, since a setting with no surface otherwise reads as a bug.suggest_skillreturnsnullunlessFUTURE_SKILL_RECO_JEV_KEYis set. So with the toggle gone both gates are closed and the feature can neither run nor spend anything.The settings-page i18n strings (
skillRecommend.title/.description) go with the row. The composer card strings stay — the card still renders if the setting is set out of band.Diff
7 files, +9 / −23:
GeneralPage.tsx,SettingsDialog.tsx, bothsettings.jsonlocales, the GeneralPage test (switch count 4 → 3), and comments on the twoskillRecommendfield declarations.Checks
npm run lint(CI's eslint +tsc --noEmit): cleancargo fmt --checkunderdesktop/src-tauri: cleanorigin/mainin; no conflicts