diff --git a/harness/README.md b/harness/README.md index d1c20cc..f9bdf56 100644 --- a/harness/README.md +++ b/harness/README.md @@ -22,7 +22,7 @@ page *Harness-parity* in LLeMbas CLI's wiki. | `permission/defaults.json` | The rules every session starts from | | `permission/modes.json` | The four modes — manual, edit, auto, plan — as what each does with each risk class | | `models/schema.json` | Model metadata: context, output limit, efforts and the thinking switch, vision, tools, notes, capacity (`parallel`); `levels` — the effort levels a chat offers and what each sends | -| `loop.json` | How one prompt runs: the step backstop, budgets, wrap-up, nudges, parallel calls, capacity; `jobs` — background work, its marks and limits; `subagents` — the model refusals, what names a model, the setting's label; `team` — a team's size, names, marks, refusals and texts; `progress` — the phases' texts; `context` — result ids, stubs, the output cap, the compaction table, the environment lines, the session notes; `scheduled` (3.5.0) — scheduled work on a linked computer: the setting, the modes, the approval wait, the sentinel, the watch command's limits and the refusals; `phone` (3.6.0) — phone actions: the capability, each action's fields, what is required and checked, the wait and the texts; `display` (3.7.0) — a call's title keys, states and facts, the blocks, the cards' actions; `scheduled.notify` (3.8.0) — notify-when and its texts; `pages` (3.8.0) — the fence word, the frame's variables, the note and the projection | +| `loop.json` | How one prompt runs: the step backstop, budgets, wrap-up, nudges, parallel calls, capacity; `jobs` — background work, its marks and limits; `subagents` — the model refusals, what names a model, the setting's label; `team` — a team's size, names, marks, refusals and texts; `progress` — the phases' texts; `context` — result ids, stubs, the output cap, the compaction table, the environment lines, the session notes; `scheduled` (3.5.0) — scheduled work on a linked computer: the setting, the modes, the approval wait, the sentinel, the watch command's limits and the refusals; `phone` (3.6.0) — phone actions: the capability, each action's fields, what is required and checked, the wait and the texts; `display` (3.7.0) — a call's title keys, states and facts, the blocks, the cards' actions; `scheduled.notify` (3.8.0) — notify-when and its texts; `pages` (3.8.0) — the fence word, the frame's variables, the note and the projection; `interactive` (3.9.0) — interactive-only models: the field, the two sentences, what each background call does with nowhere to go | | `filesystem.md` | The file system a session works in: paths, node kinds, the four access levels, errors, listings, search and indexing by tokens, stacked instruction files, skills, memory | | `context.md` | Context hygiene: what happens to a tool result when it is inserted, and never afterwards; the prefix that stays still; reasoning sent back during its turn; no absolute paths in the prompt | | `team.md` | Teams: a lead and the members it adds, the size setting, the room, who receives what, reports, a manager's refusals, capacity, stopping | @@ -32,6 +32,7 @@ page *Harness-parity* in LLeMbas CLI's wiki. | `reports.md` | Reports (3.8.0): a schedule's run files a report with `report_write`, or leaves a history line; notify-when (`always`, `when`, `never`) and the instruction for each; what a run leaves; the retired `[SILENT]`; a run on a linked computer | | `pages.md` | HTML pages in answers (3.8.0, experimental): the `html-view` fence, what the model is told, the note and the text projection for a reader that cannot show a page, when pages are offered, the session note, the frame | | `permission/rules.md` | Which permission rule decides (3.8.0): the layers, the candidate, the floors a later-made rule gives way to (3.9.0: a narrower rule that a later one narrows again is set aside), and what making a rule does | +| `interactive.md` | Interactive-only models (3.9.0): the field, what counts as a person's own turn, scheduled work that never runs on one, and where a session's background calls (title, compaction) go instead | | `display.md` | Display (3.7.0): one display in every client — a tool call's title, its four states, the duration and the facts beside it, the kinds of block; how `stopped` and `failed` stay on a finished reply; what the approval, question and plan cards offer; numbers in the client's locale | | `quirks.json` | What real servers do, and how both harnesses cope | | `conformance/.json` | Cases with their expected results, run by both test suites | @@ -109,6 +110,18 @@ a field, a rule amended, no tool and no text for a model. broad `read: allow` both counted and the strictest won, so making the allow *started* asking about `.env.example`. Now the example file is read without asking after it as before it. LLeMbas: the same change in its rule lookup, if it has the same floor. +- **Interactive-only models** (`interactive.md`, `models/schema.json` `interactive_only`, + `loop.json` `interactive`, `conformance/interactive.json`; three more cases in + `last_model.json`). A model served through a connection its provider sells for a person's own + turns only says `interactive_only: true`. **Scheduled work never runs on one**: it is not + offered for a schedule and is refused when named; a run whose model is one fails with the + sentence, and a device refuses such a scheduled turn itself (`data.reason: + "interactive_only"`), its subagents included; so does a one-shot `lembas run` with no + terminal at all. **Background calls go elsewhere**: a title or a compaction for a session on + such a model is asked of its twin (the same model under another provider), else of a default + that is not interactive-only, else the title and automatic compaction are skipped and a + compaction the person asked for is refused in words. What a person starts — their turns, the + subagents and teams of their session — stays on the model. ## 3.8.1 diff --git a/harness/acp.md b/harness/acp.md index f853425..613924a 100644 --- a/harness/acp.md +++ b/harness/acp.md @@ -402,6 +402,10 @@ resolves it for every run that opens a session, when the run starts, and sends i when the person still has it; 3. else as before 3.9.0: the default a schedule without a model runs on. +Never an interactive-only model (`interactive.md` §2): a schedule cannot name one, the +directory's does not count when it is one, and a run left with one fails with the sentence — +which the device says too, should such a turn reach it (`data.reason: "interactive_only"`). + So an Agentic schedule that names no model follows the directory: change the model you work with there, and the next run uses it. A schedule that continues one conversation keeps its session's model from run to run; the client changes it (`_lembas/configure`) only when the schedule names a @@ -488,7 +492,8 @@ client's to decide from this answer (`reports.md` §4). A device without the cap `_lembas/session/status` and the turn id, as for any agent chat. - **Refused** (`-32602` from a scheduled `session/new`, `session/prompt` or `_lembas/monitor`): the run **fails** with the device's message, said in the run's history and in the failure - notification; `data.reason` (`scheduled_off`, `folder`, `plan`, `permission`) lets the client say + notification; `data.reason` (`scheduled_off`, `folder`, `plan`, `permission`, and from spec 3.9.0 + `interactive_only` — the session's model is one, `interactive.md` §2) lets the client say what to change. Not retried. ### Monitor mode: a command watched on the device @@ -959,7 +964,9 @@ Besides `/v1/models`, the chat completions, `/api/v1/instance` and `/mcp`: model is the library's: logging in (or in again) sets config.yaml's `embedding:` to the first one as `/` when no `embedding:` is set, and never replaces one that is; `embedding: ` also finds it. Voice uses the instance's own speech endpoints, not these - entries. Any other kind is ignored. + entries. Any other kind is ignored. An entry may carry **`interactive_only: true`** (spec + 3.9.0, `interactive.md`; sent only when true): a model for a person's own turns only — the + device sends it no scheduled work and sends a session's background calls elsewhere. - **`GET /api/v1/instance`** (the `models` scope) → `{ service, version, name, connection, account: { email, name }, scope, default_model, services }`. **`scope`** is what the token presented may do, space-separated, as its login granted it diff --git a/harness/conformance/interactive.json b/harness/conformance/interactive.json new file mode 100644 index 0000000..3c6abba --- /dev/null +++ b/harness/conformance/interactive.json @@ -0,0 +1,331 @@ +{ + "about": "Spec 3.9.0 (interactive.md): interactive-only models. `models`: the served models in the list's order, each `{id, interactive_only?}` (absent: false). `kind: twin` — `model` → the id of the same model on a connection that is not interactive-only (another id with the same part after its first `/`, the first in order), or null. `kind: background` — where a background call that would use `model` goes. `call`: `title`, `compaction` (the person asked) or `auto_compaction`; `defaults`: the defaults to try after the twin, in order (a device: its global `model` setting, then the instance's default; the server: the instance's default) — one that is not listed or is interactive-only is passed over. → `{model}` (the model asked: itself, the twin or a default), `{skip: true}`, or `{refused}` with loop.json interactive.texts.compact. `kind: scheduled` — scheduled work on `model` (a run's session, its subagent, a one-shot run with nobody at it): → `{run: true}`, or `{refused}` with interactive.texts.scheduled, `{{model}}` the id. The server's twin also has to be one the person may use in the chat's data group, which no case here turns on. CLI: src/provider/interactive.ts; LLeMbas: services/interactive.py.", + "cases": [ + { + "about": "The plan's pay-as-you-go twin: the same model under another provider.", + "kind": "twin", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "payg/qwen3-coder" + }, + { + "id": "deepseek/deepseek-flash" + } + ], + "expect": "payg/qwen3-coder" + }, + { + "about": "No other provider serves it.", + "kind": "twin", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "deepseek/deepseek-flash" + } + ], + "expect": null + }, + { + "about": "A twin that is itself interactive-only is none.", + "kind": "twin", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "other-plan/qwen3-coder", + "interactive_only": true + } + ], + "expect": null + }, + { + "about": "The part after the first slash is compared whole: a longer name is another model.", + "kind": "twin", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "payg/qwen3-coder-plus" + }, + { + "id": "payg/org/qwen3-coder" + } + ], + "expect": null + }, + { + "about": "The first in the list's order.", + "kind": "twin", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "b/qwen3-coder" + }, + { + "id": "a/qwen3-coder" + } + ], + "expect": "b/qwen3-coder" + }, + { + "about": "A model that is not interactive-only is asked itself, as before.", + "kind": "background", + "call": "title", + "model": "deepseek/deepseek-flash", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "payg/qwen3-coder" + }, + { + "id": "deepseek/deepseek-flash" + } + ], + "defaults": [ + "payg/qwen3-coder" + ], + "expect": { + "model": "deepseek/deepseek-flash" + } + }, + { + "about": "A title for a session on a plan's model goes to the twin.", + "kind": "background", + "call": "title", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "payg/qwen3-coder" + }, + { + "id": "deepseek/deepseek-flash" + } + ], + "defaults": [ + "deepseek/deepseek-flash" + ], + "expect": { + "model": "payg/qwen3-coder" + } + }, + { + "about": "No twin: the default that is not interactive-only.", + "kind": "background", + "call": "compaction", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "deepseek/deepseek-flash" + } + ], + "defaults": [ + "deepseek/deepseek-flash" + ], + "expect": { + "model": "deepseek/deepseek-flash" + } + }, + { + "about": "The first default is interactive-only too, the second is not.", + "kind": "background", + "call": "auto_compaction", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "plan/qwen3-max", + "interactive_only": true + }, + { + "id": "deepseek/deepseek-flash" + } + ], + "defaults": [ + "plan/qwen3-max", + "deepseek/deepseek-flash" + ], + "expect": { + "model": "deepseek/deepseek-flash" + } + }, + { + "about": "A default the list does not have is passed over.", + "kind": "background", + "call": "title", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "plan/qwen3-max", + "interactive_only": true + } + ], + "defaults": [ + "gone/model" + ], + "expect": { + "skip": true + } + }, + { + "about": "Nowhere to go: a title is skipped.", + "kind": "background", + "call": "title", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "plan/qwen3-max", + "interactive_only": true + } + ], + "defaults": [ + "plan/qwen3-max" + ], + "expect": { + "skip": true + } + }, + { + "about": "Nowhere to go: compaction the person asked for is refused in words.", + "kind": "background", + "call": "compaction", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "plan/qwen3-max", + "interactive_only": true + } + ], + "defaults": [ + "plan/qwen3-coder" + ], + "expect": { + "refused": "This chat's model is on a connection for interactive use only, and compacting is background work its provider's terms do not allow. It needs the same model on a pay-as-you-go connection, or a default model that is not interactive-only." + } + }, + { + "about": "Nowhere to go: automatic compaction is skipped and the turn goes on.", + "kind": "background", + "call": "auto_compaction", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "plan/qwen3-max", + "interactive_only": true + } + ], + "defaults": [], + "expect": { + "skip": true + } + }, + { + "about": "A scheduled run on a pay-as-you-go model.", + "kind": "scheduled", + "model": "payg/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "payg/qwen3-coder" + }, + { + "id": "deepseek/deepseek-flash" + } + ], + "expect": { + "run": true + } + }, + { + "about": "A scheduled run whose model is interactive-only fails with the sentence — never quietly on its twin.", + "kind": "scheduled", + "model": "plan/qwen3-coder", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "payg/qwen3-coder" + }, + { + "id": "deepseek/deepseek-flash" + } + ], + "expect": { + "refused": "plan/qwen3-coder is on a connection for interactive use only: its provider's terms do not allow scheduled or background work. Choose a model on a pay-as-you-go connection." + } + }, + { + "about": "A model the list does not have is not known to be one.", + "kind": "scheduled", + "model": "new/model", + "models": [ + { + "id": "plan/qwen3-coder", + "interactive_only": true + }, + { + "id": "payg/qwen3-coder" + }, + { + "id": "deepseek/deepseek-flash" + } + ], + "expect": { + "run": true + } + } + ] +} diff --git a/harness/conformance/last_model.json b/harness/conformance/last_model.json index 8e0a3b0..cdab8ef 100644 --- a/harness/conformance/last_model.json +++ b/harness/conformance/last_model.json @@ -1,5 +1,5 @@ { - "about": "Spec 3.9.0 (acp.md *The model last used in a directory*; *Scheduled work*, *The run's model*). Three kinds. `kind: start` — the device: which model a session of its own starts on. `asked`: the model asked for at the start (--model; model / lembas_model in session/new); `project`: `model` in a trusted project's configuration; `directory`: the model remembered for exactly this directory; `global`: `model` in the device's global configuration; `served`: the ids the login serves now; `default`: the instance's default. → `{model, from}`, `from` one of `asked`, `project`, `directory`, `global`, `default`. Only the directory's model is checked against `served` and skipped when it is not there; the others are taken as written (a model nobody serves is that source's own error, as before). `kind: record` — the device: whether something makes the session's model the directory's. `session`: `terminal`, `link` (a session the client opened, or a terminal's shared one), `stdio`, `run` (one-shot lembas run) or `scheduled` (a session a schedule opened for its run); `agent`: `main` or `subagent`; `what`: `turn` (a turn begins; `machine: true` when the harness started it), `change` (the person changes the session's model: /model, a setting, _lembas/configure) or `command` (a command's own model, for its prompt). → true or false. `kind: client` — the client (LLeMbas): the model a new agent chat on a device and directory, or a schedule's run there, starts on. `named`: the model the person chose for the chat, or the schedule names (absent: none); `directory`: `model` of the directory in the device's _lembas/directories answer (absent: none, an older device, or a device not asked); `has`: the models the person has now; `default`: what a chat or schedule without a model started on before 3.9.0. → `{model, from}`, `from` one of `named`, `directory`, `default`. CLI: src/session/lastmodel.ts.", + "about": "Spec 3.9.0 (acp.md *The model last used in a directory*; *Scheduled work*, *The run's model*). Three kinds. `kind: start` — the device: which model a session of its own starts on. `asked`: the model asked for at the start (--model; model / lembas_model in session/new); `project`: `model` in a trusted project's configuration; `directory`: the model remembered for exactly this directory; `global`: `model` in the device's global configuration; `served`: the ids the login serves now; `default`: the instance's default. → `{model, from}`, `from` one of `asked`, `project`, `directory`, `global`, `default`. Only the directory's model is checked against `served` and skipped when it is not there; the others are taken as written (a model nobody serves is that source's own error, as before). `kind: record` — the device: whether something makes the session's model the directory's. `session`: `terminal`, `link` (a session the client opened, or a terminal's shared one), `stdio`, `run` (one-shot lembas run) or `scheduled` (a session a schedule opened for its run); `agent`: `main` or `subagent`; `what`: `turn` (a turn begins; `machine: true` when the harness started it), `change` (the person changes the session's model: /model, a setting, _lembas/configure) or `command` (a command's own model, for its prompt). → true or false. `kind: client` — the client (LLeMbas): the model a new agent chat on a device and directory, or a schedule's run there, starts on. `named`: the model the person chose for the chat, or the schedule names (absent: none); `directory`: `model` of the directory in the device's _lembas/directories answer (absent: none, an older device, or a device not asked); `has`: the models the person has now; `default`: what a chat or schedule without a model started on before 3.9.0. `scheduled: true`: it is a schedule's run, for which the directory's model counts only when it is not one of `interactive_only` (interactive.md §2; a person's chat may start on such a model). → `{model, from}`, `from` one of `named`, `directory`, `default`. CLI: src/session/lastmodel.ts.", "cases": [ { "about": "Nothing but the instance's default.", @@ -307,6 +307,55 @@ "model": "deepseek/deepseek-flash", "from": "default" } + }, + { + "about": "A schedule's run: an interactive-only model remembered for the directory does not count.", + "kind": "client", + "scheduled": true, + "directory": "plan/qwen3-coder", + "has": [ + "plan/qwen3-coder", + "deepseek/deepseek-flash" + ], + "interactive_only": [ + "plan/qwen3-coder" + ], + "default": "deepseek/deepseek-flash", + "expect": { + "model": "deepseek/deepseek-flash", + "from": "default" + } + }, + { + "about": "…while a person's new chat there starts on it: that is interactive.", + "kind": "client", + "directory": "plan/qwen3-coder", + "has": [ + "plan/qwen3-coder", + "deepseek/deepseek-flash" + ], + "interactive_only": [ + "plan/qwen3-coder" + ], + "default": "deepseek/deepseek-flash", + "expect": { + "model": "plan/qwen3-coder", + "from": "directory" + } + }, + { + "about": "The device, for a scheduled session opened with no model: the same skip (`served` here is what the login serves that scheduled work may use).", + "kind": "start", + "directory": "plan/qwen3-coder", + "global": "deepseek/deepseek-flash", + "served": [ + "deepseek/deepseek-flash" + ], + "default": "deepseek/deepseek-flash", + "expect": { + "model": "deepseek/deepseek-flash", + "from": "global" + } } ] } diff --git a/harness/interactive.md b/harness/interactive.md new file mode 100644 index 0000000..62904e1 --- /dev/null +++ b/harness/interactive.md @@ -0,0 +1,82 @@ +# Interactive-only models + +Spec 3.9.0. **Some models may be used for a person's own turns and for nothing else.** A +provider that sells a subscription for interactive use forbids automated services, batch scripts +and scheduled background jobs on it, and may suspend a key used for those. Whether a model is +one is the server's word — a property of the connection it is served through — and it says so +on the model: **`interactive_only: true`** (`models/schema.json`; in `/v1/models` and the model +objects of `/api/v2`, sent only when true). Nothing matches a name. + +The server enforces this for what it runs itself. A device talks to the server's `/v1`, and the +server cannot tell what a request there is *for* — so the rules below are every client's, and a +device's most of all. The field and the texts: `loop.json` `interactive`; the cases: +`conformance/interactive.json`. + +## 1. What is interactive, and what is not + +**Interactive** — and so allowed on such a model — is a turn a person started and everything +that turn starts: the reply, the tool calls inside it, a subagent or a team the person's session +starts (on the session's model, or one the person named), a turn woken by one of their notes +(`machine`), and a command the person runs that asks a model for an answer shown to them at +once (the CLI's commit-message draft). + +**Not interactive**, in two kinds: + +- **Scheduled work**: a schedule's run — on the server, or as an agent turn on a linked + computer — with its subagents and its fallbacks, which are the same run. And a **one-shot run + with nobody at it**: the CLI's `lembas run` when none of its standard input, output and error + is a terminal (a cron job, a pipeline), which is the batch script the terms name. +- **Background calls**: what a client asks a model on a session's behalf that is not the answer + to the person's turn — **naming the session** (its title) and **compacting it** (the summary, + asked for by the person or by the harness when the window fills). + +## 2. Scheduled work never runs on one + +- **A schedule may not be given one.** Wherever a schedule's model is chosen, an + interactive-only model is not offered, and one typed or sent is refused with + `interactive.texts.scheduled` (`{{model}}` the model as the person knows it). +- **A run whose model is one fails**, with that sentence, before anything is sent to the model — + never quietly on another model. (A model can become interactive-only after the schedule was + made.) For an Agentic schedule that names no model, the directory's model counts only when it + is not interactive-only (`conformance/last_model.json`, `kind: client` with `scheduled`). +- **On a linked computer** the device checks again, because it is the one that sends: a + scheduled `session/new` or `session/prompt` whose session's model is interactive-only is + refused — `-32602`, the sentence, `data: { reason: "interactive_only" }` — and the run fails + as any refused run does (`acp.md` *When the device is away, or refuses*). A scheduled + session opened with no model skips an interactive-only directory's model as it skips one no + longer served. During a scheduled turn the session's model cannot be changed to one, and a + subagent that would run on one is not started: the tool call answers the sentence, and the + run goes on without it. +- A one-shot run with nobody at it ends at once with the sentence, having sent nothing. + +A person writing into a run's chat afterwards is a person: that turn is interactive. + +## 3. Background calls go elsewhere + +When the model a background call would use is interactive-only, the call goes to the first of +(`kind: background`): + +1. **its twin** — the same model on a connection that is not interactive-only. Among served ids + (`provider/model`): another id with the same part after its first `/`, not interactive-only, + the first in the list's order (`kind: twin`). The server, which knows its connections, also + requires the twin to be one the person may use in the chat's data group; +2. **a default that is not interactive-only** — in order: on a device, its global `model` + setting, then the instance's default model; on the server, the instance's default model; +3. **nowhere**. Then: + +| The call | With nowhere to go | +|---|---| +| a title | skipped: the session keeps the name made from its first prompt | +| compaction the person asked for | refused in words: `interactive.texts.compact` | +| automatic compaction | skipped, and the turn goes on — a client may say so once; the person can switch model, or start anew | + +A call that goes elsewhere is otherwise the same call: the summary is asked for with the same +conversation and comes back into the same session, whose model does not change. A model that is +not interactive-only is asked itself, as before 3.9.0. The model a title is asked of is the +client's small model where it has one (the CLI's `small_model`), else the session's; the rule is +applied to whichever it is. + +## 4. What is outside this + +Embedding, speech and image models are not chat models and carry no such field. A device's +watch command (`_lembas/monitor`) asks no model. diff --git a/harness/loop.json b/harness/loop.json index 1d7672b..03e7adb 100644 --- a/harness/loop.json +++ b/harness/loop.json @@ -511,6 +511,20 @@ "summary_max": 300 } }, + "interactive": { + "about": "Spec 3.9.0 (interactive.md): models a provider allows for a person's own turns only. `field`: what a model's metadata says (models/schema.json; /v1/models and /api/v2 model objects, sent only when true). `texts.scheduled`: the refusal of scheduled work on one — a schedule given it, a run whose model is one, a scheduled subagent, a one-shot run with nobody at it — `{{model}}` the model as the person knows it. `texts.compact`: compaction asked for by the person with no twin and no usable default. `background`: the calls that are not the answer to a person's turn, and what each does with nowhere to go.", + "field": "interactive_only", + "reason": "interactive_only", + "texts": { + "scheduled": "{{model}} is on a connection for interactive use only: its provider's terms do not allow scheduled or background work. Choose a model on a pay-as-you-go connection.", + "compact": "This chat's model is on a connection for interactive use only, and compacting is background work its provider's terms do not allow. It needs the same model on a pay-as-you-go connection, or a default model that is not interactive-only." + }, + "background": { + "title": "skip", + "compaction": "refuse", + "auto_compaction": "skip" + } + }, "phone": { "about": "Spec 3.6.0 (phone.md): `phone_action`, carried out by the LLeMbas app on the person's phone and confirmed there. `capability` is what the app declares with each message it sends; `fields` what each action reads (anything else in a call is dropped before the phone sees it); `required` the fields each action needs (a list inside the list: any one of them); `check` the order the fields' values are checked in; `wait_seconds` how long a call waits for the phone's answer; `texts` what the model is told, `what` what a bad field should have been. conformance/phone.json.", "capability": "phone_actions", diff --git a/harness/models/schema.json b/harness/models/schema.json index 7442139..49fe319 100644 --- a/harness/models/schema.json +++ b/harness/models/schema.json @@ -18,6 +18,7 @@ "effort_style": { "enum": ["top", "kwargs", "both"], "description": "OpenAI Chat dialect: where the effort goes — top-level `reasoning_effort`, `chat_template_kwargs.reasoning_effort` (all llama.cpp reads), or both (the default)." }, "vision": { "type": "boolean", "description": "Takes images. Never sent images otherwise: most servers refuse the whole request." }, "html_pages": { "type": "boolean", "default": false, "description": "Spec 3.8.0 (pages.md): this model can write HTML pages — a complete, self-contained page in an `html-view` block of its reply. False by default; pages are offered only when this is true, the instance's switch is on and the chat's is." }, + "interactive_only": { "type": "boolean", "default": false, "description": "Spec 3.9.0 (interactive.md): the model is served through a connection its provider allows for a person's own turns only — a subscription whose terms forbid automated, batch and scheduled background use. The server's word, from the connection's type; sent only when true. A client does not offer it for a schedule, sends it no scheduled work, and sends a session's background calls (title, compaction) to its twin or a default instead." }, "tools": { "type": "boolean", "description": "Takes tool calls. false: it can only talk; never sent a tools array." }, "notes": { "type": "string", "maxLength": 300, "description": "What the model is good at, in a line: other models are told about it in the roster, for handing work over." }, "capacity": { diff --git a/src/harness.ts b/src/harness.ts index a8c1c1a..0038c94 100644 --- a/src/harness.ts +++ b/src/harness.ts @@ -124,6 +124,10 @@ export const LOOP: { wrap_up: { message: string } nudges: { max: number } parallel: { max: number } + /** Interactive-only models (spec 3.9.0, harness/interactive.md): the field, the reason of a + * refused scheduled request, the two sentences, and what each background call does with + * nowhere to go. */ + interactive: { field: string; reason: string; texts: { scheduled: string; compact: string }; background: Record<"title" | "compaction" | "auto_compaction", "skip" | "refuse"> } /** Background work (spec 2.0.0): the marks every note begins with, and the caps. */ jobs: { marks: { command: string; subagent: string; message: string; to_subagent: string } diff --git a/src/provider/interactive.ts b/src/provider/interactive.ts new file mode 100644 index 0000000..45176c3 --- /dev/null +++ b/src/provider/interactive.ts @@ -0,0 +1,42 @@ +// Interactive-only models (harness interactive.md, spec 3.9.0): a model its provider allows for a +// person's own turns and nothing else. The server says which (`interactive_only` on a served +// model); it cannot tell what a request to its /v1 is for, so what is scheduled or background +// work is decided here. Three small rules (conformance/interactive.json). +import { LOOP } from "../harness.ts" +import { fillPrompt } from "../prompt/fill.ts" + +export interface Listed { + id: string + interactive_only?: boolean +} + +const only = (model: string, models: readonly Listed[]): boolean => models.find((m) => m.id === model)?.interactive_only === true + +/** The same model on a connection that is not interactive-only: another served id with the same + * part after its first `/`, the first in the list's order. */ +export function twin(model: string, models: readonly Listed[]): string | undefined { + const cut = model.indexOf("/") + if (cut < 0) return undefined + const name = model.slice(cut + 1) + return models.find((m) => m.id !== model && m.interactive_only !== true && m.id.indexOf("/") >= 0 && m.id.slice(m.id.indexOf("/") + 1) === name)?.id +} + +export type BackgroundCall = "title" | "compaction" | "auto_compaction" + +/** Where a background call that would use `model` goes: the model itself when it is not + * interactive-only; else its twin; else the first default that is listed and is not; else + * nowhere — skipped (a title, automatic compaction) or refused in words (compaction asked for). */ +export function background(o: { model: string; models: readonly Listed[]; defaults?: readonly (string | undefined)[]; call: BackgroundCall }): { model: string } | { skip: true } | { refused: string } { + if (!only(o.model, o.models)) return { model: o.model } + const other = twin(o.model, o.models) ?? (o.defaults ?? []).find((d): d is string => Boolean(d) && o.models.some((m) => m.id === d) && !only(d!, o.models)) + if (other) return { model: other } + return LOOP.interactive.background[o.call] === "refuse" ? { refused: LOOP.interactive.texts.compact } : { skip: true } +} + +/** Why scheduled work may not use `model` — the spec's sentence — or undefined when it may. */ +export function scheduledRefusal(model: string, models: readonly Listed[], label = model): string | undefined { + return only(model, models) ? fillPrompt(LOOP.interactive.texts.scheduled, { model: label }) : undefined +} + +/** What `-32602` carries as `data.reason` for a scheduled request refused for it. */ +export const INTERACTIVE_REASON = LOOP.interactive.reason diff --git a/src/session/lastmodel.ts b/src/session/lastmodel.ts index 056a6d5..d9fec32 100644 --- a/src/session/lastmodel.ts +++ b/src/session/lastmodel.ts @@ -34,9 +34,11 @@ export function records(o: { session: SessionKind; agent: "main" | "subagent"; w /** The client's rule (LLeMbas applies it; kept here so both suites answer the same cases): the * model a new agent chat on a device and directory, or a schedule's run there, starts on. */ -export function clientModel(o: { named?: string; directory?: string; has: readonly string[]; default?: string }): { model: string | undefined; from: "named" | "directory" | "default" } { +export function clientModel(o: { named?: string; directory?: string; has: readonly string[]; default?: string; scheduled?: boolean; interactive_only?: readonly string[] }): { model: string | undefined; from: "named" | "directory" | "default" } { if (o.named) return { model: o.named, from: "named" } - if (o.directory && o.has.includes(o.directory)) return { model: o.directory, from: "directory" } + // A schedule's run never starts on an interactive-only model the directory remembers (interactive.md §2). + const usable = o.scheduled ? o.has.filter((m) => !(o.interactive_only ?? []).includes(m)) : o.has + if (o.directory && usable.includes(o.directory)) return { model: o.directory, from: "directory" } return { model: o.default, from: "default" } } diff --git a/tests/conformance.ts b/tests/conformance.ts index 1374a06..4ea2b36 100644 --- a/tests/conformance.ts +++ b/tests/conformance.ts @@ -39,6 +39,7 @@ import { fillPrompt as fillText } from "../src/prompt/fill.ts" import { isSilent, judgeCase, monitorHash, notifyInstruction, reportResult, reportTool, runLeaves, scheduledMode, stripSentinel } from "../src/acp/scheduled.ts" import { clientModel, records, startModel, type SessionKind } from "../src/session/lastmodel.ts" +import { background, scheduledRefusal, twin, type BackgroundCall, type Listed } from "../src/provider/interactive.ts" type Case = Record @@ -60,9 +61,20 @@ export const AREAS: Record unknown> = { const str = (k: string) => (typeof c[k] === "string" ? (c[k] as string) : undefined) if (c.kind === "start") return startModel({ asked: str("asked"), project: str("project"), directory: str("directory"), global: str("global"), served: c.served as string[], default: str("default") }) if (c.kind === "record") return records({ session: c.session as SessionKind, agent: c.agent as "main" | "subagent", what: c.what as "turn" | "change" | "command", machine: c.machine === true }) - if (c.kind === "client") return clientModel({ named: str("named"), directory: str("directory"), has: c.has as string[], default: str("default") }) + if (c.kind === "client") return clientModel({ named: str("named"), directory: str("directory"), has: c.has as string[], default: str("default"), scheduled: c.scheduled === true, interactive_only: c.interactive_only as string[] | undefined }) throw new Error(`last_model: unknown kind ${String(c.kind)}`) }, + // Spec 3.9.0: interactive-only models (src/provider/interactive.ts). + interactive: (c) => { + const models = c.models as Listed[] + if (c.kind === "twin") return twin(c.model as string, models) ?? null + if (c.kind === "background") return background({ model: c.model as string, models, defaults: c.defaults as string[], call: c.call as BackgroundCall }) + if (c.kind === "scheduled") { + const refused = scheduledRefusal(c.model as string, models) + return refused ? { refused } : { run: true } + } + throw new Error(`interactive: unknown kind ${String(c.kind)}`) + }, // Spec 3.5.0: scheduled work on a linked computer (src/acp/scheduled.ts). scheduled: (c) => scheduledMode({ accept: c.accept === true, mode: c.mode, max_mode: c.max_mode as Mode, approval_wait_s: c.approval_wait_s }), silent: (c) => ({ silent: isSilent(c.text as string), stripped: stripSentinel(c.text as string) }),