the night rounds: the GM-input rework and the reasoning-effort knob -- the workbench renders no faces: the composer overlay and the transcript share colour-only tokens (.narration dim, .emph accent), source verbatim, asterisks tinted and kept on screen, so the input's caret can never drift (the old overlay's real bold/italic shifted advance widths -- keeping every character preserved count, not width; the scrollbar-gutter match killed the second drift source); the story view carries its OWN renderer (view-story storyBody/storySpans) -- the book keeps real bold/italic with the asterisks spent, narration italic via #story-scoped CSS, one rule for the tool and typography for the deliverable, deliberately separate; the composer is turn-shaped: rows=6 floor, field-sizing: content grows it with the turn (the thing the GM remembered Firefox doing -- it was never in use), max-height 50vh caps with internal scroll, the footer moved under the transcript's column only so the input's width is the pane's; the transcript's stick-to-bottom was DEAD CODE all along (#transcript has no height or overflow -- main is the scroller, the scrollTop assignments were no-ops in every browser): stickBottom scrolls main and re-asserts next frame (Firefox's scroll anchoring can reclaim a same-tick scroll around a content wipe), main carries overflow-anchor: none; the prose pane drops its machinery by ruling: the status/agenda chips and the retired delta tags strip (the panes carry the derived state), the reminder card never renders (it is the same every turn -- the raw tab keeps every copy), and the status/agenda note receipts (the old delta applies and the whole-list sets alike) skip the prose walk while the raw keeps them; the model dropdown collapsed to one plain list of ids sorted, ceilings riding along (the family grouping left the user guessing what a family name means, and the curator's tier labels only made sense inside their groups); and the reasoning-effort round: the battery probes the ladder (probeEfforts -- each of none/minimal/low/medium/high/xhigh/max measured for mean thinking, two samples, efforts recorded per model, effortDefault the argmax mean over minimal..max, 'none' never a candidate -- it is the off switch; null when the model shows no thinking), the knob is first-class and the GM's alone (GM, 2026-11-16: hidden from the model, not her call -- never in the mind verb, never in the <model> display block, and renderView's via-derived block filters it too, both surfaces; it rides the via record for the raw surfaces), its unset state SENDS the measured max-mean default (the one knob with an honestly nameable default -- the registry measured it; layers run override > deployment > registry per-model, explicit null clears to nothing), the first non-numeric knob (RoleParams carries the string, the /model route validates against the ladder, the knob row a select whose unset label names what rides and rebuilds on model-select change); the GLM ladder verified live by hand before the build (low suppresses to a third of baseline, max elevates about double, the whole ladder accepted on both families without 400s, and reasoning_effort 'none' doubles as a standardized thinking-off switch); the model dropdown, the composer, and the knob UX browser-proven with zero console errors (the pass caught the unreachable-helpers bug: code after a factory's return never runs, a hoisted function referencing the uninitialized const throws silently mid-fill and stale rows render); smoke ALL PASS with the effort battery (the canned mock ladders, the default riding a bare turn's via, the override riding the next turn, the bogus-level 400, the null clear, no reasoning_effort in any <model> block) + restart + reminder + repo checks green, typecheck green on both programs; ROADMAP gains the distant extension point (n-choice inference composed by a turn-editor agent) and the operator's queue moved there from QUESTIONS by the GM; HANDOFF prepared as the handoff (the typing-round bullet trimmed into the rounds list, the server line now truthful -- the debug server runs, the registry bullet carries the six-knob state and the pending-effort refine)

This commit is contained in:
2026-11-16 23:52:58 +00:00
parent 5ffecee935
commit eebc1993dd
19 changed files with 571 additions and 179 deletions
+47 -6
View File
@@ -113,6 +113,12 @@ export async function discover(ctx) {
// --- step two: refine (the battery + the curator) -----------------------------
// the reasoning-effort ladder: the spellings the OpenAI-compatible
// world agrees on. `none` doubles as the standardized thinking-off
// switch. Mirrored in web/knobs.mjs for the select -- keep them in
// step.
export const EFFORT_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
/** One model's measured thinking under given request params.
* @param {Ctx} ctx @param {string} id @param {Record<string, unknown>} params @returns {Promise<number>} */
async function thinkingTokens(ctx, id, params) {
@@ -120,9 +126,32 @@ async function thinkingTokens(ctx, id, params) {
return Number(data.usage?.completion_tokens_details?.reasoning_tokens ?? 0);
}
/** The reasoning-effort probe: each level's measured mean thinking
* (two samples, the battery's granularity). The default is the
* level with the highest observed mean -- `none` is never a
* candidate, it is the off switch, not a thinking level (GM,
* 2026-11-16: maximum observable thinking by default, overridable
* by the user). A model that shows no thinking, or that no level
* moves, gets null -- nothing rides.
* @param {Ctx} ctx @param {string} id @returns {Promise<{ efforts: Record<string, number>, effortDefault: ?string }>} */
async function probeEfforts(ctx, id) {
/** @type {Record<string, number>} */ const efforts = {};
for (const level of EFFORT_LEVELS) {
const xs = [];
for (let i = 0; i < 2; i++) {
try { xs.push(await thinkingTokens(ctx, id, { reasoning_effort: level })); } catch { xs.push(0); }
}
efforts[level] = Math.round(xs.reduce((a, b) => a + b, 0) / xs.length);
}
const candidates = EFFORT_LEVELS.filter((l) => l !== 'none');
const best = candidates.reduce((acc, l) => (efforts[l] > efforts[acc] ? l : acc), candidates[0]);
return { efforts, effortDefault: efforts[best] > 0 ? best : null };
}
/** The deterministic battery over one model: the tool ping (the
* exact request shape a player turn takes), the reasoning samples,
* the off-switch probe. Every failure is a verdict, never an abort.
* the off-switch probe, the effort ladder. Every failure is a
* verdict, never an abort.
* @param {Ctx} ctx @param {RegistryModel} m @returns {Promise<RegistryModel>} */
async function probeOne(ctx, m) {
const base = { ...m };
@@ -131,17 +160,21 @@ async function probeOne(ctx, m) {
// the canned battery: all three stand-ins are inference models;
// mock and mock-tie are a deliberate tie pair (same deep bucket,
// same windows -- only the lex rule can part them), the cheap
// tier standard
// tier standard. The canned effort ladders exercise both shapes:
// the full ladder with max on top, and a capped ladder whose
// default is high
return m.id === 'mock-cheap'
? { ...base, inference: true, think: 120, reasoning: 'standard', offSwitch: null, latency: 5 }
: { ...base, inference: true, think: 300, reasoning: 'deep', offSwitch: null, latency: 7 };
? { ...base, inference: true, think: 120, reasoning: 'standard', offSwitch: null, latency: 5,
efforts: { none: 0, minimal: 20, low: 60, medium: 90, high: 120 }, effortDefault: 'high' }
: { ...base, inference: true, think: 300, reasoning: 'deep', offSwitch: null, latency: 7,
efforts: { none: 0, minimal: 40, low: 100, medium: 200, high: 300, xhigh: 400, max: 500 }, effortDefault: 'max' };
}
const t0 = Date.now();
try {
await ctx.provider.chat(m.id, [{ role: 'user', content: 'Say OK.' }], [ASK_GM_TOOL], { max_tokens: 400 });
} catch (e) {
const fail = String(e.message ?? e).split('\n')[0].slice(0, 200);
return { ...base, inference: false, fail, reasoning: null, offSwitch: null, latency: Date.now() - t0 };
return { ...base, inference: false, fail, reasoning: null, offSwitch: null, efforts: null, effortDefault: null, latency: Date.now() - t0 };
}
const latency = Date.now() - t0;
const samples = [];
@@ -157,7 +190,14 @@ async function probeOne(ctx, m) {
}
} catch { /* no off switch -- recorded as absent */ }
}
return { ...base, inference: true, think, reasoning: bucket(think), offSwitch, latency };
/** @type {Record<string, number>|null} */ let efforts = null;
/** @type {?string} */ let effortDefault = null;
if (think > 0) {
try {
({ efforts, effortDefault } = await probeEfforts(ctx, m.id));
} catch { /* the ladder is optional knowledge -- absent on a flaky endpoint */ }
}
return { ...base, inference: true, think, reasoning: bucket(think), offSwitch, efforts, effortDefault, latency };
}
// the pick rule, deterministic: the deepest reasoning bucket, then
@@ -199,6 +239,7 @@ async function curate(ctx, probed, best, user) {
const facts = probed.map((m) => ({
id: m.id, input: m.input, output: m.output, inference: m.inference ?? false,
fail: m.fail ?? null, reasoning: m.reasoning ?? null, hasOffSwitch: !!m.offSwitch, latencyMs: m.latency ?? null,
effortDefault: m.effortDefault ?? null,
}));
const messages = /** @type {import('./shapes.mjs').ViewMessage[]} */ ([
{ role: 'system', content: fs.readFileSync(CURATOR_PROMPT, 'utf8').trim() },
+6 -2
View File
@@ -33,7 +33,7 @@ import {
latestSession, sessionMeta, sessionDir, listSessions, loadSession, stopSession, writeMeta,
} from './session.mjs';
import { effectiveContents } from './variants.mjs';
import { HttpError, resolveParams } from './loop.mjs';
import { HttpError, resolveParams, resolveEffort } from './loop.mjs';
import { registry, usable } from './discovery.mjs';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
@@ -243,7 +243,11 @@ async function callHousekeeper(ctx, runId, messages, user) {
if (!usable(reg, model)) {
throw new Error(`model '${model}' is not in the deployment's model registry${reg ? ' (or failed the inference probe)' : ' -- the op has not run discovery yet'}`);
}
const params = resolveParams(ctx, runId, 'housekeeper');
const params = { ...resolveParams(ctx, runId, 'housekeeper') };
// the effort knob's own layers (its unset state sends the
// registry's measured default for this model)
const effort = resolveEffort(ctx, runId, 'housekeeper', model);
if (effort !== null) params.reasoning_effort = effort;
// attribution (#22): every LLM call names the acting user
console.log(`${new Date().toISOString().slice(11, 19)} llm ${model} u:${user?.id ?? '?'}`);
const data = await ctx.provider.chat(model, messages, undefined, params);
+37 -9
View File
@@ -129,15 +129,26 @@ async function runLoop(ctx, runId, user) {
for (;;) {
const view = renderView(s);
// the request's resolved params: the mind layer rides over the
// run and deployment layers. The current call's <model> block
// shows them to her when anything is set -- nothing set means no
// block (the absent grammar); the via record lands the same truth
// run and deployment layers, the effort knob resolves its own
// layers (its unset state sends the registry's measured default).
// The current call's <model> block shows her the knobs that are
// hers to answer with <mind> -- reasoning_effort is filtered out
// (hidden from the model, GM 2026-11-16: not her call); nothing
// set means no block (the absent grammar); the via record lands
// the same truth unfiltered, the raw surfaces carry it
/** @type {string} */ let model;
if (ctx.mock) model = 'mock';
else model = resolveModel(ctx, runId);
const params = { ...resolveParams(ctx, runId, 'player'), ...(s.mind ?? {}) };
if (Object.keys(params).length) {
view.push({ role: 'system', content: `<model>${JSON.stringify(params)}</model>` });
const effort = resolveEffort(ctx, runId, 'player', model);
if (effort !== null) params.reasoning_effort = effort;
const shown = { ...params };
delete shown.reasoning_effort;
if (Object.keys(shown).length) {
view.push({ role: 'system', content: `<model>${JSON.stringify(shown)}</model>` });
}
let msg;
/** @type {{ model: string, params: Record<string, number> }} */ let via;
/** @type {{ model: string, params: import('./shapes.mjs').RoleParams }} */ let via;
if (ctx.mock) {
// the synthetic marker: no provider call happens, but the knobs
// resolve for real (the mind layer included), so the smoke can
@@ -145,7 +156,6 @@ async function runLoop(ctx, runId, user) {
msg = mockModel(s, view);
via = { model: 'mock', params };
} else {
const model = resolveModel(ctx, runId);
via = { model, params };
// attribution (#22): every LLM call names the acting user
console.log(`${new Date().toISOString().slice(11, 19)} llm ${model} u:${user?.id ?? '?'}`);
@@ -275,7 +285,7 @@ function resolveModel(ctx, runId) {
/** The effective sampling knobs for a role: the deployment default
* layer (server.json params) under the run's own overrides. */
/** @param {Ctx} ctx @param {string} runId @param {'player'|'housekeeper'} role @returns {Record<string, number>} */
/** @param {Ctx} ctx @param {string} runId @param {'player'|'housekeeper'} role @returns {import('./shapes.mjs').RoleParams} */
function resolveParams(ctx, runId, role) {
const meta = ctx.runMeta(runId) ?? /** @type {import('./shapes.mjs').RunMeta} */ ({});
return {
@@ -283,7 +293,25 @@ function resolveParams(ctx, runId, role) {
...(meta.params?.[role] ?? {}),
};
}
export { resolveModel, resolveParams };
// The reasoning-effort knob's own resolution (GM, 2026-11-16): unlike
// the numeric knobs its unset state SENDS -- the registry measured a
// default, so one honestly exists. Layers: the run's override, then
// the deployment layer (server.json params), then the registry's
// per-model pick -- the level with the highest observed mean
// thinking. An explicit null clears the layers: nothing rides, the
// model id's baked default applies. Hidden from the model entirely:
// never in the mind verb, never in the <model> display block -- it
// rides the via record, the raw surfaces carry it.
/** @param {Ctx} ctx @param {string} runId @param {'player'|'housekeeper'} role @param {string} model @returns {?string} */
function resolveEffort(ctx, runId, role, model) {
const meta = ctx.runMeta(runId) ?? /** @type {import('./shapes.mjs').RunMeta} */ ({});
const set = meta.params?.[role]?.reasoning_effort ?? ctx.cfg.params?.[role]?.reasoning_effort ?? undefined;
if (set !== undefined) return set === null ? null : String(set);
const m = registry()?.models.find((x) => x.id === model);
return m?.effortDefault ?? null;
}
export { resolveModel, resolveParams, resolveEffort };
// --- the mind verb ------------------------------------------------------------
//
+14 -3
View File
@@ -603,8 +603,10 @@ route('POST', '/api/runs/:id/vars', async ({ params, body, user }) => {
// pick), selected from the registry (GET /api/models). Owner-only,
// changeable at any time -- every call resolves fresh, so a
// mid-session switch simply takes the next turn. null clears a role
// back to its deployment default; a null knob clears the knob.
const KNOBS = ['temperature', 'top_p', 'top_k', 'repetition_penalty', 'max_tokens'];
// back to its deployment default; a null knob clears the knob (for
// reasoning_effort, clearing means the registry's measured default
// rides again).
const KNOBS = ['temperature', 'top_p', 'top_k', 'repetition_penalty', 'max_tokens', 'reasoning_effort'];
route('POST', '/api/runs/:id/model', async ({ params, body, user }) => {
const id = params.id;
bundle.requireRun(id);
@@ -640,6 +642,14 @@ route('POST', '/api/runs/:id/model', async ({ params, body, user }) => {
}
for (const [k, v] of Object.entries(knobs)) {
if (!KNOBS.includes(k)) throw new HttpError(400, `unknown knob: ${k} -- ${KNOBS.join(', ')}`);
if (k === 'reasoning_effort') {
// the enum knob: one of the ladder's levels, or null to
// clear back to the measured default
if (v !== null && !discovery.EFFORT_LEVELS.includes(String(v))) {
throw new HttpError(400, `params.${role}.reasoning_effort must be one of ${discovery.EFFORT_LEVELS.join(', ')} -- or null to ride the model's measured default`);
}
continue;
}
if (v !== null && !Number.isFinite(v)) throw new HttpError(400, `params.${role}.${k} must be a number, or null to clear`);
}
}
@@ -649,7 +659,8 @@ route('POST', '/api/runs/:id/model', async ({ params, body, user }) => {
if (knobs === undefined) continue;
const cur = { ...(rp[role] ?? {}) };
for (const [k, v] of Object.entries(knobs)) {
if (v === null) delete cur[/** @type {'temperature'|'top_p'|'top_k'|'repetition_penalty'|'max_tokens'} */ (k)];
if (v === null) delete cur[/** @type {keyof import('./shapes.mjs').RoleParams} */ (k)];
else if (k === 'reasoning_effort') cur[/** @type {'reasoning_effort'} */ (k)] = String(v);
else cur[/** @type {'temperature'|'top_p'|'top_k'|'repetition_penalty'|'max_tokens'} */ (k)] = Number(v);
}
if (Object.keys(cur).length) rp[role] = cur;
+8 -1
View File
@@ -653,7 +653,14 @@ export function renderView(s, keepToolResults = 4) {
if (typeof content === 'string') {
content = content.replace(STRIP_HERS, '').trim();
if (e.via && Object.keys(e.via.params ?? {}).length) {
content = `<model>${JSON.stringify(e.via.params)}</model>\n${content}`;
// the via-derived block is the mind verb's read side:
// reasoning_effort is hidden from her (GM, 2026-11-16 --
// not her call), it rides the raw surfaces only
const shownVia = { ...e.via.params };
delete shownVia.reasoning_effort;
if (Object.keys(shownVia).length) {
content = `<model>${JSON.stringify(shownVia)}</model>\n${content}`;
}
}
if (i === lastProse) {
// the canonical stamp: status comma-separated (the wire
+11 -4
View File
@@ -88,15 +88,22 @@ export {};
/** @typedef {{ package: string, created?: string, owner?: ?string, forked?: number, models?: { player?: ?string, housekeeper?: ?string }, params?: { player?: ?RoleParams, housekeeper?: ?RoleParams } }} RunMeta */
/** The named sampling knobs, per role -- the well-known, widely
* supported set. Numbers ride the wire verbatim; null clears. */
/** @typedef {{ temperature?: number, top_p?: number, top_k?: number, repetition_penalty?: number, max_tokens?: number }} RoleParams */
* supported set, plus the reasoning-effort enum (GM, 2026-11-16:
* first-class, hidden from the model -- not her call). Numbers ride
* the wire verbatim; null clears; reasoning_effort is one of the
* effort ladder's levels. */
/** @typedef {{ temperature?: number, top_p?: number, top_k?: number, repetition_penalty?: number, max_tokens?: number, reasoning_effort?: string }} RoleParams */
/** One model of the discovered registry. Preliminary entries carry
* the scrape only (status unrefined); refined entries carry the
* battery's verdicts and the curator's presentation. think is the
* battery's best measured thinking-token count -- the pick rule
* ranks on it (the bucket is display). */
/** @typedef {{ id: string, input: ?number, output: ?number, status?: 'unrefined', inference?: boolean, fail?: string, think?: ?number, reasoning?: 'off'|'low'|'standard'|'deep'|null, offSwitch?: Record<string, unknown>|null, latency?: ?number, family?: ?string, label?: ?string, description?: ?string, roles?: { player: boolean, housekeeper: boolean } }} RegistryModel */
* ranks on it (the bucket is display). efforts is the
* reasoning-effort probe: the measured mean thinking per level of
* the ladder; effortDefault is the level with the highest observed
* mean (GM, 2026-11-16: maximum thinking by default, overridable)
* -- null when the model shows no thinking or no level moved it. */
/** @typedef {{ id: string, input: ?number, output: ?number, status?: 'unrefined', inference?: boolean, fail?: string, think?: ?number, reasoning?: 'off'|'low'|'standard'|'deep'|null, offSwitch?: Record<string, unknown>|null, efforts?: ?Record<string, number>, effortDefault?: ?string, latency?: ?number, family?: ?string, label?: ?string, description?: ?string, roles?: { player: boolean, housekeeper: boolean } }} RegistryModel */
/** state/models.json: the deployment's model registry -- the truth of
* what is selectable. Written by discovery (the scrape) and refine