Files
buzz/desktop/src/features/agents/ui/agentConfigControls.test.mjs
Mic Neale 16d4ec335e feat(desktop): use collective mesh routing for Auto (#2825)
Uses MeshLLM built-in `mesh` collective intelligence / Mixture of Agents
when Buzz Auto sees two or more distinct physical models. With zero or
one model, Auto remains ordinary `auto`. This is an alternative way to
improve tool responses, accuracy, and resistance to hallucination when a
high-latency distributed mesh contains diverse models.

Models and members may come and go: collective routing enables only
after stable capacity, drops on confirmed contraction, and can recover
later. Mesh-specific failures retry once through ordinary Auto.

This update also pins MeshLLM to a v0.73.1-compatible backport of
[MeshLLM #1074](https://github.com/Mesh-LLM/mesh-llm/pull/1074), so
client-only Buzz nodes cannot enter model election or download a remote
provider model. Buzz preserves the selected local sharing model and
switches an existing client to sharing across a controlled app restart,
retaining one runtime and one `:9337` / `:3131` pair per machine.

Validation:
- Full local `just ci` passes on the cleaned branch.
- MeshLLM host-runtime suite: 1,568 passed, 0 failed; strict Clippy
passes.
- Buzz desktop Tauri suite with `mesh-llm`: 1,721 passed, 0 failed;
strict feature Clippy passes.
- Playwright covers client-to-share using the saved local model and no
destructive stop.
- Packaged two-machine testing proved single-model routing, dual-model
collective routing, tool-markup fallback, and runtime reuse.
- Packaged client-only recheck routed a real Mini Buzz turn through M5
while Mini stayed `is_client=true`, `is_host=false`, hosted no models,
and created no Gemma cache.

Builds on the recovery work merged in #2823; this PR does not duplicate
it.

---------

Signed-off-by: Michael Neale <michael.neale@gmail.com>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
Co-authored-by: Michael Neale <michael.neale@gmail.com>
Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz>
Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
2026-07-26 19:46:13 -04:00

118 lines
3.3 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import {
MODEL_NO_MODELS_VALUE,
appendNoModelsSentinel,
resolveDefaultModelLabel,
resolveModelFieldStatusMessage,
} from "./agentConfigControls.tsx";
test("uses the harness-discovered default model label for an unset model", () => {
assert.equal(
resolveDefaultModelLabel({
discoveredModelOptions: [
{ id: "", label: "Default model (claude-sonnet-5)" },
{ id: "claude-opus-4-8", label: "Claude Opus 4.8" },
],
isSharedCompute: false,
}),
"Default model (claude-sonnet-5)",
);
});
test("falls back to a generic harness default when discovery has no current model", () => {
assert.equal(
resolveDefaultModelLabel({
discoveredModelOptions: [{ id: "", label: "Default model" }],
isSharedCompute: false,
}),
"Default model",
);
});
test("an explicit inherited default label wins over harness discovery", () => {
assert.equal(
resolveDefaultModelLabel({
defaultModelLabel: "Default model (team-model)",
discoveredModelOptions: [
{ id: "", label: "Default model (claude-sonnet-5)" },
],
isSharedCompute: false,
}),
"Default model (team-model)",
);
});
test("shared compute describes Auto's collective behavior", () => {
assert.equal(
resolveDefaultModelLabel({
discoveredModelOptions: null,
isSharedCompute: true,
}),
"Auto (collective when available)",
);
});
// ── appendNoModelsSentinel ─────────────────────────────────────────────────────
test("appendNoModelsSentinel_emptyOptionsDiscoveryFinished_addsDisabledRow", () => {
const options = appendNoModelsSentinel([], false);
assert.equal(options.length, 1);
assert.equal(options[0].disabled, true);
assert.equal(options[0].label, "No models found");
assert.equal(options[0].value, MODEL_NO_MODELS_VALUE);
});
test("appendNoModelsSentinel_emptyOptionsDiscoveryLoading_doesNotAddRow", () => {
const options = appendNoModelsSentinel([], true);
assert.equal(options.length, 0);
});
test("appendNoModelsSentinel_nonEmptyOptionsDiscoveryFinished_doesNotAddRow", () => {
const options = appendNoModelsSentinel(
[{ label: "Default model", value: "" }],
false,
);
assert.equal(options.length, 1);
assert.equal(options[0].label, "Default model");
});
test("model status omits provider selection guidance before discovery", () => {
assert.equal(
resolveModelFieldStatusMessage({
discoveredModelOptions: null,
loading: false,
status: null,
}),
null,
);
});
test("model status preserves loading, discovery, and saved-state messages", () => {
assert.equal(
resolveModelFieldStatusMessage({
discoveredModelOptions: null,
loading: true,
status: null,
}),
"Loading models...",
);
assert.equal(
resolveModelFieldStatusMessage({
discoveredModelOptions: null,
loading: false,
status: { message: "Couldn't load models", tone: "warning" },
}),
"Couldn't load models",
);
assert.equal(
resolveModelFieldStatusMessage({
discoveredModelOptions: [],
loading: false,
status: null,
}),
"Saved changes take effect on the next start.",
);
});