gui: a routing group's Slow to start takes minutes of your own, beside Wait, 30 s, 1 min and 2 min (Kismet Alan on Discord)
The group editor's "Slow to start" (迟迟不出字) row offered only Wait,
30 s, 1 min and 2 min. Kismet Alan wanted a longer time of their own.
What changed:
- routing.js: the row gets a Custom segment, the same pattern as the
Context row's Custom: picking it shows a small minutes box beside the
segments (5 from Wait, else what was picked), focused to type in.
Decimals are taken (2.5 is 150 s; a comma is read as a point). Anything
else marks the box aria-invalid and the hint says "{v} is not a number
of minutes"; the last good value is kept. A saved time that is none of
the presets opens as Custom with its minutes. firstToken is still sent
in seconds, and the card's "Next after 150 s without a first token"
and the gateway are unchanged (provider.Group.FirstToken takes any
seconds >= 0).
- routing.css: the box and its "min" unit inside the existing ctx-wrap.
- i18n.js: Custom was already there; "e.g. 5", "Minutes", "min" and the
error in zh, zh-TW, ja and de.
- group-first-token.test.cjs: now five languages (en, zh, zh-TW, ja, de)
at 1100 and 420 wide in Chromium and WebKit. It adds the Custom flow:
no box until Custom, 5 to start and focused, "abc" refused with the
hint naming it, 2.5 saved as 150 and shown on the card, reopened as
Custom 2.5, back to 1 min hides the box, and the row stays inside the
editor with no horizontal scroll. At 420 the editor runs past the
window's foot and WebKit doesn't scroll the page's scroller to a
click, so the test wheels each control into view.
What was run:
- NODE_PATH=<playwright@1.62.0> node --test group-first-token.test.cjs:
20 of 20 pass (2 engines x 5 languages x 2 widths).
- Break check: with routing.js at the old code the test fails waiting
for the Custom segment.
This commit is contained in:
@@ -3277,6 +3277,10 @@ const I18N = {
|
||||
"Largest model's": "最大模型的",
|
||||
"Smallest model's": "最小模型的",
|
||||
"e.g. 200k": "如 200k",
|
||||
"e.g. 5": "如 5",
|
||||
"Minutes": "分钟数",
|
||||
"min": "分钟",
|
||||
"{v} is not a number of minutes": "{v} 不是有效的分钟数",
|
||||
"Agents are told the group takes {n} tokens; a longer conversation still goes on to a member with room for it.": "告诉 agent 这个组的上下文是 {n} tokens;更长的对话仍会交给放得下它的成员。",
|
||||
"Agents are told {n} tokens, its smallest model's, so they compact before any member would turn the conversation away.": "告诉 agent {n} tokens(组里最小模型的),这样 agent 会在任何成员拒收之前先压缩对话。",
|
||||
"Agents are told its smallest model's window, so they compact before any member would turn the conversation away.": "告诉 agent 组里最小模型的上下文,这样 agent 会在任何成员拒收之前先压缩对话。",
|
||||
@@ -8004,6 +8008,10 @@ const I18N = {
|
||||
"Largest model's": "最大模型的",
|
||||
"Smallest model's": "最小模型的",
|
||||
"e.g. 200k": "如 200k",
|
||||
"e.g. 5": "如 5",
|
||||
"Minutes": "分鐘數",
|
||||
"min": "分鐘",
|
||||
"{v} is not a number of minutes": "{v} 不是有效的分鐘數",
|
||||
"Agents are told the group takes {n} tokens; a longer conversation still goes on to a member with room for it.": "告訴 agent 這個組的上下文是 {n} tokens;更長的對話仍會交給放得下它的成員。",
|
||||
"Agents are told {n} tokens, its smallest model's, so they compact before any member would turn the conversation away.": "告訴 agent {n} tokens(組裡最小模型的),這樣 agent 會在任何成員拒收之前先壓縮對話。",
|
||||
"Agents are told its smallest model's window, so they compact before any member would turn the conversation away.": "告訴 agent 組裡最小模型的上下文,這樣 agent 會在任何成員拒收之前先壓縮對話。",
|
||||
@@ -12742,6 +12750,10 @@ const I18N = {
|
||||
"Largest model's": "最大のモデル",
|
||||
"Smallest model's": "最小のモデル",
|
||||
"e.g. 200k": "例: 200k",
|
||||
"e.g. 5": "例: 5",
|
||||
"Minutes": "分",
|
||||
"min": "分",
|
||||
"{v} is not a number of minutes": "{v} は分数として正しくありません",
|
||||
"Agents are told the group takes {n} tokens; a longer conversation still goes on to a member with room for it.": "エージェントにはこのグループのコンテキストを {n} トークンと伝えます。より長い会話は収まるメンバーに回されます。",
|
||||
"Agents are told {n} tokens, its smallest model's, so they compact before any member would turn the conversation away.": "エージェントには最小モデルの {n} トークンを伝えるので、どのメンバーにも断られる前に会話を圧縮します。",
|
||||
"Agents are told its smallest model's window, so they compact before any member would turn the conversation away.": "エージェントには最小モデルのコンテキストを伝えるので、どのメンバーにも断られる前に会話を圧縮します。",
|
||||
@@ -17480,6 +17492,10 @@ const I18N = {
|
||||
"Largest model's": "Größtes Modell",
|
||||
"Smallest model's": "Kleinstes Modell",
|
||||
"e.g. 200k": "z. B. 200k",
|
||||
"e.g. 5": "z. B. 5",
|
||||
"Minutes": "Minuten",
|
||||
"min": "Min.",
|
||||
"{v} is not a number of minutes": "{v} ist keine Anzahl Minuten",
|
||||
"Agents are told the group takes {n} tokens; a longer conversation still goes on to a member with room for it.": "Agenten wird gesagt, die Gruppe fasst {n} Tokens; ein längeres Gespräch geht weiter an ein Mitglied mit Platz dafür.",
|
||||
"Agents are told {n} tokens, its smallest model's, so they compact before any member would turn the conversation away.": "Agenten wird {n} Tokens gesagt, das kleinste Modell, sodass sie verdichten, bevor ein Mitglied das Gespräch ablehnt.",
|
||||
"Agents are told its smallest model's window, so they compact before any member would turn the conversation away.": "Agenten wird das Fenster des kleinsten Modells gesagt, sodass sie verdichten, bevor ein Mitglied das Gespräch ablehnt.",
|
||||
|
||||
@@ -445,6 +445,9 @@ button.rt-session { cursor: pointer; }
|
||||
.rt-gedit .gsuffix { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
|
||||
.rt-gedit .gsuffix .hint { overflow-wrap: anywhere; }
|
||||
.rt-gedit .ctx-wrap input.ctx-in { width: 96px; flex: none; }
|
||||
.rt-gedit .ctx-wrap input.first-in { width: 64px; }
|
||||
.rt-gedit .ctx-wrap .first-unit { margin-left: -2px; color: var(--muted); font-size: 12px; }
|
||||
.rt-gedit .ctx-wrap .first-unit[hidden] { display: none; }
|
||||
.rt-pool { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 12px 10px 14px; }
|
||||
.rt-pool .nm { flex: 1 1 12em; display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
|
||||
.rt-pool .nm .ic { width: 16px; height: 16px; }
|
||||
|
||||
@@ -4404,11 +4404,45 @@
|
||||
ed.append(kLab, kw);
|
||||
drawSink();
|
||||
// a member slow to begin its answer: waited for, or the next asked
|
||||
const fHint = el("div", "hint"), fw = el("div");
|
||||
const drawFirst = () => fHint.textContent = d.firstToken
|
||||
? t("A member that hasn't begun answering after {n} — no text, reasoning or tool call yet — is let go and the next one asked, before any of it reaches the agent. It doesn't rest; the last one left is always waited for. Only for streamed requests.", { n: took(d.firstToken * 1000) })
|
||||
: t("Every member is waited for, however long it takes to begin answering.");
|
||||
fw.append(segs(FIRST_OPTS.map(([n, l]) => [n, t(l)]), d.firstToken || 0, (v) => { d.firstToken = +v; drawFirst(); }), fHint);
|
||||
// or after as many minutes as the user types (Kismet Alan on Discord)
|
||||
const fHint = el("div", "hint"), fw = el("div", "ctx-wrap first-wrap");
|
||||
const firstIn = keys(input("", t("e.g. 5")));
|
||||
firstIn.classList.add("ctx-in", "first-in");
|
||||
firstIn.inputMode = "decimal";
|
||||
firstIn.setAttribute("aria-label", t("Minutes"));
|
||||
fHint.id = "groupFirstHint";
|
||||
firstIn.setAttribute("aria-describedby", fHint.id);
|
||||
const firstUnit = el("span", "first-unit", t("min"));
|
||||
const firstMins = (s) => String(+(s / 60).toFixed(2));
|
||||
let firstMode = FIRST_OPTS.some(([n]) => n === (d.firstToken || 0)) ? d.firstToken || 0 : "custom";
|
||||
if (firstMode === "custom") firstIn.value = firstMins(d.firstToken);
|
||||
let firstErr = "";
|
||||
const drawFirst = () => {
|
||||
firstIn.hidden = firstUnit.hidden = firstMode !== "custom";
|
||||
firstIn.setAttribute("aria-invalid", String(!!firstErr));
|
||||
fHint.textContent = firstErr || (d.firstToken
|
||||
? t("A member that hasn't begun answering after {n} — no text, reasoning or tool call yet — is let go and the next one asked, before any of it reaches the agent. It doesn't rest; the last one left is always waited for. Only for streamed requests.", { n: took(d.firstToken * 1000) })
|
||||
: t("Every member is waited for, however long it takes to begin answering."));
|
||||
};
|
||||
fw.append(segs([...FIRST_OPTS.map(([n, l]) => [n, t(l)]), ["custom", t("Custom")]], firstMode, (v) => {
|
||||
firstErr = "";
|
||||
firstMode = v;
|
||||
if (v !== "custom") d.firstToken = +v;
|
||||
else {
|
||||
// starts from what was picked, or 5 minutes from Wait
|
||||
d.firstToken = d.firstToken > 0 ? d.firstToken : 300;
|
||||
firstIn.value = firstMins(d.firstToken);
|
||||
}
|
||||
drawFirst();
|
||||
if (v === "custom") firstIn.focus();
|
||||
}), firstIn, firstUnit, fHint);
|
||||
firstIn.oninput = () => {
|
||||
const v = firstIn.value.trim().replace(",", ".");
|
||||
const n = /^\d+(?:\.\d+)?$/.test(v) ? Math.round(+v * 60) : 0;
|
||||
firstErr = n > 0 ? "" : t("{v} is not a number of minutes", { v: firstIn.value.trim() });
|
||||
if (n > 0) d.firstToken = n;
|
||||
drawFirst();
|
||||
};
|
||||
ed.append(el("label", "", t("Slow to start")), fw);
|
||||
drawFirst();
|
||||
// every member busy at once: the agent told, or the members asked
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// A routing group may let a member go that is slow to begin its answer
|
||||
// (Chen on X: every answer waits on a slow vendor). The group editor's
|
||||
// "Slow to start" row picks Wait, 30 s, 1 min or 2 min, its hint saying
|
||||
// what each does; saved, the group is sent with firstToken in seconds and
|
||||
// its card says "Next after 60 s without a first token". Wait sends 0 and
|
||||
// the card says nothing. In English and Chinese, Chromium and WebKit.
|
||||
// "Slow to start" row picks Wait, 30 s, 1 min or 2 min, or Custom and as
|
||||
// many minutes as are typed (Kismet Alan on Discord), its hint saying what
|
||||
// each does; saved, the group is sent with firstToken in seconds and its
|
||||
// card says "Next after 60 s without a first token". Wait sends 0 and the
|
||||
// card says nothing. In five languages, Chromium and WebKit, at 1100 and 420.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -28,7 +29,11 @@ const groups = () => ({
|
||||
const words = {
|
||||
en: { edit: "Edit", save: "Save", label: "Slow to start", wait: "Wait", min: "1 min", tag: "Next after 60 s without a first token", waits: "Every member is waited for" },
|
||||
zh: { edit: "编辑", save: "保存", label: "迟迟不出字", wait: "一直等", min: "1 分钟", tag: "60 秒 无首字换下一个", waits: "每个成员都会一直等" },
|
||||
"zh-TW": { edit: "編輯", save: "儲存", label: "遲遲不出字", wait: "一直等", min: "1 分鐘", tag: "60 秒 無首字換下一個", waits: "每個成員都會一直等" },
|
||||
ja: { edit: "編集", save: "保存", label: "応答開始が遅いとき", wait: "待つ", min: "1 分", tag: "最初のトークンが 60 秒 なければ次へ", waits: "どのメンバーも" },
|
||||
de: { edit: "Bearbeiten", save: "Speichern", label: "Langsamer Start", wait: "Warten", min: "1 Min.", tag: "Nächstes nach 60 s ohne erstes Token", waits: "Auf jedes Mitglied wird gewartet" },
|
||||
};
|
||||
const custom = { en: "Custom", zh: "自定义", "zh-TW": "自定義", ja: "カスタム", de: "Benutzerdefiniert" };
|
||||
|
||||
function serve(lang, posts) {
|
||||
const state = { agents: [{ id: "codex", name: "Codex", path: "/test/codex", fields: [] }], profiles: [], settings: { lang, theme: "light" } };
|
||||
@@ -60,16 +65,16 @@ function serve(lang, posts) {
|
||||
}
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh"]) {
|
||||
for (const lang of Object.keys(words)) for (const width of [1100, 420]) {
|
||||
const w = words[lang];
|
||||
test(`${engine} ${lang}: a group lets a slow-to-start member go`, async (t) => {
|
||||
test(`${engine} ${lang} ${width}: a group lets a slow-to-start member go`, async (t) => {
|
||||
saved.firstToken = 0;
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const page = await (await browser.newContext({ viewport: { width: 1100, height: 2000 }, reducedMotion: "reduce" })).newPage();
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 2000 }, reducedMotion: "reduce" })).newPage();
|
||||
t.after(async () => {
|
||||
if (process.env.ARTIFACT_DIR) {
|
||||
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
||||
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-group-first-token.png`) });
|
||||
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-group-first-token.png`) });
|
||||
}
|
||||
await browser.close();
|
||||
});
|
||||
@@ -82,38 +87,94 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await card.waitFor();
|
||||
assert.equal(await card.locator(".tag", { hasText: w.tag }).count(), 0, "off by default");
|
||||
|
||||
// at 420 the editor runs past the window's foot, and WebKit doesn't
|
||||
// scroll the page's own scroller to a click: wheel it into view
|
||||
const reach = async (loc) => {
|
||||
await loc.waitFor();
|
||||
await page.mouse.move(width / 2, 600);
|
||||
for (let i = 0; i < 30; i++) {
|
||||
const b = await loc.boundingBox();
|
||||
if (b && b.y >= 0 && b.y + b.height <= 2000) return loc;
|
||||
await page.mouse.wheel(0, b && b.y < 0 ? -400 : 400);
|
||||
await page.waitForTimeout(50);
|
||||
}
|
||||
return loc;
|
||||
};
|
||||
const save = async () => {
|
||||
const ed = page.locator(".rt-gedit");
|
||||
await ed.locator("button.primary", { hasText: w.save }).click();
|
||||
await (await reach(ed.locator("button.primary", { hasText: w.save }))).click();
|
||||
await page.waitForFunction(() => !document.querySelector(".rt-gedit"));
|
||||
return posts.filter((p) => p.path === "/api/groups/save").at(-1).body;
|
||||
};
|
||||
await card.locator("button", { hasText: w.edit }).click();
|
||||
await (await reach(card.locator("button", { hasText: w.edit }))).click();
|
||||
const ed = page.locator(".rt-gedit");
|
||||
const row = ed.locator("label", { hasText: w.label }).locator("xpath=following-sibling::div[1]");
|
||||
await row.waitFor();
|
||||
await reach(row);
|
||||
assert.equal(await row.locator(".opt.on").textContent(), w.wait);
|
||||
assert((await row.locator(".hint").textContent()).startsWith(w.waits));
|
||||
await row.locator(".opt", { hasText: w.min }).click();
|
||||
assert((await row.locator(".hint").textContent()).includes(lang === "zh" ? "60 秒" : "60 s"));
|
||||
const secs = (n) => page.evaluate((n) => t("{n} s", { n }), n);
|
||||
assert((await row.locator(".hint").textContent()).includes(await secs(60)));
|
||||
assert.equal((await save()).firstToken, 60);
|
||||
await card.locator(".tag", { hasText: w.tag }).waitFor();
|
||||
|
||||
await card.locator("button", { hasText: w.edit }).click();
|
||||
await (await reach(card.locator("button", { hasText: w.edit }))).click();
|
||||
await row.waitFor();
|
||||
await reach(row);
|
||||
assert.equal(await row.locator(".opt.on").textContent(), w.min, "the editor opens at what was saved");
|
||||
await row.locator(".opt", { hasText: w.wait }).click();
|
||||
assert.equal((await save()).firstToken, 0);
|
||||
await page.waitForFunction((tag) => ![...document.querySelectorAll(".rt-group .tag")].some((x) => x.textContent === tag), w.tag);
|
||||
|
||||
// Custom: as many minutes as are typed, from 5 when it was Wait
|
||||
await (await reach(card.locator("button", { hasText: w.edit }))).click();
|
||||
await row.waitFor();
|
||||
await reach(row);
|
||||
const minutes = row.locator("input.first-in");
|
||||
assert.equal(await minutes.isVisible(), false, "no minutes box until Custom is picked");
|
||||
await row.locator(".opt", { hasText: custom[lang] }).click();
|
||||
assert.equal(await minutes.isVisible(), true);
|
||||
assert.equal(await minutes.inputValue(), "5");
|
||||
assert.equal(await page.evaluate(() => document.activeElement?.classList.contains("first-in")), true, "the box is focused to type in");
|
||||
assert((await row.locator(".hint").textContent()).includes(await secs(300)));
|
||||
await minutes.fill("abc");
|
||||
assert.equal(await minutes.getAttribute("aria-invalid"), "true");
|
||||
assert((await row.locator(".hint").textContent()).includes("abc"), "the hint says what is wrong");
|
||||
await minutes.fill("2.5");
|
||||
assert.equal(await minutes.getAttribute("aria-invalid"), "false");
|
||||
assert((await row.locator(".hint").textContent()).includes(await secs(150)));
|
||||
// the row fits the editor at this width
|
||||
const fit = await row.evaluate((r) => {
|
||||
const box = r.getBoundingClientRect(), ed = r.closest(".rt-gedit").getBoundingClientRect();
|
||||
return [...r.querySelectorAll(".segs, input.first-in, .first-unit")].every((x) => {
|
||||
const b = x.getBoundingClientRect();
|
||||
return b.left >= ed.left - 0.5 && b.right <= ed.right + 0.5 && b.right <= box.right + 0.5;
|
||||
}) && document.scrollingElement.scrollWidth <= document.scrollingElement.clientWidth;
|
||||
});
|
||||
assert.equal(fit, true, "the Custom row overflows at " + width);
|
||||
assert.equal((await save()).firstToken, 150);
|
||||
const tag150 = w.tag.replace(await secs(60), await secs(150));
|
||||
await card.locator(".tag", { hasText: tag150 }).waitFor();
|
||||
|
||||
await (await reach(card.locator("button", { hasText: w.edit }))).click();
|
||||
await row.waitFor();
|
||||
await reach(row);
|
||||
assert.equal(await row.locator(".opt.on").textContent(), custom[lang], "a time of its own opens as Custom");
|
||||
assert.equal(await minutes.inputValue(), "2.5");
|
||||
await row.locator(".opt", { hasText: w.min }).click();
|
||||
assert.equal(await minutes.isVisible(), false);
|
||||
assert.equal((await save()).firstToken, 60);
|
||||
|
||||
const missing = await page.evaluate(() => [
|
||||
"Wait", "30 s", "1 min", "2 min", "Slow to start", "slow to start", "Next after {n} without a first token",
|
||||
"Every member is waited for, however long it takes to begin answering.",
|
||||
"A member that hasn't begun answering after {n} — no text, reasoning or tool call yet — is let go and the next one asked, before any of it reaches the agent. It doesn't rest; the last one left is always waited for. Only for streamed requests.",
|
||||
"{who} hadn't begun answering after {ms}, so the request went on to the next before any of it reached {agent}. Nothing is wrong with {who}, so it doesn't rest.",
|
||||
"In magpie", "Vendor's first token",
|
||||
].filter((k) => !I18N.zh[k]));
|
||||
assert.deepEqual(missing, [], "every string has its Chinese");
|
||||
"Custom", "e.g. 5", "Minutes", "min", "{v} is not a number of minutes",
|
||||
].filter((k) => !["zh", "zh-TW", "ja", "de"].every((l) => I18N[l][k])));
|
||||
assert.deepEqual(missing, [], "every string has its zh, zh-TW, ja and de");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user