@qvac/harness 1.0.0-rc.19 → 1.0.0-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +106 -2
  2. package/README.md +7 -0
  3. package/dist-lib/lib/capabilities/agent-ports.js +4 -3
  4. package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +1 -0
  5. package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +3 -1
  6. package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +5 -4
  7. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +5 -1
  8. package/dist-lib/lib/capabilities/completion-engine/driver.js +9 -2
  9. package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +3 -1
  10. package/dist-lib/lib/capabilities/sdk-tool.d.ts +2 -2
  11. package/dist-lib/lib/capabilities/sdk-tool.js +2 -2
  12. package/dist-lib/lib/capabilities/tool-turns.d.ts +1 -0
  13. package/dist-lib/lib/capabilities/tool-turns.js +2 -0
  14. package/dist-lib/lib/contract/agent.d.ts +2 -0
  15. package/dist-lib/lib/contract/media.d.ts +7 -0
  16. package/dist-lib/lib/helpers/run-outcome.d.ts +2 -0
  17. package/dist-lib/lib/helpers/run-outcome.js +6 -2
  18. package/dist-lib/lib/machine/completion/types.d.ts +1 -0
  19. package/dist-lib/lib/machine/index.d.ts +2 -0
  20. package/dist-lib/lib/machine/index.js +2 -0
  21. package/dist-lib/lib/media-wire.js +16 -1
  22. package/dist-lib/lib/models/context-choice.js +8 -1
  23. package/dist-lib/lib/models/llm-presets.js +27 -1
  24. package/dist-lib/lib/models/model-catalog-constants.d.ts +2 -2
  25. package/dist-lib/lib/models/model-catalog-constants.js +3 -4
  26. package/dist-lib/lib/models/model-catalog.d.ts +4 -2
  27. package/dist-lib/lib/models/model-catalog.js +29 -11
  28. package/dist-lib/lib/models/tts-model-default.d.ts +2 -1
  29. package/dist-lib/lib/models/tts-model-default.js +8 -6
  30. package/dist-lib/lib/plugins/registry.d.ts +1 -0
  31. package/dist-lib/lib/plugins/registry.js +7 -4
  32. package/dist-lib/lib/prompt.d.ts +5 -4
  33. package/dist-lib/lib/prompt.js +68 -22
  34. package/dist-lib/lib/residency/completion-runtime.js +6 -1
  35. package/dist-lib/lib/residency/index.js +1 -0
  36. package/dist-lib/lib/tools/files/edit-file.d.ts +4 -1
  37. package/dist-lib/lib/tools/files/edit-file.js +220 -28
  38. package/dist-lib/lib/tools/files/index.js +3 -1
  39. package/dist-lib/lib/tools/fs/edit-match.d.ts +22 -0
  40. package/dist-lib/lib/tools/fs/edit-match.js +337 -45
  41. package/dist-lib/plugins/coding-guards/index.d.ts +25 -0
  42. package/dist-lib/plugins/coding-guards/index.js +126 -0
  43. package/dist-lib/plugins/image/edit-image.d.ts +3 -22
  44. package/dist-lib/plugins/image/edit-image.js +13 -32
  45. package/dist-lib/plugins/image/fit.d.ts +31 -0
  46. package/dist-lib/plugins/image/fit.js +28 -0
  47. package/dist-lib/plugins/image/generate-image.d.ts +9 -2
  48. package/dist-lib/plugins/image/generate-image.js +23 -6
  49. package/dist-lib/plugins/image/index.js +4 -1
  50. package/dist-lib/plugins/ocr/index.d.ts +1 -1
  51. package/dist-lib/plugins/ocr/index.js +3 -1
  52. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  53. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  54. package/dist-lib/plugins/speech/speech-engine.d.ts +1 -1
  55. package/dist-lib/plugins/speech/speech-engine.js +10 -5
  56. package/dist-lib/plugins/speech/speech-text.d.ts +1 -0
  57. package/dist-lib/plugins/speech/speech-text.js +9 -4
  58. package/dist-lib/plugins/speech/voice.js +7 -2
  59. package/package.json +5 -1
package/CHANGELOG.md CHANGED
@@ -27,8 +27,11 @@ breaking change is listed under Changed and Removed.
27
27
  answers through `serveMediaRound(request, io)`; parsing, attaching and
28
28
  progress stay with the run. A host without the model refuses with
29
29
  `MEDIA_MODEL_MISSING` and downloads nothing, so the caller can ask another
30
- device. It crosses the sidecar and worker wire as model rounds do. See
31
- [docs/hosting.md](docs/hosting.md). (#845, #849)
30
+ device. It crosses the sidecar and worker wire as model rounds do. An
31
+ `edit_image` round names its sources in `request.sources` (attachment id or
32
+ turn-image file, with the fitted size), so the serving device can read the
33
+ original and fit it itself. See [docs/hosting.md](docs/hosting.md).
34
+ (#845, #849, #866)
32
35
 
33
36
  ```js
34
37
  owner.completion({ ...run, mediaRound: (request, io) => host.serveMediaRound(request, io) })
@@ -80,6 +83,18 @@ breaking change is listed under Changed and Removed.
80
83
  [the decision record](docs/decisions/2026-11-03-a-scanned-pdf-page-is-read-by-ocr.md).
81
84
  (#768)
82
85
 
86
+ - Kwaipilot's KAT-Coder-V2.5-Dev (`Kwaipilot_KAT-Coder-V2.5-Dev-Q4_K_M`, 21.4 GB) is in the LLM catalog:
87
+ a coding tune of the Qwen3.6-35B-A3B architecture, text only, `xhigh`, with the `qwen35` tool
88
+ dialect. It and gpt-oss sample as their makers recommend: KAT-Coder at temp 1.0, top_p 0.95 and
89
+ top_k 20; gpt-oss at temp 1.0 and top_p 1.0. A run's own sampling still wins. (#717)
90
+
91
+ - The `coding-guards` plugin, for a coding model that loops on whole-file
92
+ writes or works where nothing can run. Each guard is off until its option is
93
+ set: `sameWrite` refuses a `write_file` of the content the run last wrote to
94
+ that file, until another tool changes it; `promptNote` adds a note to every
95
+ prompt; `noRunner` tells every prompt that nothing can be built, run or
96
+ tested here. (#691, #717)
97
+
83
98
  - `isLoading` covers image and music models, and a reply waiting for room. An
84
99
  image or music row reads `true` from the request, through any wait for a
85
100
  download or for room, until the model is resident or the load fails, and the
@@ -105,6 +120,34 @@ breaking change is listed under Changed and Removed.
105
120
  the mcp, web-search and weather plugins. `isDeviceSharedCredentialKey` from
106
121
  `@qvac/harness/skill-state` names the first-party plugins' device-shared
107
122
  credential keys for a client that has no skill readiness to read them from.
123
+ - `wording.toolRepeatedFailure` sets the note on a call answered from its own
124
+ earlier failure (`RunPolicy.repeatedFailureMessage`).
125
+ - `wording.guidelines` rewords a system-prompt guideline by its id, or drops it
126
+ with `false`; `skills-list` is the header of the skills list. A deferred
127
+ tool's description carries the same wording (`GuidelineWording`).
128
+ - `insert_text` and `edit_many` are default tools in the files toolset, available
129
+ with a writable folder grant; `edit_file` is unchanged. No `toolConfigs` entry
130
+ is needed. Both remain subject to file permissions, the Files switch, and
131
+ approval. `insert_text` adds lines `after` a line number from `read_file`
132
+ whose text matches `expect`, with `after: 0` the start and `after: "end"` the
133
+ end. `edit_many` takes a list of `{ old, new }` replacements, all resolved
134
+ against the file as read and applied together or not at all, with one
135
+ approval whose `quote` lists every change. Both reply
136
+ `{ edited, changes }` with a unified diff in `data.diff`. See the
137
+ [decision record](docs/decisions/2026-10-22-edit-file-inserts-at-a-checked-line.md).
138
+
139
+ ```js
140
+ insert_text({ path: '.gitignore', insert: 'todo.md', after: 'end' })
141
+ insert_text({ path: 'notes.md', insert: '- three', after: 3, expect: '- two' })
142
+ edit_many({
143
+ path: 'notes.md',
144
+ edits: [
145
+ { old: '- one', new: '- 1' },
146
+ { old: '- two', new: '- 2' }
147
+ ]
148
+ })
149
+ ```
150
+
108
151
  - `CompletionContext.modelRound` sends each `generating` and
109
152
  `wrapping` model round to another device. It gets the request the local
110
153
  round would send and streams `content` and `thinking` back through `emit`;
@@ -520,6 +563,33 @@ breaking change is listed under Changed and Removed.
520
563
 
521
564
  ### Changed
522
565
 
566
+ - **Breaking:** speech defaults to Audio8. A `speak` or `speakStream` that
567
+ names no model loads `Audio8-Q8_0` on every device profile, where it loaded
568
+ Supertonic 3. Audio8 is 1.05 GB with its codec decoder (Supertonic was 85 MB
569
+ on phones and 207 MB on desktops) and speaks the language the text is
570
+ written in. `defaultTtsModelName`, `infraModelsFor` and `TTS_MODEL_NAMES`
571
+ answer Audio8, so a host that prefetches them downloads it once.
572
+ `new Speech({ tts: 'supertonic' })` keeps Supertonic, at the quant the
573
+ device profile carries.
574
+
575
+ On macOS and iOS the SDK downloads a Core ML bundle with the Audio8 codec
576
+ decoder and the Parakeet encoder and runs those stages on it. On an M2 Max
577
+ Audio8 speaks 9.8 s of audio in 2.7 s, and Supertonic FP16 speaks 8.4 s in
578
+ 1.6 s. See
579
+ [the decision](docs/decisions/2026-11-09-audio8-is-the-default-voice.md).
580
+ (#853)
581
+
582
+ ```js
583
+ import { defaultTtsModelName } from '@qvac/harness/model-defaults'
584
+
585
+ defaultTtsModelName('mid') // 'Audio8-Q8_0', was 'Supertonic3-FP16'
586
+
587
+ // before: Supertonic unless the host asked for MOSS
588
+ new Speech()
589
+ // after: the same voice as before
590
+ new Speech({ tts: 'supertonic' })
591
+ ```
592
+
523
593
  - **Breaking:** `@qvac/harness` no longer depends on `@qvac/skills`; the host
524
594
  installs the skills version it ships and hands it in.
525
595
  `Tools.bundledSkillsDir(bundle)` takes `{ skills, hash }` (what
@@ -1188,6 +1258,19 @@ breaking change is listed under Changed and Removed.
1188
1258
 
1189
1259
  ### Removed
1190
1260
 
1261
+ - **Breaking:** `Qwen3.6-27B-UD-Q4_K_XL` leaves the curated catalog, and the
1262
+ `QWEN_36_27B` export with it. Qwen3.8-27B is the model the `xhigh` profile
1263
+ recommends. An agent saved on the old name still loads, through the
1264
+ registry, as an uncurated model: no projection and no capability gate.
1265
+ (#862)
1266
+
1267
+ ```js
1268
+ // before
1269
+ import { QWEN_36_27B } from '@qvac/harness/model-catalog'
1270
+ // after
1271
+ import { QWEN_38_27B } from '@qvac/harness/model-catalog'
1272
+ ```
1273
+
1191
1274
  - The eight file exports 1.0.0-rc.7 added for hosts:
1192
1275
  `./lib/tools/fs/drive.ts`, `remote.ts` and `remote-protocol.ts`, and
1193
1276
  `./lib/tools/skills/skill-state.ts`, `credential-slots.ts`,
@@ -1260,6 +1343,16 @@ breaking change is listed under Changed and Removed.
1260
1343
 
1261
1344
  ### Fixed
1262
1345
 
1346
+ - OCR loads in the harness sidecar. Since rc.16 the first OCR model load
1347
+ failed with `CANNOT_LOAD`, so a scanned PDF got no text on desktop. (#844)
1348
+ - `edit_file`, `insert_text` and `edit_many` write only what they change. A
1349
+ BOM stays first when lines go in at the start, and line endings outside an
1350
+ edit keep their CRLF or LF in a file that mixes both. A `new` with
1351
+ `read_file` row numbers loses them only when they are rows of
1352
+ `old`, so `2026| revenue` is written as sent. `expect` takes the pasted
1353
+ `N| ` prefix even when the line itself starts with one. A change to the
1354
+ final newline alone shows in the diff (``) and in
1355
+ the approval quote.
1263
1356
  - Two walkie-talkie machines in one process no longer miss each other. Started
1264
1357
  together they dialed each other at once, each could keep a different one of
1265
1358
  the two connections, and `teammate()` then never resolved: the agent-team
@@ -1385,6 +1478,13 @@ later` instead of a stowed harness failing to open with `ADDON_NOT_FOUND` for
1385
1478
  of escaped text (newlines, quotes) stays within the room instead of coming
1386
1479
  back at up to twice the budget while `truncated.keptChars` reported the
1387
1480
  budget, and a short field after it still fits.
1481
+
1482
+ - A plugin added before the harness has served any run joins the boot set, so a run it hooked
1483
+ resumes after a restart that adds it again. Before, every added plugin took a per-process
1484
+ revision, and a run interrupted mid-try, such as a benchmark try cut at its time limit, could
1485
+ never resume with the host's config plugins loaded. A plugin added after a run started, or
1486
+ reloaded, still fails closed. (#717)
1487
+
1388
1488
  - The last tool round pushes `WRAP_UP_NUDGE` (a host's `wording.wrapUp`), which asks for a
1389
1489
  plain-text answer, instead of the nudge that offers "the next tool": with the grammar off
1390
1490
  Qwen3.5-2B wrote that call as text and answered "I ran out of steps" (24 → 1 of 396 runs).
@@ -1415,6 +1515,10 @@ later` instead of a stowed harness failing to open with `ADDON_NOT_FOUND` for
1415
1515
  token on Qwen3.5-2B after a 12-turn chat). (#605)
1416
1516
  - A `skill` call that names a skill by its display name, in another case, or by
1417
1517
  the one tool it grants (`pptx`) loads that skill. (#528)
1518
+ - A call the model repeats after it failed now says it was not run again,
1519
+ instead of only repeating the failure. A run that stops on those repeats and
1520
+ whose wrap-up says nothing ends on `REPEATED_CALL_ANSWER` instead of "I ran
1521
+ out of steps", which invited the same loop.
1418
1522
  - On Node, the Python plugin finds pyodide and the vendored wheels without
1419
1523
  `import.meta.asset`: it resolves both with `import.meta.resolve`. (#535)
1420
1524
  - A skill's tools are reselected on the turn the skill loads, so a run
package/README.md CHANGED
@@ -100,6 +100,12 @@ Built-in tools read and edit files only inside folders you grant (`grantedDirs`,
100
100
  `grantedWriteDirs`), and never inside the app's own storage. They also read, edit and create Word,
101
101
  Excel, PowerPoint and PDF files on device, in TypeScript, with no Python and no cloud.
102
102
 
103
+ A writable folder also enables `insert_text` and `edit_many` by default. Use `insert_text` to add
104
+ lines after a checked line, or at the start or end; use `edit_many` for several replacements in
105
+ one file, matched against the original content and validated together before writing. Both ask
106
+ for approval. `edit_file` keeps its existing single-replacement interface. Disable the `files`
107
+ toolset to hide file tools, or pass `files: false` when composing `Tools.product`.
108
+
103
109
  ### Large tool sets, on demand
104
110
 
105
111
  Mark a tool `defer: true` and the model sees only its name, grouped under `group`, until it calls
@@ -302,6 +308,7 @@ itself.
302
308
  | [`WalkieTalkie`](plugins/walkie-talkie/README.md) | Two-way comms with agents and people on other machines, over Hyperswarm |
303
309
  | [`RunReport`](plugins/run-report/README.md) | A run as a flowchart played back step by step, with why; records through `hopLog`, not `plugins` |
304
310
  | [`CodingPlugin`](plugins/coding/README.md) | A shell that keeps its place, background jobs |
311
+ | [`CodingGuards`](plugins/coding-guards/README.md) | Stops a coding model rewriting files in a loop, and tells it when nothing here can run |
305
312
  | [`LspPlugin`](plugins/lsp/README.md) | Definitions, references, symbols and diagnostics from language servers |
306
313
  | [`McpPlugin`](plugins/mcp/README.md) | The tools of any HTTP MCP server |
307
314
  | [`CodeMode`](plugins/code-mode/README.md) | `run_code`: a script that calls the other tools |
@@ -4,11 +4,12 @@ import { resolveImplicitSkill, resolveSkillMention } from '../tools/skills/menti
4
4
  import { promptSkill } from './skill-entry.js';
5
5
  export const defaultAgentPorts = {
6
6
  generationParams: resolveLlmGenerationParams,
7
- systemPrompt: ({ bio, toolNames, skills, platform }) => systemPromptParts({
7
+ systemPrompt: ({ bio, toolNames, skills, platform, guidelines }) => systemPromptParts({
8
8
  bio,
9
9
  toolNames,
10
- skillsSection: skillsPromptSection(skills.map(promptSkill)),
11
- platform
10
+ skillsSection: skillsPromptSection(skills.map(promptSkill), guidelines),
11
+ platform,
12
+ guidelines
12
13
  }),
13
14
  mention: resolveSkillMention,
14
15
  implicitSkill: resolveImplicitSkill
@@ -36,6 +36,7 @@ export function toolContext({ deps, context, name }) {
36
36
  knowledge: args.knowledge,
37
37
  ocr: deps.services?.ocr,
38
38
  planMode: context.planMode,
39
+ runId: session.runId,
39
40
  spill: session.enabled.some((tool) => tool.name === 'read_file')
40
41
  ? runSpill(session.runId)
41
42
  : undefined,
@@ -80,7 +80,9 @@ async function prepare({ input, context, reconstruct, source, emit }) {
80
80
  const readySkills = skillCatalog.filter(skillInContext);
81
81
  const unreadySkills = skillCatalog.filter((skill) => !skillInContext(skill) && fixableInSkills(skill));
82
82
  const offered = offeredTools(allTools, model);
83
- const tools = deferTools ? offered.map(deferredForRun) : offered;
83
+ const tools = deferTools
84
+ ? offered.map((tool) => deferredForRun(tool, args.wording?.guidelines))
85
+ : offered;
84
86
  const resolved = Agent.resolve({
85
87
  agent,
86
88
  model,
@@ -1,7 +1,7 @@
1
1
  import { spliceFrom } from '../splice.js';
2
2
  import { directToolHistory } from '../turns.js';
3
3
  import { labelOf } from '../loop.js';
4
- import { toolResultHistoryEntry, toolResultTurn } from '../../tool-turns.js';
4
+ import { toolResultHistoryEntry, toolResultTurn, withHookContext } from '../../tool-turns.js';
5
5
  import { readFailureResult, storeFailureResult } from '../../../helpers/failure-result.js';
6
6
  import { reportFailure } from '../tool-execution.js';
7
7
  export const rejecting = async function rejecting({ emit, input: { session }, context }) {
@@ -16,7 +16,7 @@ export const rejecting = async function rejecting({ emit, input: { session }, co
16
16
  const outcome = rejected.repeat ??
17
17
  rejected.outcome ?? { kind: 'blocked', reason: 'Tool call was rejected' };
18
18
  const result = rejected.repeat
19
- ? refused
19
+ ? withHookContext(refused, context.policy.repeatedFailureMessage)
20
20
  : await reportFailure(session.pipeline, {
21
21
  runId: session.runId,
22
22
  callId: call.id,
@@ -45,11 +45,12 @@ export const rejecting = async function rejecting({ emit, input: { session }, co
45
45
  emit({ type: 'tool-result', name: call.name, result });
46
46
  }
47
47
  const turn = toolResultTurn(call.name, call.id, result);
48
+ const resultRef = rejected.repeat ? undefined : rejected.resultRef;
48
49
  const history = context.execution?.kind === 'direct'
49
50
  ? directToolHistory(context.history, {
50
51
  args: call.args,
51
52
  output: result,
52
- resultRef: rejected.resultRef,
53
+ resultRef,
53
54
  nudge: context.policy.continuationNudge
54
55
  })
55
56
  : [
@@ -58,7 +59,7 @@ export const rejecting = async function rejecting({ emit, input: { session }, co
58
59
  name: call.name,
59
60
  id: call.id,
60
61
  output: result,
61
- resultRef: rejected.resultRef
62
+ resultRef
62
63
  })
63
64
  ];
64
65
  const failed = rejected.outcome && rejected.outcome.kind !== 'denied' && !rejected.repeat
@@ -57,7 +57,11 @@ export const wrapUp = async function wrapUp({ emit, input: { sdk, args, session,
57
57
  replacedTypes: ['content', 'thinking']
58
58
  });
59
59
  }
60
- const fallbackResponse = degenerateAnswer(wrapOutcome(context), materializeCompletionHistory(context.history, context.failureResults), { ...previewFinishedRound(session.runOutcomes.snapshot()), delivered: context.delivered });
60
+ const fallbackResponse = degenerateAnswer(wrapOutcome(context), materializeCompletionHistory(context.history, context.failureResults), {
61
+ ...previewFinishedRound(session.runOutcomes.snapshot()),
62
+ delivered: context.delivered,
63
+ repeated: CompletionMachine.repeatsBlocked(context)
64
+ });
61
65
  return {
62
66
  contentText,
63
67
  thinkingText: '',
@@ -9,7 +9,7 @@ import { runEngine } from './engine.js';
9
9
  import { didDrainTimeOut, raceDrain } from '../../helpers/drain.js';
10
10
  import { RunLog } from '../../run-log/index.js';
11
11
  import { stableStringify } from '../../helpers/stable-stringify.js';
12
- import { checkGoal, checkMaxToolRounds, FILE_DELIVERED_NUDGE, GOAL_CONTINUATION_NUDGE, GOAL_STALLED_NUDGE, GOAL_ROUNDS, MAX_TOOL_ROUNDS, TOOL_CONTEXT_BOUNDARY_MESSAGE, TOOL_CONTINUATION_NUDGE, WRAP_UP_NUDGE, TOOL_CUT_OFF_MESSAGE, TOOL_DENIED_MESSAGE, TOOL_REPEATED_MESSAGE, TOOL_ROUND_CUT_MESSAGE, TOOL_UNCHANGED_MESSAGE } from '../tool-turns.js';
12
+ import { checkGoal, checkMaxToolRounds, FILE_DELIVERED_NUDGE, GOAL_CONTINUATION_NUDGE, GOAL_STALLED_NUDGE, GOAL_ROUNDS, MAX_TOOL_ROUNDS, TOOL_CONTEXT_BOUNDARY_MESSAGE, TOOL_CONTINUATION_NUDGE, WRAP_UP_NUDGE, TOOL_CUT_OFF_MESSAGE, TOOL_DENIED_MESSAGE, TOOL_REPEATED_FAILURE_MESSAGE, TOOL_REPEATED_MESSAGE, TOOL_ROUND_CUT_MESSAGE, TOOL_UNCHANGED_MESSAGE } from '../tool-turns.js';
13
13
  import { createSession } from './session.js';
14
14
  import { captureFacts } from './durable.js';
15
15
  import { completionPorts } from './ports.js';
@@ -364,6 +364,12 @@ function completionArgs(...parts) {
364
364
  }
365
365
  return { ...merged, model: own ?? merged.model, modelId, messages };
366
366
  }
367
+ function worded(ports, guidelines) {
368
+ if (!guidelines) {
369
+ return ports;
370
+ }
371
+ return { ...ports, systemPrompt: (input) => ports.systemPrompt({ ...input, guidelines }) };
372
+ }
367
373
  function runPolicy({ maxToolRounds, goal, wording }) {
368
374
  return {
369
375
  maxToolRounds: checkMaxToolRounds(goal?.rounds ?? maxToolRounds ?? (goal ? GOAL_ROUNDS : MAX_TOOL_ROUNDS)),
@@ -375,6 +381,7 @@ function runPolicy({ maxToolRounds, goal, wording }) {
375
381
  contextBoundaryMessage: wording?.toolContextBoundary ?? TOOL_CONTEXT_BOUNDARY_MESSAGE,
376
382
  roundCutMessage: wording?.toolRoundCut ?? TOOL_ROUND_CUT_MESSAGE,
377
383
  repeatedCallMessage: wording?.toolRepeated ?? TOOL_REPEATED_MESSAGE,
384
+ repeatedFailureMessage: wording?.toolRepeatedFailure ?? TOOL_REPEATED_FAILURE_MESSAGE,
378
385
  unchangedMessage: wording?.toolUnchanged ?? TOOL_UNCHANGED_MESSAGE,
379
386
  failingMessage: wording?.toolFailing,
380
387
  goalNudge: wording?.goalContinuation ?? GOAL_CONTINUATION_NUDGE,
@@ -560,7 +567,7 @@ export async function* driveCompletion(args, runtime, options) {
560
567
  runId,
561
568
  pipeline,
562
569
  outbound: options.outbound,
563
- agentPorts: options.agentPorts
570
+ agentPorts: worded(options.agentPorts, full.wording?.guidelines)
564
571
  });
565
572
  session.startedAt = openedBoot.metadata?.startedAt ?? openedBoot.firstSavedAt ?? now();
566
573
  if (openedBoot.metadata?.budget) {
@@ -1,7 +1,7 @@
1
1
  import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
2
2
  import type { RecoveryResolution } from '../../run-log/index.ts';
3
3
  import type { KnowledgeGrant } from '../../contract/knowledge.ts';
4
- import type { MediaRoundPort, ToolCallDisplay } from '../../contract/index.ts';
4
+ import type { GuidelineWording, MediaRoundPort, ToolCallDisplay } from '../../contract/index.ts';
5
5
  import type { AgentConfig, AccessPolicy, CompiledPolicy, CompletionEvent, ApproveFn, AskUserFn, AttachFn, DriveRoot, FetchAttachmentFn, LlmGenerationParams, Message, ProgressFn, ResponseFormat, RunBudget, RunGoal, RunInput, RoundModelLease, ShowImageFn, ToolDefinition, ToolExecuteContext } from '../../contract/index.ts';
6
6
  import type { CompletionSkillEntry } from '../skill-entry.ts';
7
7
  import type { ModelRoundPort } from './model-round.ts';
@@ -61,10 +61,12 @@ export interface CompletionArgs {
61
61
  toolRoundCut?: string;
62
62
  toolContextBoundary?: string;
63
63
  toolRepeated?: string;
64
+ toolRepeatedFailure?: string;
64
65
  toolUnchanged?: string;
65
66
  toolFailing?: string;
66
67
  goalContinuation?: string;
67
68
  goalStalled?: string;
69
+ guidelines?: GuidelineWording;
68
70
  };
69
71
  }
70
72
  export declare function labelOf(name: string, args: Record<string, unknown>, emoji: string | null): ToolCallDisplay;
@@ -1,8 +1,8 @@
1
1
  import type { Tool as SdkTool } from '@qvac/inference';
2
- import type { AgentSkill, CompletionHistoryEntry, Message, ToolDefinition } from '../contract/index.ts';
2
+ import type { AgentSkill, CompletionHistoryEntry, GuidelineWording, Message, ToolDefinition } from '../contract/index.ts';
3
3
  export declare const TOOL_SEARCH_TOOL_NAME: string;
4
4
  export declare function defers(tool: ToolDefinition): boolean;
5
- export declare function deferredForRun(tool: ToolDefinition): ToolDefinition;
5
+ export declare function deferredForRun(tool: ToolDefinition, wording?: GuidelineWording): ToolDefinition;
6
6
  export declare function toSdkTool(tool: ToolDefinition): SdkTool;
7
7
  export declare function toSdkTools(tools: readonly ToolDefinition[], callable?: ReadonlySet<string>): SdkTool[] | undefined;
8
8
  export declare function renderedTools(tools: SdkTool[] | undefined, history: readonly CompletionHistoryEntry[]): SdkTool[] | undefined;
@@ -72,12 +72,12 @@ function field(name, schema, required) {
72
72
  export function defers(tool) {
73
73
  return (tool.defer === true || tool.skillGated === true) && !tool.endsRun && !tool.callsTools;
74
74
  }
75
- export function deferredForRun(tool) {
75
+ export function deferredForRun(tool, wording = {}) {
76
76
  const deferred = { ...tool, defer: true };
77
77
  if (tool.name === Agent.SKILL_TOOL_NAME || !defers(deferred)) {
78
78
  return tool;
79
79
  }
80
- const lines = toolGuidelines(tool.name);
80
+ const lines = toolGuidelines(tool.name, wording);
81
81
  if (!lines.length) {
82
82
  return deferred;
83
83
  }
@@ -18,6 +18,7 @@ export declare const TOOL_CONTEXT_BOUNDARY_MESSAGE: string;
18
18
  export declare const TOOL_REPEATED_MESSAGE: string;
19
19
  export declare const TOOL_FAILING_MESSAGE: string;
20
20
  export declare const FAILURE_STREAK = 3;
21
+ export declare const TOOL_REPEATED_FAILURE_MESSAGE: string;
21
22
  export declare const TOOL_UNCHANGED_MESSAGE: string;
22
23
  export declare const GOAL_CONTINUATION_NUDGE: string;
23
24
  export declare const GOAL_STALLED_NUDGE: string;
@@ -40,6 +40,8 @@ export const TOOL_FAILING_MESSAGE = 'This call has failed {count} times in a row
40
40
  're-read the failing output and the requirements, work out what the failures have in common, ' +
41
41
  'and change your approach instead of patching the last error.';
42
42
  export const FAILURE_STREAK = 3;
43
+ export const TOOL_REPEATED_FAILURE_MESSAGE = 'You already made this exact call and it failed as shown; it was not run again. Do what the ' +
44
+ 'error says: change the arguments, use another tool, or answer the user.';
43
45
  export const TOOL_UNCHANGED_MESSAGE = 'This call returned the same result the last {count} times it ran. Running it again will ' +
44
46
  'not change it: use the result you have, try something else, or answer.';
45
47
  export const GOAL_CONTINUATION_NUDGE = '[The goal is not met yet. Keep working on it: call the next tool. Track the work with ' +
@@ -11,6 +11,7 @@ export interface AgentSkill {
11
11
  readonly tools: readonly string[];
12
12
  readonly cliValidator?: CliValidator;
13
13
  }
14
+ export type GuidelineWording = Readonly<Record<string, string | false>>;
14
15
  export interface SystemPromptParts {
15
16
  text: string;
16
17
  bioChars: number;
@@ -32,6 +33,7 @@ export interface AgentPorts<Skill extends AgentSkill = AgentSkill> {
32
33
  toolNames: readonly string[];
33
34
  skills: readonly Skill[];
34
35
  platform?: string | undefined;
36
+ guidelines?: GuidelineWording | undefined;
35
37
  }): SystemPromptParts;
36
38
  mention(text: string, skills: readonly Skill[]): Skill | null;
37
39
  implicitSkill(text: string, skills: readonly Skill[]): Skill | null;
@@ -6,6 +6,13 @@ export interface MediaRoundRequest {
6
6
  modelChoice?: string | undefined;
7
7
  params: Record<string, unknown>;
8
8
  images?: Uint8Array[] | undefined;
9
+ sources?: MediaSourceRef[] | undefined;
10
+ }
11
+ export interface MediaSourceRef {
12
+ attachmentId?: string | undefined;
13
+ path?: string | undefined;
14
+ width: number;
15
+ height: number;
9
16
  }
10
17
  export interface MediaTick {
11
18
  step: number;
@@ -2,6 +2,7 @@ import type { RunOutcome, ToolExecutionOutcome } from '../contract/index.ts';
2
2
  export type { RunOutcome };
3
3
  export declare const DEGENERATE_ANSWER_FALLBACK = "I couldn't complete that step and don't have a useful result to share.";
4
4
  export declare const ROUND_CAP_ANSWER = "I ran out of steps before I could finish that. Ask me to continue and I'll pick up where I left off.";
5
+ export declare const REPEATED_CALL_ANSWER = "I stopped because I kept repeating the same step without getting anywhere. Tell me more about what you want, or put it another way, and I'll try something else.";
5
6
  export declare const SEARCH_CAPPED_ANSWER = "I searched the web but couldn't find the answer in the results I got.";
6
7
  export declare const DELIVERED_ANSWER = "Your file is attached to the chat.";
7
8
  export declare const WRITE_RESULT_LEAD = "Here's what came back:";
@@ -10,6 +11,7 @@ export interface RunOutcomeFacts {
10
11
  readonly latestFailure: string | null;
11
12
  readonly confirmedWrites: ReadonlyArray<string>;
12
13
  readonly delivered?: boolean;
14
+ readonly repeated?: boolean;
13
15
  }
14
16
  export interface HistoryTurn {
15
17
  readonly role: string;
@@ -1,6 +1,7 @@
1
1
  import { isRecord } from '../guards.js';
2
2
  export const DEGENERATE_ANSWER_FALLBACK = "I couldn't complete that step and don't have a useful result to share.";
3
3
  export const ROUND_CAP_ANSWER = "I ran out of steps before I could finish that. Ask me to continue and I'll pick up where I left off.";
4
+ export const REPEATED_CALL_ANSWER = "I stopped because I kept repeating the same step without getting anywhere. Tell me more about what you want, or put it another way, and I'll try something else.";
4
5
  export const SEARCH_CAPPED_ANSWER = "I searched the web but couldn't find the answer in the results I got.";
5
6
  export const DELIVERED_ANSWER = 'Your file is attached to the chat.';
6
7
  export const WRITE_RESULT_LEAD = "Here's what came back:";
@@ -66,7 +67,7 @@ export function failureFromToolExecution(result, outcome) {
66
67
  return resultFailure(result);
67
68
  }
68
69
  export function degenerateAnswer(outcome, history, facts) {
69
- const rest = facts.latestFailure ?? cappedAnswer(outcome, history);
70
+ const rest = facts.latestFailure ?? cappedAnswer(outcome, history, facts.repeated === true);
70
71
  const lines = [
71
72
  writeReport(facts.confirmedWrites),
72
73
  facts.delivered ? DELIVERED_ANSWER : null,
@@ -74,7 +75,10 @@ export function degenerateAnswer(outcome, history, facts) {
74
75
  ].filter((line) => line !== null);
75
76
  return lines.length ? lines.join('\n\n') : DEGENERATE_ANSWER_FALLBACK;
76
77
  }
77
- function cappedAnswer(outcome, history) {
78
+ function cappedAnswer(outcome, history, repeated) {
79
+ if (outcome === 'exhausted' && repeated) {
80
+ return REPEATED_CALL_ANSWER;
81
+ }
78
82
  if (outcome === 'search-capped') {
79
83
  return searchCappedAnswer(history);
80
84
  }
@@ -270,6 +270,7 @@ export interface RunPolicy {
270
270
  contextBoundaryMessage: string;
271
271
  roundCutMessage: string;
272
272
  repeatedCallMessage: string;
273
+ repeatedFailureMessage: string;
273
274
  unchangedMessage: string;
274
275
  failingMessage?: string;
275
276
  goalNudge: string;
@@ -1,6 +1,7 @@
1
1
  import { goalStatus } from './completion/actions/completion.ts';
2
2
  import { emptyCompletionContext } from './completion/context.ts';
3
3
  import { atContextBoundary, cutOffMessage, cutShort, runsUnasked } from './completion/rules.ts';
4
+ import { repeatsBlocked } from './completion/guards/retry.ts';
4
5
  import { completionMachineDefinition, transitionName } from './definition.ts';
5
6
  export declare class CompletionMachine {
6
7
  static VERSION: number;
@@ -490,6 +491,7 @@ export declare class CompletionMachine {
490
491
  static cutOffMessage: typeof cutOffMessage;
491
492
  static cutShort: typeof cutShort;
492
493
  static atContextBoundary: typeof atContextBoundary;
494
+ static repeatsBlocked: typeof repeatsBlocked;
493
495
  static MAX_ROUND_CALLS: number;
494
496
  static MAX_SHOWN_IMAGES: number;
495
497
  static MAX_ROUND_REPEATS: number;
@@ -3,6 +3,7 @@ import { PLAN_MODE_REFUSAL } from './completion/actions/tools.js';
3
3
  import { emptyCompletionContext } from './completion/context.js';
4
4
  import { createCompletionMachine } from './completion/machine.js';
5
5
  import { atContextBoundary, cutOffMessage, cutShort, MAX_ROUND_CALLS, MAX_ROUND_REPEATS, MAX_SHOWN_IMAGES, runsUnasked } from './completion/rules.js';
6
+ import { repeatsBlocked } from './completion/guards/retry.js';
6
7
  import { MACHINE_VERSION } from './completion/version.js';
7
8
  import { completionMachineDefinition, transitionName } from './definition.js';
8
9
  export class CompletionMachine {
@@ -17,6 +18,7 @@ export class CompletionMachine {
17
18
  static cutOffMessage = cutOffMessage;
18
19
  static cutShort = cutShort;
19
20
  static atContextBoundary = atContextBoundary;
21
+ static repeatsBlocked = repeatsBlocked;
20
22
  static MAX_ROUND_CALLS = MAX_ROUND_CALLS;
21
23
  static MAX_SHOWN_IMAGES = MAX_SHOWN_IMAGES;
22
24
  static MAX_ROUND_REPEATS = MAX_ROUND_REPEATS;
@@ -25,9 +25,24 @@ export async function mediaRequestFrom(payload) {
25
25
  runId: String(payload.runId ?? ''),
26
26
  modelChoice: typeof payload.modelChoice === 'string' ? payload.modelChoice : undefined,
27
27
  params: isRecord(payload.params) ? payload.params : {},
28
- images: paths.length ? images : undefined
28
+ images: paths.length ? images : undefined,
29
+ sources: Array.isArray(payload.sources) ? payload.sources.flatMap(sourceRefFrom) : undefined
29
30
  };
30
31
  }
32
+ function sourceRefFrom(ref) {
33
+ if (!isRecord(ref) || typeof ref.width !== 'number' || typeof ref.height !== 'number') {
34
+ return [];
35
+ }
36
+ const name = (value) => (typeof value === 'string' ? value : undefined);
37
+ return [
38
+ {
39
+ attachmentId: name(ref.attachmentId),
40
+ path: name(ref.path),
41
+ width: ref.width,
42
+ height: ref.height
43
+ }
44
+ ];
45
+ }
31
46
  export async function mediaResultWire(result) {
32
47
  if ('error' in result) {
33
48
  return { result: { error: result.error, code: result.code } };
@@ -1,3 +1,4 @@
1
+ import { HarnessLog } from '../log.js';
1
2
  const RUNGS = [262_144, 131_072, 65_536];
2
3
  const CEILINGS = {
3
4
  mid: 65_536,
@@ -34,14 +35,18 @@ export class ContextChoice {
34
35
  return choice;
35
36
  }
36
37
  async _climb(tier, ask) {
37
- const ceiling = ContextChoice.ceiling(await this._profile());
38
+ const profile = await this._profile();
39
+ const ceiling = ContextChoice.ceiling(profile);
38
40
  if (!ceiling || ceiling <= tier) {
41
+ HarnessLog.info('context climb', { tier, profile: profile ?? null, stop: 'ceiling' });
39
42
  return tier;
40
43
  }
41
44
  const trained = await ask.trained();
42
45
  if (!trained) {
46
+ HarnessLog.info('context climb', { tier, ceiling, stop: 'trained-unknown' });
43
47
  return undefined;
44
48
  }
49
+ const tried = [];
45
50
  for (const rung of RUNGS) {
46
51
  if (rung > ceiling || rung > trained || rung <= tier) {
47
52
  continue;
@@ -49,7 +54,9 @@ export class ContextChoice {
49
54
  if (await ask.fits(rung)) {
50
55
  return rung;
51
56
  }
57
+ tried.push(rung);
52
58
  }
59
+ HarnessLog.info('context climb', { tier, ceiling, trained, tried, stop: 'no-fit' });
53
60
  return tier;
54
61
  }
55
62
  }
@@ -23,10 +23,31 @@ const QWEN_THINKING_GENERAL_SAMPLER = {
23
23
  repeat_penalty: 1.0,
24
24
  frequency_penalty: 0
25
25
  };
26
+ const KAT_CODER_SAMPLER = {
27
+ temp: 1.0,
28
+ top_p: 0.95,
29
+ top_k: 20,
30
+ presence_penalty: 0,
31
+ repeat_penalty: 1.0,
32
+ frequency_penalty: 0
33
+ };
34
+ const GPT_OSS_SAMPLER = {
35
+ temp: 1.0,
36
+ top_p: 1.0,
37
+ top_k: 0,
38
+ presence_penalty: 0,
39
+ repeat_penalty: 1.0,
40
+ frequency_penalty: 0
41
+ };
26
42
  const PRESET_RESOLVERS = [
27
43
  { prefix: 'Qwen3.5-0.8B-', resolve: qwen08BPreset },
28
44
  { prefix: 'Qwen3.5-2B-', resolve: qwen2BPreset },
29
- { prefix: 'Qwen3.5-4B-', resolve: qwen4BPreset }
45
+ { prefix: 'Qwen3.5-4B-', resolve: qwen4BPreset },
46
+ {
47
+ prefix: 'Kwaipilot_KAT-Coder-',
48
+ resolve: (reasoning) => withBudget(KAT_CODER_SAMPLER, reasoning)
49
+ },
50
+ { prefix: 'gpt-oss-', resolve: (reasoning) => withBudget(GPT_OSS_SAMPLER, reasoning) }
30
51
  ];
31
52
  export function resolveLlmGenerationParams(modelName, reasoningEnabled, deviceDefault) {
32
53
  const effective = reasoningEnabled ?? deviceDefault;
@@ -59,3 +80,8 @@ function thinkingVlPreset() {
59
80
  function thinkingGeneralPreset() {
60
81
  return { ...QWEN_THINKING_GENERAL_SAMPLER, reasoning_budget: DEFAULT_REASONING_BUDGET };
61
82
  }
83
+ function withBudget(sampler, reasoningEnabled) {
84
+ return reasoningEnabled === undefined
85
+ ? { ...sampler }
86
+ : { ...sampler, reasoning_budget: reasoningEnabled ? DEFAULT_REASONING_BUDGET : 0 };
87
+ }
@@ -3,9 +3,9 @@ export declare const CAPABILITY_PROFILE_ORDER: readonly CapabilityProfile[];
3
3
  export declare const QWEN_35_2B = "Qwen3.5-2B-Q4_K_M";
4
4
  export declare const QWEN_35_4B = "Qwen3.5-4B-Q4_K_M";
5
5
  export declare const QWEN_35_9B = "Qwen3.5-9B-Q4_K_M";
6
- export declare const QWEN_36_27B = "Qwen3.6-27B-UD-Q4_K_XL";
7
6
  export declare const QWEN_36_35B_A3B = "Qwen3.6-35B-A3B-UD-Q4_K_M";
8
7
  export declare const QWEN_38_27B = "Qwen3.8-27B-UD-Q4_K_XL";
8
+ export declare const KAT_CODER_25_35B = "Kwaipilot_KAT-Coder-V2.5-Dev-Q4_K_M";
9
9
  export declare const BONSAI_2_27B_PQ2 = "Ternary-Bonsai-2-27B-PQ2_0";
10
10
  export declare const BONSAI_2_27B_PTQ1 = "Ternary-Bonsai-2-27B-PTQ1_0";
11
11
  export declare const MEDPSY_1_7B = "medpsy-1.7b-q4_k_m-imat";
@@ -21,7 +21,7 @@ export interface HostCapability {
21
21
  export declare function isMobilePlatform(platform: string): boolean;
22
22
  export declare function runnableModelName(requested: string, host: HostCapability | null): string;
23
23
  export declare function capabilityProfileToModelName(profile: CapabilityProfile): string;
24
- export declare const AGENT_MODEL_NAMES: readonly ["Qwen3.5-2B-Q4_K_M", "Qwen3.5-4B-Q4_K_M", "Qwen3.5-9B-Q4_K_M", "Qwen3.6-27B-UD-Q4_K_XL", "Qwen3.6-35B-A3B-UD-Q4_K_M", "Qwen3.8-27B-UD-Q4_K_XL", "Ternary-Bonsai-2-27B-PQ2_0", "Ternary-Bonsai-2-27B-PTQ1_0", "medpsy-1.7b-q4_k_m-imat", "medpsy-4b-q4_k_m-imat"];
24
+ export declare const AGENT_MODEL_NAMES: readonly ["Qwen3.5-2B-Q4_K_M", "Qwen3.5-4B-Q4_K_M", "Qwen3.5-9B-Q4_K_M", "Qwen3.6-35B-A3B-UD-Q4_K_M", "Qwen3.8-27B-UD-Q4_K_XL", "Kwaipilot_KAT-Coder-V2.5-Dev-Q4_K_M", "Ternary-Bonsai-2-27B-PQ2_0", "Ternary-Bonsai-2-27B-PTQ1_0", "medpsy-1.7b-q4_k_m-imat", "medpsy-4b-q4_k_m-imat"];
25
25
  export declare function modelDisplayName(modelName: string): string;
26
26
  export declare function capabilityProfileModelLabel(profile: CapabilityProfile): string;
27
27
  export declare function isMultimodalLlm(modelName: string): boolean;