Files
buzz/desktop/src/features/agents/ui/PersonaModelField.tsx
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

117 lines
3.5 KiB
TypeScript

import type * as React from "react";
import { motion } from "motion/react";
import { cn } from "@/shared/lib/cn";
import { Input } from "@/shared/ui/input";
import { PersonaModelCombobox } from "./PersonaModelCombobox";
import type { PersonaModelDiscoveryStatus } from "./personaModelDiscoveryStatus";
import {
type PersonaDropdownOption,
PERSONA_FIELD_CONTROL_CLASS,
PERSONA_FIELD_SHELL_CLASS,
PERSONA_LABEL_OPTIONAL_CLASS,
} from "./agentConfigOptions";
type PersonaModelFieldProps = {
disabled: boolean;
isExplicitModelRequired: boolean;
model: string;
modelDiscoveryStatus: PersonaModelDiscoveryStatus | null;
modelDropdownOptions: readonly PersonaDropdownOption[];
showSharedComputeAutoHint: boolean;
modelSelectValue: string;
onCustomModelChange: (value: string) => void;
onModelValueChange: (value: string) => void;
showCustomModelInput: boolean;
transition: React.ComponentProps<typeof motion.div>["transition"];
};
export function PersonaModelField({
disabled,
isExplicitModelRequired,
model,
modelDiscoveryStatus,
modelDropdownOptions,
modelSelectValue,
showSharedComputeAutoHint,
onCustomModelChange,
onModelValueChange,
showCustomModelInput,
transition,
}: PersonaModelFieldProps) {
return (
<motion.div
animate={{ height: "auto", opacity: 1, scale: 1 }}
className="origin-top overflow-hidden"
exit={{ height: 0, opacity: 0, scale: 0.98 }}
initial={{ height: 0, opacity: 0, scale: 0.98 }}
key="persona-model-field"
transition={transition}
>
<div className="space-y-1.5">
<label
className="text-sm font-medium text-foreground"
htmlFor="persona-model"
>
Model
{!isExplicitModelRequired ? (
<span className={PERSONA_LABEL_OPTIONAL_CLASS}>Optional</span>
) : null}
</label>
<PersonaModelCombobox
disabled={disabled}
id="persona-model"
onValueChange={onModelValueChange}
options={modelDropdownOptions}
placeholder={
isExplicitModelRequired ? "Choose a model" : "Default model"
}
value={modelSelectValue}
/>
{showCustomModelInput ? (
<div
className={cn(
"mt-2 flex min-h-11 items-center px-3",
PERSONA_FIELD_SHELL_CLASS,
)}
>
<Input
aria-label="Custom model ID"
autoCorrect="off"
className={cn(
"h-8 px-0 py-0 leading-6",
PERSONA_FIELD_CONTROL_CLASS,
)}
disabled={disabled}
id="persona-custom-model"
onChange={(event) => onCustomModelChange(event.target.value)}
placeholder="Custom model ID"
value={model}
/>
</div>
) : null}
{showSharedComputeAutoHint ? (
<p className="text-xs text-muted-foreground">
Auto uses Mesh collective intelligence when two or more models stay
available, otherwise it chooses one available model.
</p>
) : null}
{modelDiscoveryStatus ? (
<p
aria-live="polite"
className={cn(
"text-xs",
modelDiscoveryStatus.tone === "warning"
? "text-warning"
: "text-muted-foreground",
)}
data-testid="persona-model-discovery-status"
>
{modelDiscoveryStatus.message}
</p>
) : null}
</div>
</motion.div>
);
}