Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Configure a default model for new Bots

klarkxy5f8d43ec71c3
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 24d0962b..2d6b7fd7 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -93,6 +93,9 @@ var ZH = {
"Delete group": "删除群聊",
"Open {name}'s chat": "打开 {name} 的对话",
"New Bot": "新 Bot",
+ "New Bots": "新 Bot",
+ "Default model": "默认模型",
+ "Applies to Bots made after this pick, when a create names no model. Existing Bots keep their own.": "只影响之后新建的 Bot;已有 Bot 的模型不变。",
// Sidebar and account menu
"Bot list": "Bot 列表",
"Setting up your Main Bot…": "正在设置你的主 Bot…",
@@ -11844,12 +11847,12 @@ function useAnchoredMenu() {
}, [anchor, tick]);
return { isOpen: place !== null, shownPlace, leaving, button, menu, open, close };
}
-function ModelMenu({ bot, roster, actions, run: run2, wide = false, onPick, onPickEffort }) {
+function ModelMenu({ bot, roster, actions, run: run2, wide = false, onPick, onPickEffort, withEfforts = true }) {
const { isOpen, shownPlace, leaving, button, menu, open, close } = useAnchoredMenu();
const shown = modelOf(bot, roster);
const current = bot.model ?? bot.appliedModel;
const served = servedOf(roster, current);
- const reasoning = useEfforts(served, current, actions);
+ const reasoning = useEfforts(served, withEfforts ? current : void 0, actions);
const picked = reasoning?.efforts?.some((effort) => effort.id === bot.effort) ? bot.effort : void 0;
const currentEffort = picked ?? reasoning?.defaultEffort;
const effortLabel = currentEffort === void 0 ? reasoning?.efforts?.length > 0 ? t("Default") : void 0 : reasoning.efforts.find((effort) => effort.id === currentEffort)?.name ?? currentEffort;
@@ -11893,7 +11896,7 @@ function ModelMenu({ bot, roster, actions, run: run2, wide = false, onPick, onPi
"span",
{ className: "bt-model-copy" },
(0, import_react25.createElement)("span", { className: "bt-model-name" }, shown?.name ?? t("Choose a model")),
- shown ? (0, import_react25.createElement)("span", { className: "bt-model-provider" }, shown.served || models.length === 0 ? effortLabel === void 0 ? shown.provider : `${shown.provider} · ${effortLabel}` : t("{provider} · not available", { provider: shown.provider })) : null
+ shown ? (0, import_react25.createElement)("span", { className: "bt-model-provider" }, shown.served || models.length === 0 ? !withEfforts || effortLabel === void 0 ? shown.provider : `${shown.provider} · ${effortLabel}` : t("{provider} · not available", { provider: shown.provider })) : null
),
(0, import_react25.createElement)(Caret)
),
@@ -11901,7 +11904,7 @@ function ModelMenu({ bot, roster, actions, run: run2, wide = false, onPick, onPi
"div",
{ ref: menu, className: `bt-menu bt-model-menu${shownPlace.bottom !== void 0 ? " bt-menu-up" : ""}`, role: "menu", "aria-label": t("Model for {name}", { name: bot.name }), style: shownPlace, "data-leaving": leaving || void 0 },
models.length > 0 ? (0, import_react25.createElement)(ModelRows, { roster, current, onPick: pick2 }) : (0, import_react25.createElement)("div", { className: "bt-model-none" }, t("No models are set up in DeepSeek Harness yet.")),
- effortRows(reasoning).length > 0 ? (0, import_react25.createElement)(EffortRows, { reasoning, current: picked, onPick: pickEffort }) : null,
+ withEfforts && effortRows(reasoning).length > 0 ? (0, import_react25.createElement)(EffortRows, { reasoning, current: picked, onPick: pickEffort }) : null,
manage ? (0, import_react25.createElement)("div", { className: "bt-menu-sep", role: "separator" }) : null,
manage ? (0, import_react25.createElement)("button", { type: "button", role: "menuitem", onClick: () => {
close();
@@ -13752,7 +13755,7 @@ function freshBotName(roster, base = "New Bot") {
}
function startModel(roster) {
const models = roster.models ?? [];
- return (models.find((model) => model.ref === roster.defaultModel) ?? models[0])?.ref ?? "";
+ return (models.find((model) => model.ref === roster.prefs?.defaultBotModel) ?? models.find((model) => model.ref === roster.defaultModel) ?? models[0])?.ref ?? "";
}
function createPayload({ name, look, image, model, effort, brief }) {
const payload = { name, color: look.color, avatar: image ? { shape: look.shape, image } : { shape: look.shape } };
@@ -16966,6 +16969,24 @@ function GeneralPage({ roster, actions, run: run2 }) {
(0, import_react45.createElement)(SetRow, { label: t("Bubble width") }, (0, import_react45.createElement)(WidthSlider, { label: t("Bubble width"), value: widthOf(prefs), save: (width) => run2(actions.setPrefs({ width })) })),
(0, import_react45.createElement)(SetRow, { label: t("Show thinking") }, (0, import_react45.createElement)(Switch, { label: t("Show thinking"), on: thinkingShown(prefs), onChange: (thinking) => run2(actions.setPrefs({ thinking })) }))
),
+ (0, import_react45.createElement)(
+ SetSection,
+ { key: "new", title: t("New Bots") },
+ (0, import_react45.createElement)(
+ SetRow,
+ { label: t("Default model"), hint: t("Applies to Bots made after this pick, when a create names no model. Existing Bots keep their own.") },
+ (0, import_react45.createElement)(ModelMenu, {
+ bot: { id: "new-bots", name: t("New Bots"), model: prefs.defaultBotModel },
+ roster,
+ actions,
+ run: run2,
+ wide: true,
+ withEfforts: false,
+ onPick: (ref) => run2(actions.setPrefs({ defaultBotModel: ref }))
+ }),
+ prefs.defaultBotModel ? (0, import_react45.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", onClick: () => run2(actions.setPrefs({ defaultBotModel: null })) }, t("Reset")) : null
+ )
+ ),
actions.setSurface ? (0, import_react45.createElement)(
SetSection,
{ key: "mode", title: t("Mode") },
@@ -20853,7 +20874,7 @@ function apply(ctx) {
if (typeof release === "function") release();
if (snapshot.ready) {
try {
- localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, layout: prefs.layout, width: prefs.width, flatWidth: prefs.flatWidth, thinking: prefs.thinking }));
+ localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, layout: prefs.layout, width: prefs.width, flatWidth: prefs.flatWidth, thinking: prefs.thinking, defaultBotModel: prefs.defaultBotModel }));
} catch {
}
}
diff --git a/ds-bot/src/client/bot-draft.js b/ds-bot/src/client/bot-draft.js
index c7659d87..52e97de0 100644
--- a/ds-bot/src/client/bot-draft.js
+++ b/ds-bot/src/client/bot-draft.js
@@ -8,10 +8,11 @@ export function freshBotName(roster, base = 'New Bot') {
return `${base} ${index}`
}
-// The form starts on the DSH default model when it is served, else the first one.
+// The form starts on the team default model from settings when it is served, then
+// the DSH default, else the first one.
export function startModel(roster) {
const models = roster.models ?? []
- return (models.find(model => model.ref === roster.defaultModel) ?? models[0])?.ref ?? ''
+ return (models.find(model => model.ref === roster.prefs?.defaultBotModel) ?? models.find(model => model.ref === roster.defaultModel) ?? models[0])?.ref ?? ''
}
// The model is always sent: the host fixes it on the Bot at creation.
diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.js
index fa328fd3..17cb8b39 100644
--- a/ds-bot/src/client/i18n.js
+++ b/ds-bot/src/client/i18n.js
@@ -56,6 +56,9 @@ const ZH = {
'Delete group': '删除群聊',
"Open {name}'s chat": '打开 {name} 的对话',
'New Bot': '新 Bot',
+ 'New Bots': '新 Bot',
+ 'Default model': '默认模型',
+ 'Applies to Bots made after this pick, when a create names no model. Existing Bots keep their own.': '只影响之后新建的 Bot;已有 Bot 的模型不变。',
// Sidebar and account menu
'Bot list': 'Bot 列表',
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index 98e1b486..40941284 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -363,7 +363,7 @@ export function apply(ctx) {
releaseTokens = ctx.theme.overrideTokens('ds-bot', shellTokens(themes[id]))
if (typeof release === 'function') release()
if (snapshot.ready) {
- try { localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, layout: prefs.layout, width: prefs.width, flatWidth: prefs.flatWidth, thinking: prefs.thinking })) } catch { /* storage unavailable */ }
+ try { localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, layout: prefs.layout, width: prefs.width, flatWidth: prefs.flatWidth, thinking: prefs.thinking, defaultBotModel: prefs.defaultBotModel })) } catch { /* storage unavailable */ }
}
}
render()
diff --git a/ds-bot/src/client/model-menu.js b/ds-bot/src/client/model-menu.js
index 4ac48362..015e746b 100644
--- a/ds-bot/src/client/model-menu.js
+++ b/ds-bot/src/client/model-menu.js
@@ -144,12 +144,13 @@ export function useAnchoredMenu() {
// The trigger shows the model name over its provider. A Thinking section lists the
// levels of the shown model when it has them.
// `onPick`/`onPickEffort` replace saving to the Bot, for a Bot that does not exist yet.
-export function ModelMenu({ bot, roster, actions, run, wide = false, onPick, onPickEffort }) {
+// `withEfforts: false` keeps the Thinking section out, for a pick that has no level of its own.
+export function ModelMenu({ bot, roster, actions, run, wide = false, onPick, onPickEffort, withEfforts = true }) {
const { isOpen, shownPlace, leaving, button, menu, open, close } = useAnchoredMenu()
const shown = modelOf(bot, roster)
const current = bot.model ?? bot.appliedModel
const served = servedOf(roster, current)
- const reasoning = useEfforts(served, current, actions)
+ const reasoning = useEfforts(served, withEfforts ? current : undefined, actions)
// The level the Bot runs on: its pick when the model serves it, else the model's own.
const picked = reasoning?.efforts?.some(effort => effort.id === bot.effort) ? bot.effort : undefined
const currentEffort = picked ?? reasoning?.defaultEffort
@@ -183,13 +184,13 @@ export function ModelMenu({ bot, roster, actions, run, wide = false, onPick, onP
h('span', { className: 'bt-model-copy' },
h('span', { className: 'bt-model-name' }, shown?.name ?? t('Choose a model')),
shown ? h('span', { className: 'bt-model-provider' }, shown.served || models.length === 0
- ? (effortLabel === undefined ? shown.provider : `${shown.provider} · ${effortLabel}`)
+ ? (!withEfforts || effortLabel === undefined ? shown.provider : `${shown.provider} · ${effortLabel}`)
: t('{provider} · not available', { provider: shown.provider })) : null),
h(Caret)),
shownPlace ? createPortal(h('div', { ref: menu, className: `bt-menu bt-model-menu${shownPlace.bottom !== undefined ? ' bt-menu-up' : ''}`, role: 'menu', 'aria-label': t('Model for {name}', { name: bot.name }), style: shownPlace, 'data-leaving': leaving || undefined },
models.length > 0 ? h(ModelRows, { roster, current, onPick: pick })
: h('div', { className: 'bt-model-none' }, t('No models are set up in DeepSeek Harness yet.')),
- effortRows(reasoning).length > 0 ? h(EffortRows, { reasoning, current: picked, onPick: pickEffort }) : null,
+ withEfforts && effortRows(reasoning).length > 0 ? h(EffortRows, { reasoning, current: picked, onPick: pickEffort }) : null,
manage ? h('div', { className: 'bt-menu-sep', role: 'separator' }) : null,
manage ? h('button', { type: 'button', role: 'menuitem', onClick: () => { close(); manage() } }, h(SlidersIcon), h('span', { className: 'bt-menu-label' }, t('Models and providers…'))) : null), document.body) : null)
}
diff --git a/ds-bot/src/client/settings.js b/ds-bot/src/client/settings.js
index 4428659d..330b7c72 100644
--- a/ds-bot/src/client/settings.js
+++ b/ds-bot/src/client/settings.js
@@ -20,6 +20,7 @@ import { FeedbackIcon, FeedbackPage } from './feedback.js'
import { AboutPage } from './about.js'
import { ProvidersPage } from './providers-page.js'
import { FolderMenu } from './folder-menu.js'
+import { ModelMenu } from './model-menu.js'
import { t } from './i18n.js'
const capitalize = word => word[0].toUpperCase() + word.slice(1)
@@ -106,6 +107,14 @@ function GeneralPage({ roster, actions, run }) {
layoutOf(prefs) === 'flat' ? h(SetRow, { label: t('Text width') }, h(WidthSlider, { label: t('Text width'), value: flatWidthOf(prefs), save: flatWidth => run(actions.setPrefs({ flatWidth })) })) : null,
h(SetRow, { label: t('Bubble width') }, h(WidthSlider, { label: t('Bubble width'), value: widthOf(prefs), save: width => run(actions.setPrefs({ width })) })),
h(SetRow, { label: t('Show thinking') }, h(Switch, { label: t('Show thinking'), on: thinkingShown(prefs), onChange: thinking => run(actions.setPrefs({ thinking })) }))),
+ h(SetSection, { key: 'new', title: t('New Bots') },
+ h(SetRow, { label: t('Default model'), hint: t('Applies to Bots made after this pick, when a create names no model. Existing Bots keep their own.') },
+ h(ModelMenu, {
+ bot: { id: 'new-bots', name: t('New Bots'), model: prefs.defaultBotModel },
+ roster, actions, run, wide: true, withEfforts: false,
+ onPick: ref => run(actions.setPrefs({ defaultBotModel: ref })),
+ }),
+ prefs.defaultBotModel ? h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: () => run(actions.setPrefs({ defaultBotModel: null })) }, t('Reset')) : null)),
actions.setSurface ? h(SetSection, { key: 'mode', title: t('Mode') },
h(SetRow, { label: t('Classic Agent mode') },
h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: () => actions.setSurface('agent') }, t('Switch')))) : null,
diff --git a/ds-bot/src/host/channel.js b/ds-bot/src/host/channel.js
index 59168534..64dd5cc6 100644
--- a/ds-bot/src/host/channel.js
+++ b/ds-bot/src/host/channel.js
@@ -116,7 +116,7 @@ export function install(rt) {
// Updates change the dsh profile, not the team, so a reading host may run them too.
const READS = new Set(['state', 'models', 'efforts', 'providers', 'provider-models', 'earlier', 'chat', 'run-stats', 'room-progress', 'exchange', 'exchange-text', 'file-text', 'usage', 'schedules', 'memory-view', 'browser-wait', 'browser-result', 'diagnostics', 'diagnostics-log', 'diagnostics-clear', 'update-check', 'update-install', 'dsh-update-install', 'repo-stars', 'approval-answer', 'thinking', 'avatar-library'])
- function setPrefs(body) {
+ async function setPrefs(body) {
if (body.theme !== undefined) {
if (typeof body.theme !== 'string' || !/^[a-z][\w-]{0,31}$/.test(body.theme)) throw invalid('Unknown theme')
state.prefs.theme = body.theme
@@ -146,6 +146,12 @@ export function install(rt) {
else if (Number.isInteger(body.flatWidth) && body.flatWidth >= 50 && body.flatWidth <= 100) state.prefs.flatWidth = body.flatWidth
else throw invalid('Flat text width must be a whole percent from 50 to 100')
}
+ if (body.defaultBotModel !== undefined) {
+ // The model new Bots start on when a create names none. It resolves now, so the
+ // saved ref is one the catalog served at save time; a create still re-checks it.
+ if (body.defaultBotModel === null || body.defaultBotModel === '') delete state.prefs.defaultBotModel
+ else state.prefs.defaultBotModel = await rt.resolveModel(body.defaultBotModel)
+ }
if (body.thinking !== undefined) {
// A value this version does not know is ignored, not refused: the toggle
// may grow more states later.
diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.js
index 5a74daac..68cfa513 100644
--- a/ds-bot/src/host/tools.js
+++ b/ds-bot/src/host/tools.js
@@ -315,7 +315,7 @@ export function install(rt) {
role: { type: 'string', required: true, description: 'Two-to-four character role label shown under the name' },
instructions: { type: 'string', required: true, description: 'What this Bot is responsible for and how it should work' },
brief: { type: 'string', description: 'Why the user wants it, passed to the new Bot as its first context' },
- model: { type: 'string', description: 'Model the Bot runs on, as provider/model or a model id. Only when the user names one; otherwise the model you run on.' },
+ model: { type: 'string', description: 'Model the Bot runs on, as provider/model or a model id. Only when the user names one; otherwise the team default model from DS Bot settings, or the model you run on.' },
effort: { type: 'string', description: 'Thinking level for the model, as list_bot_models shows it. Only when the user names one.' },
work_dir: WORK_DIR_PARAM,
avatar: AVATAR_PARAM,
@@ -329,11 +329,13 @@ export function install(rt) {
const workDir = args.work_dir ? await rt.cleanWorkDir(args.work_dir) : undefined
const name = String(args.name ?? '').trim()
await rt.approveFolder(exec, { path: workDir, who: { en: `the new Bot ${name}`, zh: `新 Bot ${name} ` } })
- // Without a named model the new Bot takes its creator's: the DSH default may be
- // a provider that has no key, and then the new Bot fails on its first reply.
+ // Without a named model the team's default applies; without one the new Bot
+ // takes its creator's: the DSH default may be a provider that has no key, and
+ // then the new Bot fails on its first reply.
const creator = callerBot(exec)
- const served = creator?.model && (await rt.catalog()).some(entry => entry.ref === creator.model)
- const model = args.model || (served ? creator.model : undefined)
+ const served = new Set((await rt.catalog()).map(entry => entry.ref))
+ const fallback = [state.prefs.defaultBotModel, creator?.model].find(ref => ref && served.has(ref))
+ const model = args.model || fallback
const bot = await rt.createBot({ ...args, avatar: avatar === undefined ? undefined : { image: avatar }, model, workDir, effort: args.effort, createdBy: creator?.id })
return `Created ${bot.name}${workDir ? `, working in ${workDir}` : ''}. It is greeting the user now.`
} catch (error) {
diff --git a/ds-bot/test/create-bot.test.js b/ds-bot/test/create-bot.test.js
index bceaf803..cdea48ef 100644
--- a/ds-bot/test/create-bot.test.js
+++ b/ds-bot/test/create-bot.test.js
@@ -7,11 +7,14 @@ const models = [
{ ref: 'cloud/qwen-max', name: 'Qwen Max', providerName: 'Cloud' },
]
-test('the form starts on the DSH default model, else the first served one', () => {
+test('the form starts on the team default model, then the DSH default, else the first served one', () => {
assert.equal(startModel({ models, defaultModel: 'cloud/qwen-max' }), 'cloud/qwen-max')
assert.equal(startModel({ models, defaultModel: 'gone/model' }), 'ollama/ds-flash')
assert.equal(startModel({ models, defaultModel: null }), 'ollama/ds-flash')
assert.equal(startModel({ models: [], defaultModel: 'cloud/qwen-max' }), '')
+ // The team's pick from settings comes first; one that is not served falls through.
+ assert.equal(startModel({ models, defaultModel: 'cloud/qwen-max', prefs: { defaultBotModel: 'ollama/ds-flash' } }), 'ollama/ds-flash')
+ assert.equal(startModel({ models, defaultModel: 'cloud/qwen-max', prefs: { defaultBotModel: 'gone/model' } }), 'cloud/qwen-max')
})
test('the payload carries the look, the chosen model, and the brief', () => {
diff --git a/ds-bot/test/roster.test.js b/ds-bot/test/roster.test.js
index d6b23e09..2672f2f6 100644
--- a/ds-bot/test/roster.test.js
+++ b/ds-bot/test/roster.test.js
@@ -992,3 +992,60 @@ test('old late-round and relay-limit fields of a group load away; calls it parke
assert.equal(set.ok, true)
assert.deepEqual(set.value.changes, [])
})
+
+// #227: a team-level default model for new Bots. A create that names a model keeps it;
+// the team's pick comes next, and only when it is still served. Without either, the Bot
+// takes its creator's served model, as it always has.
+const TEAM_MODEL = {
+ version: 1,
+ mainBotIds: ['chief'],
+ bots: { chief: { id: 'chief', sessionId: 'chief', name: 'Chief', instructions: '', createdAt: 1, model: 'deepseek/deepseek-v4-pro' } },
+ rooms: {},
+ exchanges: [],
+ exchangeTurns: {},
+ questions: {},
+}
+
+const createBotAs = async (name, args = {}, exec = { agent: { id: 'chief' } }) =>
+ rt.teamTools.find(d => d.name === 'create_bot').execute({ name, role: 'R', instructions: '', ...args }, exec)
+const botNamed = async name => Object.values(rt.state.bots).find(bot => bot.name === name)
+
+test('create_bot uses a named model, then the team default, then its creator’s', async (t) => {
+ const { call, stop } = start(TEAM_MODEL, { models: ['deepseek-v4-flash', 'deepseek-v4-pro'] })
+ t.after(stop)
+ await call('set-prefs', { defaultBotModel: 'deepseek/deepseek-v4-flash' })
+
+ // An explicit model wins over the team default.
+ assert.match(await createBotAs('Named', { model: 'deepseek/deepseek-v4-pro' }), /^Created Named/)
+ assert.equal((await botNamed('Named')).model, 'deepseek/deepseek-v4-pro')
+
+ // The team default beats the creator's model.
+ assert.match(await createBotAs('Defaulted'), /^Created Defaulted/)
+ assert.equal((await botNamed('Defaulted')).model, 'deepseek/deepseek-v4-flash')
+
+ // A team default that is no longer served falls back to the creator's model.
+ rt.state.prefs.defaultBotModel = 'gone/model'
+ assert.match(await createBotAs('Inherited'), /^Created Inherited/)
+ assert.equal((await botNamed('Inherited')).model, 'deepseek/deepseek-v4-pro')
+})
+
+test('create_bot inherits the creator’s model when no team default is set', async (t) => {
+ const { stop } = start(TEAM_MODEL, { models: ['deepseek-v4-flash', 'deepseek-v4-pro'] })
+ t.after(stop)
+ assert.match(await createBotAs('Inherited'), /^Created Inherited/)
+ assert.equal((await botNamed('Inherited')).model, 'deepseek/deepseek-v4-pro')
+})
+
+test('set-prefs stores a served default model, clears it, and refuses an unknown one', async (t) => {
+ const { call, stop } = start(TEAM_MODEL, { models: ['deepseek-v4-flash', 'deepseek-v4-pro'] })
+ t.after(stop)
+ assert.equal((await call('set-prefs', { defaultBotModel: 'deepseek/deepseek-v4-flash' })).value.defaultBotModel, 'deepseek/deepseek-v4-flash')
+ // A bare model id resolves to its full ref.
+ assert.equal((await call('set-prefs', { defaultBotModel: 'deepseek-v4-pro' })).value.defaultBotModel, 'deepseek/deepseek-v4-pro')
+ const refused = await call('set-prefs', { defaultBotModel: 'gone/model' })
+ assert.equal(refused.ok, false)
+ assert.match(refused.error.message, /Model gone\/model is not available/)
+ assert.equal(rt.state.prefs.defaultBotModel, 'deepseek/deepseek-v4-pro')
+ assert.equal('defaultBotModel' in (await call('set-prefs', { defaultBotModel: null })).value, false)
+ assert.equal('defaultBotModel' in rt.state.prefs, false)
+})