Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

PM starts on Opus 5.5 xhigh, roles carry defaults, reviews held to the Builder's strength (#2274)

0xken1543dc7a63fe4f
diff --git a/backend/src/superTabs/autoReview.ts b/backend/src/superTabs/autoReview.ts
index a15c0a65a..51d4a8f65 100644
--- a/backend/src/superTabs/autoReview.ts
+++ b/backend/src/superTabs/autoReview.ts
@@ -53,17 +53,22 @@ const free = (state: SuperTabState, agent: Agent) =>
/**
* The Reviewer for [group]'s review: the one that reviewed its earlier head while it is still free (a delta review), else
- * a free Reviewer of the project, one on another engine than the Engineer's first. Never one that is stopping, waiting to
+ * a free Reviewer of the project: one at least as strong as the Engineer ([strength], up to the top tier) first, as the CLI's
+ * route holds a Reviewer to the Builder's strength (review of #2274), and among those one on another engine than the
+ * Engineer's first; else the weaker ones in that order. Never one that is stopping, waiting to
* resume a lost task, down (its session gone or its machine silent), or (`mayWork`) not allowed to take this work: on its
* machine, or by the owner's rules (#610 review).
*/
function pickReviewer(state: SuperTabState, group: Conversation, engineer: Agent | undefined, earlier: Conversation | undefined,
- mayWork: (agent: Agent) => boolean, now: number): Agent | null {
+ mayWork: (agent: Agent) => boolean, strength: (agent: Agent) => number, now: number): Agent | null {
const projectId = groupProject(state, group).id
const candidates = state.agents.filter(a => agentRole(a) === 'reviewer' && agentProjectId(state, a) === projectId &&
a.workDecision !== 'stop' && !a.lostTask && !downSince(state, a, now) && free(state, a) && mayWork(a))
const previous = candidates.find(a => a.id === earlier?.assignment?.agentId)
- return previous ?? candidates.find(a => a.configuration.engine !== engineer?.configuration.engine) ?? candidates[0] ?? null
+ const floor = engineer ? Math.min(3, strength(engineer)) : 0
+ const strong = candidates.filter(a => strength(a) >= floor), weaker = candidates.filter(a => strength(a) < floor)
+ const otherEngine = (list: Agent[]) => list.find(a => a.configuration.engine !== engineer?.configuration.engine) ?? list[0]
+ return previous ?? otherEngine(strong) ?? otherEngine(weaker) ?? null
}
function briefOf(group: Conversation, handoff: string, pullRequest: string, earlier: Conversation | undefined): string {
@@ -92,14 +97,15 @@ export interface OpenedReview { review: Conversation; reviewer: Agent | null; me
* notices are (liveness.ts), never as the Engineer (#610 review); [engineer] writes them only in a group with no Lead.
*/
export function openReview(state: SuperTabState, group: Conversation, handoff: string, pullRequest: string,
- context: { operationId: string; now: number; engineer: Author; mayWork: (agent: Agent) => boolean; sameEngine?: (agent: Agent) => string | null }): OpenedReview | null {
+ context: { operationId: string; now: number; engineer: Author; mayWork: (agent: Agent) => boolean; strength: (agent: Agent) => number;
+ sameEngine?: (agent: Agent) => string | null }): OpenedReview | null {
const project = groupProject(state, group)
// On Custom skills without a reviewer role there are no review groups (commands.ts requireCustomRole).
if (state.paused || (skillSetOf(project) === 'custom' && !project.roles?.some(r => r.kind === 'reviewer'))) return null
// Only a review that gave its verdict reviewed the earlier head: one cancelled before it reviewed nothing (#610 review).
const earlier = state.conversations.filter(c => c.reviewOf === group.id && c.assignment && verdictGiven(c)).sort((a, b) => (b.number ?? 0) - (a.number ?? 0))[0]
const engineer = state.agents.find(a => a.id === group.assignment?.agentId)
- const reviewer = pickReviewer(state, group, engineer, earlier, context.mayWork, context.now)
+ const reviewer = pickReviewer(state, group, engineer, earlier, context.mayWork, context.strength, context.now)
const id = stableId(context.operationId, 'auto-review')
const number = nextConversationNumber(state)
state.groupCounter = number
diff --git a/backend/src/superTabs/commands.test.ts b/backend/src/superTabs/commands.test.ts
index 82ed42484..d49271122 100644
--- a/backend/src/superTabs/commands.test.ts
+++ b/backend/src/superTabs/commands.test.ts
@@ -1074,6 +1074,27 @@ it('records the lead project once and accepts only Claude Code and Codex contrib
expect(commandSchema.safeParse({ ...command, engines: ['claude', engine] }).success).toBe(false)
}
})
+it('says in the project chat when a Product Manager on its person\'s own Mac could not launch on the model its role asks for', () => {
+ const join = (extra: Record<string, unknown>, lead = true) => {
+ const f = fixture(), project = { cwd: '/repo', repositoryUrl: 'https://github.com/example/project' }
+ const effects = f.run({ type: 'agent.add', conversationId: 'lead', machineId: 'host', harnessId: 'pm', name: 'Lead', configuration: config, lead, project, ...extra } as Command, owner,
+ { contribution: { machineOwnerId: 'owner', contributorId: 'owner' } })
+ return effects.messages.filter(m => m.conversationId === 'lead').map(m => m.text)
+ }
+ expect(join({ launchRefused: { model: 'opus', effort: 'xhigh' } })).toEqual(
+ ['Product Manager started. It asked for opus at xhigh and runs its engine\u2019s own model there: this machine could not launch it with them.'])
+ expect(join({})).toEqual([])
+ // Only a Product Manager's start says it.
+ expect(join({ launchRefused: { model: 'opus', effort: 'xhigh' } }, false)).toEqual([])
+ expect(commandSchema.safeParse({ type: 'agent.add', conversationId: 'lead', machineId: 'host', harnessId: 'pm', name: 'Lead', configuration: config, lead: true,
+ launchRefused: { model: 'opus', other: 1 } }).success).toBe(false)
+ // Only what a launch could have asked for (cli lib/launchModel.ts MODEL and EFFORT): one short word each.
+ for (const launchRefused of [{ model: 'opus --dangerously-skip-permissions' }, { model: 'opus\nRead this' }, { model: 'x'.repeat(65) }, { model: 'opus', effort: 'XHIGH' }, { model: 'opus', effort: 'x'.repeat(17) }]) {
+ expect(commandSchema.safeParse({ type: 'agent.add', conversationId: 'lead', machineId: 'host', harnessId: 'pm', name: 'Lead', configuration: config, lead: true, launchRefused }).success, JSON.stringify(launchRefused)).toBe(false)
+ }
+ expect(commandSchema.safeParse({ type: 'agent.add', conversationId: 'lead', machineId: 'host', harnessId: 'pm', name: 'Lead', configuration: config, lead: true,
+ launchRefused: { model: 'claude-opus-5[1m]', effort: 'xhigh' } }).success).toBe(true)
+})
it('accepts POSIX, Windows drive and UNC folders and refuses relative, drive-relative and control-character ones', () => {
const contribute = (cwd: string) => commandSchema.safeParse({ type: 'machine.contribute', machineId: 'host', name: 'PC', cwd, engines: ['claude'], maxAgents: 1 })
for (const cwd of ['/repo', 'C:\\Users\\dev\\data', 'c:/Users/dev/data', 'D:\\', '\\\\server\\share\\x']) expect(contribute(cwd).success, cwd).toBe(true)
@@ -1673,6 +1694,24 @@ describe('Reviewer role', () => {
expect(reviews()[0]!.assignment!.agentId).toBe(fresh)
})
+ it('prefers a free Reviewer at least as strong as the Builder, and falls back to a weaker one (review of #2274)', () => {
+ // The Engineer runs Codex gpt-6.1-sol (quality 3). `reviewer` comes first on Claude Sonnet (2); `fresh` runs Claude Opus (3).
+ const { f, fresh, reviewer, builder, markReady, reviews } = ready('claude')
+ f.state.agents.find(a => a.id === builder)!.configuration.model = 'gpt-6.1-sol'
+ f.state.agents.find(a => a.id === reviewer)!.configuration.model = 'claude-sonnet-5-5'
+ markReady(`Ready. ${pr}`)
+ expect(reviews()[0]!.assignment!.agentId).toBe(fresh)
+ })
+
+ it('takes a weaker free Reviewer when none is as strong as the Builder', () => {
+ const { f, fresh, reviewer, builder, lead, markReady, reviews } = ready('claude')
+ f.run({ type: 'agent.release', agentId: fresh, decision: 'stop' }, { kind: 'agent', agentId: lead, machineOwnerId: 'host-owner' })
+ f.state.agents.find(a => a.id === builder)!.configuration.model = 'gpt-6.1-sol'
+ f.state.agents.find(a => a.id === reviewer)!.configuration.model = 'claude-sonnet-5-5'
+ markReady(`Ready. ${pr}`)
+ expect(reviews()[0]!.assignment!.agentId).toBe(reviewer)
+ })
+
it('opens nothing without a link to a pull request of the project\'s repository, or when the Lead marks it ready', () => {
const { f, lead, markReady, reviews } = ready()
markReady('Ready. Revision abc.')
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.ts
index db1b92957..89c6dcef6 100644
--- a/backend/src/superTabs/commands.ts
+++ b/backend/src/superTabs/commands.ts
@@ -11,7 +11,7 @@ import {
import { jobKindOf } from './evidence/jobKind.js'
import { routeRecordSchema, routeTitle, startedAs, type RouteCandidate, type RouteDecision, type RouteFinal, type RouteOverride } from './routeRecord.js'
import { DEFAULT_ROUTING_POLICY, routingOverrideSaveSchema, type RoutingPolicy } from './routingPolicy.js'
-import { agentTarget, askedInSchema, broken, MAX_RULES, reviewRefusal, RULE_MESSAGE_MS, SAME_ENGINE, sameEngineReview, ruleSchema, ruleTextSchema, startTarget, unmet, type RunTarget } from './rules.js'
+import { agentQuality, agentTarget, askedInSchema, broken, MAX_RULES, reviewRefusal, RULE_MESSAGE_MS, SAME_ENGINE, sameEngineReview, ruleSchema, ruleTextSchema, startTarget, unmet, type RunTarget } from './rules.js'
import { MAX_ATTACHMENTS, type Attachment } from './attachments.js'
import { checkMentions, MAX_MENTIONS, namedIn, textTags, withTags, type MentionTarget } from './mentions.js'
import { answerDecision, askDecisions, checkAsker, decisionChoices, decisionQuestion, MAX_OPEN_DECISIONS, MAX_QUESTIONS, type DecisionTarget } from './decisions.js'
@@ -34,10 +34,10 @@ import { bindPullRequestCards, bindTaskCard, pullRequestCard, recordCardMerged }
import { openReview, openReviewOf, projectPullRequest, verdictPending } from './autoReview.js'
import { carryOver, cheapAttempt, GRID_START_FAILED, REVIEW_FAILED, stepUp, stepUpRefusal } from './stepUp.js'
import { avatarChoice, setAgentAvatar, setMemberAvatar, setStatus, statusSchema, type AvatarUpload } from './profile.js'
-import { agentKind, agentProjectId, audienceOf, agentSetRole, canReadProject, deleteProject, isConfidential, markConfidential, onTeamAccount, requireSingleRegistration, groupProject, inviteLanding, ledProject, manageProject, MAX_ROLES, mutableProjects, placeRules, projectMembers, projectOf, projectRules, projectsOf, readAgent, readConversation, readProject, roleVersion, sameProject, sharedWithLeads, SKILL_SET_NAMES, skillSetOf, type ProjectRole, type RoleKind, type SwarmProject } from './projects.js'
+import { agentKind, agentProjectId, audienceOf, agentSetRole, canReadProject, deleteProject, isConfidential, markConfidential, onTeamAccount, requireSingleRegistration, groupProject, inviteLanding, ledProject, manageProject, MAX_ROLES, mutableProjects, placeRules, projectMembers, projectOf, projectRules, projectsOf, readAgent, readConversation, readProject, roleDefaults, roleVersion, sameProject, sharedWithLeads, SKILL_SET_NAMES, skillSetOf, withRoleDefaults, type ProjectRole, type RoleDefaults, type RoleKind, type SwarmProject } from './projects.js'
import { BUDDY_REQUIREMENTS, buddyChatId, buddyReady, chosenBuddyName, isBuddy, isBuddyChat, MAX_PROPOSAL_ASKS, MAX_PROPOSAL_ATTACHMENTS, openBuddyChat, PROPOSAL_ASK_MS, proposalText, renameBuddy, requireBuddyCommand } from './buddies.js'
import { BUDDY_OWN_MACHINE_REFUSAL, CODEX_BUDDY_REFUSAL } from './buddyContract.js'
-import { LEAD_NAME, leadJoined, leadStartFailed, leadStarting, placeLead } from './leadStart.js'
+import { LEAD_NAME, launchRefusedLine, leadJoined, leadStartFailed, leadStarting, placeLead } from './leadStart.js'
const id = z.string().min(1).max(160).regex(/^[A-Za-z0-9_-]+$/)
const title = z.string().trim().min(1).max(160)
@@ -68,8 +68,15 @@ const project = z.object({ cwd: path, repositoryUrl: repositoryUrl.nullable() })
const maxAgents = z.number().int().min(1).max(1024)
// Copied Default roles keep the ids lead, dev and review; a role the owner adds gets 12 random hex characters from the client.
const roleId = z.string().regex(/^([0-9a-f]{12}|lead|dev|review)$/)
+/** A role's default engine, model and effort (projects.ts RoleDefaults). */
+/** What a launch may be asked to run, one short word each, as the CLI checks it (cli lib/launchModel.ts MODEL and EFFORT). */
+const LAUNCH_MODEL = /^[A-Za-z0-9][A-Za-z0-9._:\-[\]]{0,63}$/
+const LAUNCH_EFFORT = /^[a-z]{1,16}$/
+const roleDefaultsSchema = z.object({ engine: z.enum(['claude', 'codex']), model: z.string().trim().min(1).max(200).optional(),
+ effort: z.string().trim().min(1).max(80).optional() }).strict()
const role = z.object({ id: roleId, name: z.string().trim().min(1).max(40), kind: z.enum(['lead', 'builder', 'reviewer']),
- text: z.string().min(1).refine(value => Buffer.byteLength(value) <= 65_536, 'A role\'s skill text is at most 64 KB.') }).strict()
+ text: z.string().min(1).refine(value => Buffer.byteLength(value) <= 65_536, 'A role\'s skill text is at most 64 KB.'),
+ defaults: roleDefaultsSchema.optional() }).strict()
const roleSet = z.array(role).min(1).max(MAX_ROLES)
export const startRequestSchema = z.object({
conversationId: id, machineId: id, engine: swarmEngine, name: title, cwd: path, role: z.enum(['builder', 'reviewer']).optional(), roleId: roleId.optional(),
@@ -141,7 +148,10 @@ export const commandSchema = z.discriminatedUnion('type', [
// `fixes`: the merged PR this one fixes, for its model's fixes after merge (leaderboard/record.ts recordFix).
z.object({ type: z.literal('conversation.merged'), conversationId: id, pullRequestUrl: z.string().max(400).regex(PULL_REQUEST_URL),
mergedAt: z.iso.datetime().optional(), fixes: z.string().max(400).regex(PULL_REQUEST_URL).optional() }).strict(),
- z.object({ type: z.literal('agent.add'), conversationId: id, machineId: id, harnessId: id, name: title, configuration, lead: z.boolean(), project: project.optional(), roleId: roleId.optional(), initialMessage: text.optional() }).strict(),
+ // `launchRefused`: the model and effort a Product Manager's own-machine launch asked for, which that machine refused before
+ // launching anything, so it runs its engine's own model (Desktop AgentCreationAttempt; leadStart.ts launchRefusedLine).
+ z.object({ type: z.literal('agent.add'), conversationId: id, machineId: id, harnessId: id, name: title, configuration, lead: z.boolean(), project: project.optional(), roleId: roleId.optional(), initialMessage: text.optional(),
+ launchRefused: z.object({ model: z.string().regex(LAUNCH_MODEL), effort: z.string().regex(LAUNCH_EFFORT).optional() }).strict().optional() }).strict(),
z.object({ type: z.literal('agent.start'), request: startRequestSchema, routeDecisionId: id.optional(), overrideReason: reason.optional() }).strict(),
// A Buddy's proposal for its owner, posted in its project's chat: `conversationId` is its own chat, and `ownerMessageId` its
// owner's message there asking for it. Its files are its own uploads in that chat, or files its owner sent there (store.ts proposable).
@@ -393,7 +403,8 @@ function roleSetOf(roles: ProjectRole[]): ProjectRole[] {
}
return roles
}
-const projectRole = (r: z.infer<typeof role>): ProjectRole => ({ id: r.id, name: r.name, kind: r.kind, version: roleVersion(r.text) })
+const projectRole = (r: z.infer<typeof role>): ProjectRole => ({ id: r.id, name: r.name, kind: r.kind, version: roleVersion(r.text),
+ ...(r.defaults ? { defaults: r.defaults } : {}) })
/** The custom set's role an agent of this kind is started or assigned with. */
function chosenRole(project: SwarmProject, id: string, kind: RoleKind): ProjectRole {
@@ -657,6 +668,28 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma
/** The Mac a Harness Team account's machine is, for a machines rule naming the Mac (machines.ts teamStartRequest). */
const macOf = (id: string) => state.machines?.find(m => m.machineId === id)?.hostMachineId
const groupRules = (conversationId: string) => projectRules(state, groupProject(state, conversation(state, conversationId)).id)
+ /** [request] with its role's [defaults] filled in (projects.ts withRoleDefaults) while the routing policy has that model on and
+ * the project's rules allow it. Otherwise it starts as asked, on its engine's own model, and [conversationId] says why: a
+ * default never overrides the owner's model list or rules (review of #2274). */
+ const defaulted = <T extends { engine: string; model?: string; effort?: string; gridModel?: string }>(request: T, defaults: RoleDefaults | undefined,
+ conversationId: string, machineId: string, name: string): T => {
+ const filled = withRoleDefaults(request, defaults)
+ if (filled === request) return request
+ const model = filled.model!, engineName = filled.engine === 'codex' ? 'Codex' : 'Claude'
+ const rows = policy.models.filter(m => m.engine === filled.engine && m.model === model)
+ const exact = rows.find(m => m.effort === (filled.effort ?? 'default'))
+ // Each rule on its own: one the plain request already breaks never hides another the default breaks (re-review of #2274).
+ const target = (r: T) => startTarget({ ...r, machineId })
+ const rule = groupRules(conversationId).map(r => !broken([r], target(request), machineName, macOf) && broken([r], target(filled), machineName, macOf)).find(Boolean)
+ const why = !rows.length ? `the routing policy has no row for ${engineName} ${model}.`
+ : !(exact ? exact.enabled : rows.some(m => m.enabled)) ? `the routing policy turns off ${engineName} ${model}${exact ? ` at ${exact.effort}` : ''}.`
+ : rule ? rule.replace(/^./, c => c.toLowerCase())
+ : null
+ if (!why) return filled
+ effects.messages.push({ id: stableId(operationId, 'role-default'), conversationId, author: sender, replyTo: null, recipients: [], source: RULE_ROW,
+ text: `${name} starts on its engine\u2019s own model, not ${model}${filled.effort ? ` at ${filled.effort}` : ''}: ${why}` })
+ return request
+ }
/** A requirement names only machines its setter sees, so it never names one to a reader who could not (model.ts TaskRequirement). */
const requirable = (task: WorkTask | undefined) => {
const machines = task?.requires?.machines
@@ -980,7 +1013,9 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma
const { type: _type, projectId: _projectId, machineId, ...request } = command
// Only its person knows which machine stays on (Ken, 10-29): a Desktop from before asked for the first free one.
if (!machineId) fail('MACHINE_REQUIRED', `Choose the machine the ${LEAD_NAME} runs on.`, 400)
- const start = placeLead(state, project, person(state, actor.userId), machineId, request, operationId, context)
+ // Its person named no model: the lead role's default for this engine (Claude Opus 5.5 at xhigh in the built-in sets).
+ const asked = defaulted(request, roleDefaults(project, 'lead'), project.leadConversationId, machineId, LEAD_NAME)
+ const start = placeLead(state, project, person(state, actor.userId), machineId, asked, operationId, context)
Object.assign(result, { startId: start.id, machineId: start.request.machineId })
break
}
@@ -1456,6 +1491,9 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma
if (actor.kind !== 'person') fail('FORBIDDEN', 'Only a person can record their initial launch request.', 403)
message(group.id, command.initialMessage)
}
+ // A Product Manager started on its person's own Mac says, as one the Swarm starts does (leadJoined), when it does not
+ // run the model its role asked for.
+ if (command.lead && command.launchRefused) message(group.id, launchRefusedLine(command.launchRefused), [], null, SYSTEM_ROW)
break
}
case 'agent.start': {
@@ -1483,7 +1521,11 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma
fail('STARTS_PENDING', 'Reconcile pending agent starts before adding more.')
}
// A teammate's project started on a Mac runs in that Mac's Harness Team account, never as its owner (machines.ts).
- const request = teamStartRequest(state, command.request, home, context.teamAccountsIdle, context.teamMachines)
+ // A person's start that names no model takes its role's default. A routed start keeps the model its route picked.
+ const asked = command.routeDecisionId ? command.request
+ : defaulted(command.request, roleDefaults(home, command.request.role ?? 'builder', command.request.roleId), command.request.conversationId,
+ command.request.machineId, command.request.name)
+ const request = teamStartRequest(state, asked, home, context.teamAccountsIdle, context.teamMachines)
const pool = admitMachineStart(state, request, context.now, undefined, context.teamMachines, context.otherWorkspaceMachines)
// Off the Machines list, a teammate's project never runs: nothing there shows a privacy check (machines.ts).
if (!pool) requireTeamWork(state, request.machineId, grant.contributorId, home, context.now, context.teamMachines, context.otherWorkspaceMachines)
@@ -2234,6 +2276,7 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma
// The owner's hard rules hold as for work.assign; the reviewed task's own requirement is its Engineer's, not its Reviewer's.
mayWork: a => !teamWorkCheck(state, a.machineId, a.contributorId, groupProject(state, group), context.now, context.teamMachines, context.otherWorkspaceMachines)
&& !broken(groupRules(group.id), agentTarget(state, a), machineName, macOf) && !reviewRefusal(state, group.id, agentTarget(state, a), policy, mayRun(group.id, false), context.now),
+ strength: a => agentQuality(state, policy, a),
sameEngine: a => sameEngineReview(state, group.id, agentTarget(state, a), policy, mayRun(group.id, false), context.now) })
if (opened) effects.messages.push(...opened.messages)
// No new Reviewer on another engine can start, or soon none will: the project's chat hears it once (reviewCapacity.ts).
diff --git a/backend/src/superTabs/leadStart.test.ts b/backend/src/superTabs/leadStart.test.ts
index 3a7098a17..35e93e938 100644
--- a/backend/src/superTabs/leadStart.test.ts
+++ b/backend/src/superTabs/leadStart.test.ts
@@ -1,6 +1,7 @@
import { afterEach, describe, expect, it } from 'vitest'
import { applyCommand, commandSchema, type Command, type CommandContext } from './commands.js'
import type { ContributedMachine, MachinePrivacy } from './machines.js'
+import { DEFAULT_ROUTING_POLICY } from './routingPolicy.js'
import { createSuperTab, SuperTabError, type Actor, type AgentConfiguration, type SuperTabState } from './model.js'
// A project's Product Manager started by the Swarm on the machine its person names (Dee, 10-29, option B; Ken, 10-29): on
@@ -194,6 +195,84 @@ describe('starting a project\'s Product Manager on a Swarm machine', () => {
})
})
+describe('the Product Manager\'s model and effort (Scholes\'s roadmap, piece 1)', () => {
+ const requestOf = (f: ReturnType<typeof swarm>) => f.state.starts!.at(-1)!.request
+ it('asks for Claude Opus 5.5 at xhigh when its person names no model', () => {
+ const f = swarm()
+ f.lead('owner-mac')
+ expect(requestOf(f)).toMatchObject({ engine: 'claude', model: 'opus', effort: 'xhigh' })
+ })
+ it('keeps a model or effort its person named, and leaves a Codex Product Manager on its engine\'s own model', () => {
+ const named = swarm()
+ named.lead('owner-mac', { model: 'sonnet', effort: 'high' })
+ expect(requestOf(named)).toMatchObject({ model: 'sonnet', effort: 'high' })
+ const effortOnly = swarm()
+ effortOnly.lead('owner-mac', { effort: 'max' })
+ expect(requestOf(effortOnly)).toMatchObject({ model: 'opus', effort: 'max' })
+ const codex = swarm()
+ codex.lead('owner-mac', { engine: 'codex' })
+ expect(requestOf(codex)).not.toHaveProperty('model')
+ expect(requestOf(codex)).not.toHaveProperty('effort')
+ })
+ it('takes a custom lead role\'s own default, for its engine only', () => {
+ const f = swarm()
+ const roles = [{ id: 'lead', name: 'Product Manager', kind: 'lead', text: '# PM', defaults: { engine: 'codex', model: 'gpt-6.1-sol', effort: 'xhigh' } },
+ { id: 'dev', name: 'Engineer', kind: 'builder', text: '# Dev' }]
+ f.run({ type: 'project.roles.create', projectId: f.app.projectId, roles } as Command)
+ f.run({ type: 'project.skills', projectId: f.app.projectId, mode: 'custom' } as Command)
+ f.lead('owner-mac', { engine: 'codex' })
+ expect(requestOf(f)).toMatchObject({ engine: 'codex', model: 'gpt-6.1-sol', effort: 'xhigh' })
+ const claude = swarm()
+ claude.run({ type: 'project.roles.create', projectId: claude.app.projectId, roles } as Command)
+ claude.run({ type: 'project.skills', projectId: claude.app.projectId, mode: 'custom' } as Command)
+ claude.lead('owner-mac')
+ expect(requestOf(claude)).not.toHaveProperty('model')
+ })
+ it('keeps its engine\'s own model, and says why in the project chat, when the owner\'s rules or routing policy rule its default out', () => {
+ // Review of #2274: a default never overrides the owner's model list or rules.
+ const linesOf = (f: ReturnType<typeof swarm>, effects: ReturnType<ReturnType<typeof swarm>['run']>) =>
+ effects.messages.filter(m => m.conversationId === f.app.conversationId).map(m => m.text)
+ const ruled = swarm()
+ ruled.run({ type: 'rule.set', projectId: ruled.app.projectId, rule: { kind: 'forbidModel', model: 'opus' }, text: 'No Opus.' } as Command)
+ const refused = ruled.lead('owner-mac')
+ expect(requestOf(ruled)).not.toHaveProperty('model')
+ expect(requestOf(ruled)).not.toHaveProperty('effort')
+ expect(linesOf(ruled, refused)).toEqual(['Product Manager starts on its engine\u2019s own model, not opus at xhigh: the owner\'s rule "No Opus." rules out Claude opus.'])
+ const policyWith = (off: (m: { model: string; effort: string }) => boolean) =>
+ ({ routingPolicy: { ...DEFAULT_ROUTING_POLICY, models: DEFAULT_ROUTING_POLICY.models.map(m => off(m) ? { ...m, enabled: false } : m) } })
+ for (const off of [(m: { model: string }) => m.model === 'opus', (m: { model: string; effort: string }) => m.model === 'opus' && m.effort === 'xhigh']) {
+ const f = swarm()
+ const effects = f.lead('owner-mac', {}, owner, policyWith(off))
+ expect(requestOf(f)).not.toHaveProperty('model')
+ expect(linesOf(f, effects)).toEqual(['Product Manager starts on its engine\u2019s own model, not opus at xhigh: the routing policy turns off Claude opus at xhigh.'])
+ }
+ // Opus at xhigh off, the effort its person named on: that row decides.
+ const named = swarm()
+ named.lead('owner-mac', { effort: 'high' }, owner, policyWith(m => m.model === 'opus' && m.effort === 'xhigh'))
+ expect(requestOf(named)).toMatchObject({ model: 'opus', effort: 'high' })
+ // Each rule on its own (re-review of #2274): one the plain request already breaks never lets the default through another.
+ const two = swarm()
+ two.run({ type: 'rule.set', projectId: two.app.projectId, rule: { kind: 'minEffort', effort: 'high' }, text: 'At least high.' } as Command)
+ two.run({ type: 'rule.set', projectId: two.app.projectId, rule: { kind: 'forbidModel', model: 'opus' }, text: 'No Opus.' } as Command)
+ const both = two.lead('owner-mac')
+ expect(requestOf(two)).not.toHaveProperty('model')
+ expect(linesOf(two, both)).toContain('Product Manager starts on its engine\u2019s own model, not opus at xhigh: the owner\'s rule "No Opus." rules out Claude opus.')
+ // Allowed: no line.
+ const plain = swarm()
+ expect(linesOf(plain, plain.lead('owner-mac'))).toEqual([])
+ })
+ it('never takes another project\'s role default', () => {
+ const f = swarm()
+ const other = f.run({ type: 'project.create', name: 'Other', visibility: 'private', brief: 'Other work.' }).result.projectId as string
+ f.run({ type: 'project.roles.create', projectId: other, roles: [{ id: 'lead', name: 'PM', kind: 'lead', text: '# PM',
+ defaults: { engine: 'codex', model: 'gpt-6.1-sol', effort: 'xhigh' } }] } as Command)
+ f.run({ type: 'project.skills', projectId: other, mode: 'custom' } as Command)
+ f.lead('owner-mac', { engine: 'codex' })
+ expect(requestOf(f)).toMatchObject({ engine: 'codex', leadFor: { projectId: f.app.projectId } })
+ expect(requestOf(f)).not.toHaveProperty('model')
+ })
+})
+
describe('a Product Manager\'s start, once its host reports it', () => {
/** The host of [machineId] acting for the start's requester, as the store's host route does (store.ts poolHostActor). */
const hosted = (f: ReturnType<typeof swarm>, machineId: string) => ({ contribution: { machineOwnerId: f.machine(machineId).contributorId,
@@ -201,10 +280,25 @@ describe('a Product Manager\'s start, once its host reports it', () => {
const messages = (effects: ReturnType<ReturnType<typeof swarm>['run']>, conversationId: string) =>
effects.messages.filter(m => m.conversationId === conversationId).map(m => m.text)
+ it('says when it runs another model or effort than it asked for, and nothing when it cannot tell', () => {
+ const joinedWith = (configuration: AgentConfiguration) => {
+ const f = swarm()
+ const startId = f.lead('mate-mac').result.startId as string
+ return messages(f.run({ type: 'agent.started', startId, harnessId: 'pm', configuration }, owner, hosted(f, 'mate-team')), f.app.conversationId)
+ }
+ expect(joinedWith({ ...config, model: 'claude-sonnet-5-5', effort: 'high' })).toEqual(
+ ['Product Manager started on MacBook Pro. It asked for opus at xhigh and runs claude-sonnet-5-5 at high there.'])
+ expect(joinedWith({ ...config, model: 'claude-opus-5-5', effort: 'high' })).toEqual(
+ ['Product Manager started on MacBook Pro. It asked for opus at xhigh and runs claude-opus-5-5 at high there.'])
+ expect(joinedWith({ ...config, model: 'claude-opus-5-5', effort: 'xhigh' })).toEqual(['Product Manager started on MacBook Pro.'])
+ expect(joinedWith({ ...config, model: 'claude-opus-5-5[1m]', effort: 'auto' })).toEqual(['Product Manager started on MacBook Pro.'])
+ expect(joinedWith({ ...config, model: null, effort: null })).toEqual(['Product Manager started on MacBook Pro.'])
+ })
+
it('running, becomes the project\'s Lead and says on which machine', () => {
const f = swarm()
const startId = f.lead('mate-mac').result.startId as string
- const joined = f.run({ type: 'agent.started', startId, harnessId: 'pm', configuration: config }, owner, hosted(f, 'mate-team'))
+ const joined = f.run({ type: 'agent.started', startId, harnessId: 'pm', configuration: { ...config, effort: 'xhigh' } }, owner, hosted(f, 'mate-team'))
const agentId = joined.result.agentId as string
const home = f.state.conversations.find(c => c.id === f.app.conversationId)!
expect(home).toMatchObject({ leadId: agentId, agentIds: [agentId] })
diff --git a/backend/src/superTabs/leadStart.ts b/backend/src/superTabs/leadStart.ts
index 711e0dd66..43760c848 100644
--- a/backend/src/superTabs/leadStart.ts
+++ b/backend/src/superTabs/leadStart.ts
@@ -164,7 +164,30 @@ export function leadJoined(state: SuperTabState, start: AgentStart, home: Conver
if (!home.leadId || !home.agentIds.includes(home.leadId)) home.leadId = agentId
const placement = placementOf(state, start)
if (placement) placement.status = 'started'
- return `${LEAD_NAME} started on ${placement?.machineName ?? state.machines?.find(m => m.machineId === start.request.machineId)?.name ?? 'its machine'}.`
+ const started = `${LEAD_NAME} started on ${placement?.machineName ?? state.machines?.find(m => m.machineId === start.request.machineId)?.name ?? 'its machine'}.`
+ const ran = state.agents.find(a => a.id === agentId)?.configuration
+ const other = ran && otherThanAsked(start.request, ran)
+ return other ? `${started} ${other}` : started
+}
+
+/** A Product Manager's start line when its machine could not launch it with the model and effort it asked for, so it runs its
+ * engine's own model (Desktop's own-machine start; the Swarm's start says it in leadJoined). */
+export const launchRefusedLine = (asked: { model: string; effort?: string }) =>
+ `${LEAD_NAME} started. It asked for ${asked.effort ? `${asked.model} at ${asked.effort}` : asked.model} and runs its engine\u2019s own model there: this machine could not launch it with them.`
+
+/** A Claude id by its family (`claude-opus-5-5[1m]` is opus), as routing rates it (rules.ts policyQuality). */
+const family = (model: string) => /haiku|sonnet|opus|fable/.exec(model.toLowerCase())?.[0] ?? model.toLowerCase()
+/** What a started agent runs when it is known to differ from the model or effort its start asked for, said for its chat; null
+ * when it runs them or cannot tell (no model reported, an effort read as auto). Its start never fails over this. */
+function otherThanAsked(asked: { model?: string; effort?: string }, ran: { model: string | null; effort: string | null }): string | null {
+ if (!asked.model) return null
+ const effortKnown = !!ran.effort && ran.effort !== 'auto' && ran.effort !== 'default'
+ const modelDiffers = !!ran.model && family(ran.model) !== family(asked.model)
+ const effortDiffers = effortKnown && !!asked.effort && ran.effort !== asked.effort
+ if (!modelDiffers && !effortDiffers) return null
+ const wanted = asked.effort ? `${asked.model} at ${asked.effort}` : asked.model
+ const runs = [ran.model ?? 'its engine\u2019s own model', ...(effortKnown ? [`at ${ran.effort}`] : [])].join(' ')
+ return `It asked for ${wanted} and runs ${runs} there.`
}
/** Its start failed with [reason]: the project says why and waits for its person to name a machine again. The line its
diff --git a/backend/src/superTabs/projects.test.ts b/backend/src/superTabs/projects.test.ts
index a1bb28ac2..ef8efb874 100644
--- a/backend/src/superTabs/projects.test.ts
+++ b/backend/src/superTabs/projects.test.ts
@@ -4,6 +4,7 @@ import { applyCommand, commandSchema, type Command, type CommandContext } from '
import { agentOnly, createSuperTab, SuperTabError, visibleState, type Actor, type MessageDraft } from './model.js'
import { canReadAgent, canWatchAgent, markConfidential, projectOf, projectsOf, readConversation, skillModeOf, skillSetOf, watchersLost } from './projects.js'
import { mayDrive } from './terminal.js'
+import { DEFAULT_ROUTING_POLICY } from './routingPolicy.js'
const owner: Actor = { kind: 'person', userId: 'owner', email: '[email protected]' }
const peer: Actor = { kind: 'person', userId: 'peer', email: '[email protected]' }
@@ -441,6 +442,51 @@ describe('custom role sets', () => {
expect(skillSetOf({ ...projectOf(f.state, p.projectId), skillMode: undefined })).toBe('orchestration')
})
+ it('keeps a role\'s default engine, model and effort, and a person\'s start that names no model takes it for that engine', () => {
+ const { f, p, roles } = custom()
+ const writer = { ...role('abcdefabcdef', 'Docs writer', 'builder'), defaults: { engine: 'codex', model: 'gpt-6.1-sol', effort: 'medium' } }
+ f.run({ type: 'project.role.set', projectId: p.projectId, role: writer } as Command, peer)
+ f.run({ type: 'project.skills', projectId: p.projectId, mode: 'custom' }, peer)
+ expect(roles()!.find(r => r.id === 'abcdefabcdef')).toMatchObject({ defaults: { engine: 'codex', model: 'gpt-6.1-sol', effort: 'medium' } })
+ const startWith = (extra: Record<string, unknown>) => {
+ const startId = String(f.run({ type: 'agent.start', request: request(p.conversationId, extra) } as Command, peer).startId)
+ return f.state.starts!.find(s => s.id === startId)!.request
+ }
+ expect(startWith({ roleId: 'abcdefabcdef' })).toMatchObject({ engine: 'codex', model: 'gpt-6.1-sol', effort: 'medium' })
+ expect(startWith({ roleId: 'abcdefabcdef', model: 'gpt-6-luna' })).toMatchObject({ model: 'gpt-6-luna' })
+ expect(startWith({ roleId: 'abcdefabcdef', model: 'gpt-6-luna' })).not.toHaveProperty('effort')
+ expect(startWith({ roleId: 'abcdefabcdef', engine: 'claude' })).not.toHaveProperty('model')
+ // The Engineer of the copied Default set has none: routing chooses.
+ expect(startWith({ roleId: 'dev' })).not.toHaveProperty('model')
+ const bad = (defaults: unknown) => () => f.run({ type: 'project.role.set', projectId: p.projectId, role: { ...writer, defaults } } as Command, peer)
+ expect(bad({ engine: 'cursor' })).toThrow()
+ expect(bad({ engine: 'codex', model: 'x'.repeat(201) })).toThrow()
+ expect(bad({ engine: 'codex', other: true })).toThrow()
+ })
+
+ it('starts on its engine\'s own model, and says why, when the owner\'s rules or routing policy rule a role default out', () => {
+ // Review of #2274: a role default never overrides the owner's model list or rules.
+ const { f, p } = custom()
+ const writer = { ...role('abcdefabcdef', 'Docs writer', 'builder'), defaults: { engine: 'codex', model: 'gpt-6.1-sol', effort: 'medium' } }
+ f.run({ type: 'project.role.set', projectId: p.projectId, role: writer } as Command, peer)
+ f.run({ type: 'project.skills', projectId: p.projectId, mode: 'custom' }, peer)
+ const startWith = (context: Partial<CommandContext> = {}) => {
+ const startId = String(f.run({ type: 'agent.start', request: request(p.conversationId, { roleId: 'abcdefabcdef' }) } as Command, peer, context).startId)
+ return { request: f.state.starts!.find(s => s.id === startId)!.request, lines: f.messages.filter(m => m.conversationId === p.conversationId).map(m => m.text) }
+ }
+ const off = { routingPolicy: { ...DEFAULT_ROUTING_POLICY, models: DEFAULT_ROUTING_POLICY.models.map(m => m.model === 'gpt-6.1-sol' ? { ...m, enabled: false } : m) } }
+ const turnedOff = startWith(off)
+ expect(turnedOff.request).not.toHaveProperty('model')
+ expect(turnedOff.request).not.toHaveProperty('effort')
+ expect(turnedOff.lines).toEqual(['Builder starts on its engine\u2019s own model, not gpt-6.1-sol at medium: the routing policy turns off Codex gpt-6.1-sol.'])
+ // A rule the plain start already breaks comes first; the default is still judged by the next (re-review of #2274).
+ f.run({ type: 'rule.set', projectId: p.projectId, rule: { kind: 'minEffort', engine: 'codex', effort: 'high' }, text: 'At least high.' } as Command, peer)
+ f.run({ type: 'rule.set', projectId: p.projectId, rule: { kind: 'forbidModel', engine: 'codex', model: 'sol' }, text: 'No Sol.' } as Command, peer)
+ const ruled = startWith()
+ expect(ruled.request).not.toHaveProperty('model')
+ expect(ruled.lines).toContain('Builder starts on its engine\u2019s own model, not gpt-6.1-sol at medium: the owner\'s rule "No Sol." rules out Codex gpt-6.1-sol.')
+ })
+
it('starts and assigns by a role id that exists in the custom set and matches the agent\'s kind', () => {
const { f, p } = custom()
f.run({ type: 'project.role.set', projectId: p.projectId, role: role('abcdefabcdef', 'Docs writer', 'builder') }, peer)
diff --git a/backend/src/superTabs/projects.ts b/backend/src/superTabs/projects.ts
index 59b19357b..163a846da 100644
--- a/backend/src/superTabs/projects.ts
+++ b/backend/src/superTabs/projects.ts
@@ -12,7 +12,26 @@ export const SKILL_SET_NAMES: Record<SkillSet, string> = { default: 'Default', o
export type RoleKind = 'lead' | 'builder' | 'reviewer'
/** A role of a project's custom set as the tab state keeps it. Its text lives outside the state (store.ts roleText), so a
* roster or tab read never carries up to 20 x 64 KB of skill text; `version` names the text. */
-export interface ProjectRole { id: string; name: string; kind: RoleKind; version: string }
+export interface ProjectRole { id: string; name: string; kind: RoleKind; version: string; defaults?: RoleDefaults }
+/** What an agent of a role starts on when its start names no model: an engine, and on it a model and effort. */
+export interface RoleDefaults { engine: 'claude' | 'codex'; model?: string; effort?: string }
+/** The built-in sets' defaults (Scholes's roadmap, piece 1, 10-30): the Product Manager runs Claude Opus 5.5 at xhigh. Engineers
+ * and temporary agents are left to routing; a Reviewer's is a route floor, the reviewed Builder's strength (cli route.ts). */
+export const BUILT_IN_ROLE_DEFAULTS: Partial<Record<RoleKind, RoleDefaults>> = { lead: { engine: 'claude', model: 'opus', effort: 'xhigh' } }
+
+/** The defaults an agent of [kind] (by [roleId] in a custom set) starts with: its custom role's own, else the built-in ones. */
+export function roleDefaults(project: SwarmProject, kind: RoleKind, roleId?: string): RoleDefaults | undefined {
+ const custom = skillSetOf(project) === 'custom' ? project.roles?.find(r => r.id === roleId && r.kind === kind) ?? project.roles?.find(r => r.kind === kind) : undefined
+ return custom?.defaults ?? BUILT_IN_ROLE_DEFAULTS[kind]
+}
+
+/** [request] with its role's [defaults] filled in when it names no model, on the defaults' engine alone; a named effort is kept. A
+ * grid model chooses its own. */
+export function withRoleDefaults<T extends { engine: string; model?: string; effort?: string; gridModel?: string }>(request: T, defaults: RoleDefaults | undefined): T {
+ if (!defaults || request.model || request.gridModel || defaults.engine !== request.engine || !defaults.model) return request
+ const effort = request.effort ?? defaults.effort
+ return { ...request, model: defaults.model, ...(effort ? { effort } : {}) }
+}
export const MAX_ROLES = 20
export const roleVersion = (text: string): string => createHash('sha256').update(text).digest('hex').slice(0, 16)
export interface SwarmProject {
diff --git a/backend/src/superTabs/routingPolicy.test.ts b/backend/src/superTabs/routingPolicy.test.ts
index 9be764b60..3fbf0d2a6 100644
--- a/backend/src/superTabs/routingPolicy.test.ts
+++ b/backend/src/superTabs/routingPolicy.test.ts
@@ -11,6 +11,10 @@ describe('routing policy', () => {
expect(new Set(DEFAULT_ROUTING_POLICY.models.map(m => m.engine))).toEqual(new Set(['claude', 'codex']))
})
+ it('offers Claude Opus at xhigh as its own row, dearer than at high for the extra thinking', () => {
+ expect(DEFAULT_ROUTING_POLICY.models).toContainEqual({ engine: 'claude', model: 'opus', effort: 'xhigh', quality: 3, cost: 4, enabled: true })
+ })
+
it('uses the default when the account has none, and merges a tab override field by field', () => {
expect(effectivePolicy(null, null)).toEqual({ policy: DEFAULT_ROUTING_POLICY, warnings: [], overridden: [] })
const account = { ...DEFAULT_ROUTING_POLICY, quotaReserve: 20, notes: 'Frontend prefers Claude.' }
diff --git a/backend/src/superTabs/routingPolicy.ts b/backend/src/superTabs/routingPolicy.ts
index bdb4fb1d3..c18dc34fc 100644
--- a/backend/src/superTabs/routingPolicy.ts
+++ b/backend/src/superTabs/routingPolicy.ts
@@ -61,6 +61,9 @@ export const DEFAULT_ROUTING_POLICY: RoutingPolicy = {
version: 1,
models: [
{ engine: 'claude', model: 'opus', effort: 'high', quality: 3, cost: 3, enabled: true },
+ // Opus 5.5 at xhigh, as the Product Manager runs (role defaults, projects.ts): the same price per token as at high, more
+ // thinking per task, so dearer; at equal strength routing keeps choosing high unless a rule or a person asks for more.
+ { engine: 'claude', model: 'opus', effort: 'xhigh', quality: 3, cost: 4, enabled: true },
{ engine: 'codex', model: 'default', effort: 'default', quality: 3, cost: 2, enabled: true },
// Next to `default` so the form lists Codex's rows together. List order ranks nothing: the CLI route breaks ties by title.
...ADDED_ROWS,
diff --git a/backend/src/superTabs/rules.ts b/backend/src/superTabs/rules.ts
index e80497909..3cd14bdac 100644
--- a/backend/src/superTabs/rules.ts
+++ b/backend/src/superTabs/rules.ts
@@ -4,7 +4,7 @@
* half the time on 2026-10-22 (Haiku, a stopping agent, low effort) because it did not know the owner's rules. */
import { z } from 'zod'
import type { Agent, SuperTabState, TaskRequirement } from './model.js'
-import type { RoutingPolicy } from './routingPolicy.js'
+import { gridQuality, type RoutingPolicy } from './routingPolicy.js'
import { downSince } from './machines.js'
import { canStart, REVIEW_START_MS, standing } from './reviewSeats.js'
@@ -126,6 +126,10 @@ export function policyQuality(policy: RoutingPolicy, engine: string, model: stri
const SMALL = /(^|[^a-z0-9])(mini|nano)([^a-z0-9]|$)/i
/** A target's strength: an agent launched on the engine's own model falls back to the `default` row (Codex reports its slug). */
export const targetQuality = (policy: RoutingPolicy, t: RunTarget) => policyQuality(policy, t.engine, t.model, t.effort, !!t.launchedDefault)
+/** How strong an agent counts: a grid model by the policy's grid rating, else as [targetQuality] (cli route.ts reviewedBuilder). */
+export const agentQuality = (state: SuperTabState, policy: RoutingPolicy, worker: Agent): number =>
+ worker.gridModel ? gridQuality(policy, worker.gridModel, state.starts?.find(s => s.harnessId === worker.harnessId && s.request.machineId === worker.machineId)?.request.gridName ?? '')
+ : targetQuality(policy, agentTarget(state, worker))
/** A model family: a grid model's own, else its engine's. */
const familyOf = (t: { engine: string; gridModel?: string }) => t.gridModel ? `grid:${t.gridModel}` : t.engine
diff --git a/cli/src/superTabs/route.spec.ts b/cli/src/superTabs/route.spec.ts
index 8ff588bed..fb8838390 100644
--- a/cli/src/superTabs/route.spec.ts
+++ b/cli/src/superTabs/route.spec.ts
@@ -73,6 +73,29 @@ describe('quota and rates', () => {
})
describe('choose', () => {
+ // A Reviewer's role default (Scholes's roadmap, piece 1): at least the reviewed Builder's strength, while one can run.
+ it('holds a review to the reviewed Builder\'s strength, and never leaves it with nobody when the strongest is busy', () => {
+ const strong = probe({ engine: 'codex', model: 'default', effort: 'default', quality: 3, cost: 2, machineId: 'm2', machineName: 'mac' })
+ const weaker = probe()
+ const low = a({ difficulty: 'low' })
+ const held = choose([strong, weaker], policy, low, NOW, [], [], [], [], 3)
+ if ('error' in held) throw new Error('unexpected')
+ expect(held.shown.map(s => s.title)).toEqual(['New agent · Codex default default · mac'])
+ expect(held).toMatchObject({ floor: 3, belowFloor: false })
+ // Its machine is full: the weaker one still reviews, marked below the floor.
+ const busy = choose([{ ...strong, refusals: ['This machine runs as many agents as its owner allows.'] }, weaker], policy, low, NOW, [], [], [], [], 3)
+ if ('error' in busy) throw new Error('unexpected')
+ expect(busy.shown.map(s => s.title)).toEqual(['New agent · Claude sonnet medium · remote-1'])
+ expect(busy).toMatchObject({ floor: 3, belowFloor: true })
+ // Out of quota, the strong one is still offered first rather than a weaker one.
+ const short = choose([{ ...strong, quota: windows([99, 3 * H], [90, 5 * D]) }, weaker], policy, low, NOW, [], [], [], [], 3)
+ if ('error' in short) throw new Error('unexpected')
+ expect(short.shown[0]!.title).toBe('New agent · Codex default default · mac')
+ // Without a reviewed Builder, the task's own floor.
+ const plain = choose([strong, weaker], policy, low, NOW)
+ if ('error' in plain) throw new Error('unexpected')
+ expect(plain.floor).toBe(1)
+ })
it('returns NO_CANDIDATE with reasons when nothing can run', () => {
expect(choose([probe({ refusals: ['Machine is offline.'] })], policy, a())).toEqual({ error: 'NO_CANDIDATE',
excluded: [{ title: 'New agent · Claude sonnet medium · remote-1', reason: 'Machine is offline.', machine: 'remote-1' }] })
diff --git a/cli/src/superTabs/route.ts b/cli/src/superTabs/route.ts
index c159dd618..872333e06 100644
--- a/cli/src/superTabs/route.ts
+++ b/cli/src/superTabs/route.ts
@@ -233,7 +233,7 @@ export function rateFor(policy: Policy, engine: string, model: string | null, ef
const SMALL = /(^|[^a-z0-9])(mini|nano)([^a-z0-9]|$)/i
/** What a reviewed Builder ran: its engine, and the grid model its engine drove. */
-export interface Reviewed { engine: string; gridModel?: string }
+export interface Reviewed { engine: string; gridModel?: string; quality?: number }
/** A model family: a grid model's own, else its engine's. */
const familyOf = (t: Reviewed) => t.gridModel ? `grid:${t.gridModel}` : t.engine
/** Why [p] may not review (Ken, 2026-10-29: a small model never reviews again): a model served on the Swarm's grid, one rated
@@ -445,9 +445,11 @@ function withEveryMachine<T extends { machineId: string }>(ranked: T[]): T[] {
return ranked.filter(p => keep.has(p))
}
-/** `avoid`: accounts of agents that lost this task (a review's Reviewer whose model kept failing): any other account goes first. */
+/** `avoid`: accounts of agents that lost this task (a review's Reviewer whose model kept failing): any other account goes first.
+ * `reviewFloor`: a review's reviewed Builder's strength, the Reviewer role's default (Scholes's roadmap, piece 1): the floor
+ * rises to it, and like any floor it gives way when nobody that strong can run, so a review never waits for nobody. */
export function choose(probes: Probe[], policy: Policy, a: Assessment, now: number = Date.now(), open: Commitment[] = [], rules: SwarmRule[] = [], held: HeldModel[] = [],
- avoid: string[] = []): Choice | { error: 'NO_CANDIDATE'; excluded: Excluded[] } {
+ avoid: string[] = [], reviewFloor = 0): Choice | { error: 'NO_CANDIDATE'; excluded: Excluded[] } {
// A lifted row can equal another row on the same machine (Codex `default` lifted to high beside Codex high); one is kept.
// A person asking for a local model considers local models alone, whatever their strength.
if (a.local) probes = probes.filter(p => p.gridModel)
@@ -469,7 +471,7 @@ export function choose(probes: Probe[], policy: Policy, a: Assessment, now: numb
else excluded.push({ title: 'Local models', reason: LOCAL_NONE })
}
if (!viable.length) return { error: 'NO_CANDIDATE', excluded }
- const floor = floorFor(policy, a)
+ const floor = Math.max(floorFor(policy, a), Math.min(3, reviewFloor))
const meeting = a.local || named ? viable : viable.filter(p => p.quality >= floor)
const byFloor = meeting.length ? meeting : viable
// Strength beats fit (owner, 2026-10-21): a hard task never goes to a weaker model because the strong ones are short of quota.
diff --git a/cli/src/superTabs/routeCommand.spec.ts b/cli/src/superTabs/routeCommand.spec.ts
index 9725e67da..24c0bb99f 100644
--- a/cli/src/superTabs/routeCommand.spec.ts
+++ b/cli/src/superTabs/routeCommand.spec.ts
@@ -273,6 +273,32 @@ describe('routeTask', () => {
Object.assign(t.state.conversations[2]!, { assignment: null })
expect(await routeTask(input, scoped({ tab: t }), where as never, opener(), () => 'op')).toMatchObject({ ok: true })
})
+ it('holds a review to the reviewed Builder\'s strength: a top-tier Codex Builder is reviewed at the top tier, a grid Builder at its own', async () => {
+ const t = tab(); t.state.agents = agents.map(a => a.id === 'a1' ? { ...a, role: 'reviewer' } : a)
+ t.state.conversations.push({ id: 'g0', title: 'Built', leadId: 'lead', agentIds: ['lead'], archived: false, brief: '', checks: [],
+ assignment: { id: 'b', agentId: 'gone', status: 'review', configuration: { engine: 'codex' } } } as never)
+ Object.assign(t.state.conversations[1]!, { reviewOf: 'g0' })
+ // The idle Sonnet Reviewer is cheaper, but the Builder ran Codex's top tier.
+ const s = scoped({ tab: t })
+ expect(await routeTask(input, s, where as never, opener(), () => 'op')).toMatchObject({ ok: true, pick: { kind: 'new', engine: 'claude', model: 'opus' } })
+ expect(recorded(s).command.decision).toMatchObject({ floor: 3, belowFloor: false })
+ // A Builder on a grid model of quality 2: the Sonnet Reviewer will do.
+ t.state.agents.push({ id: 'b1', name: 'Kimi', machineId: 'm1', harnessId: 'hb', configuration: { engine: 'codex', model: 'default', effort: 'default' }, gridModel: 'moonshotai/kimi-k3' } as never)
+ Object.assign(t.state.conversations[2]!, { assignment: { id: 'b', agentId: 'b1', status: 'review' } })
+ expect(await routeTask(input, scoped({ tab: t }), where as never, opener(), () => 'op')).toMatchObject({ ok: true, pick: { kind: 'member', agentId: 'a1' } })
+ })
+ it('rates a Builder launched on its engine\'s own model by that engine\'s default row, whatever slug it reports (review of #2274)', async () => {
+ const t = tab(); t.state.agents = agents.map(a => a.id === 'a1' ? { ...a, role: 'reviewer' } : a)
+ // Codex reports the slug it runs, which the policy does not name; its start named no model.
+ t.state.agents.push({ id: 'b2', name: 'Codex builder', machineId: 'm1', harnessId: 'hb2', configuration: { engine: 'codex', model: 'gpt-6-luna', effort: 'high' } } as never)
+ Object.assign(t.state, { starts: [{ id: 's2', harnessId: 'hb2', request: { machineId: 'm1', engine: 'codex' } }] })
+ t.state.conversations.push({ id: 'g0', title: 'Built', leadId: 'lead', agentIds: ['lead'], archived: false, brief: '', checks: [],
+ assignment: { id: 'b', agentId: 'b2', status: 'review' } } as never)
+ Object.assign(t.state.conversations[1]!, { reviewOf: 'g0' })
+ const s = scoped({ tab: t })
+ expect(await routeTask(input, s, where as never, opener(), () => 'op')).toMatchObject({ ok: true, pick: { kind: 'new', engine: 'claude', model: 'opus' } })
+ expect(recorded(s).command.decision).toMatchObject({ floor: 3, belowFloor: false })
+ })
it('lets the Builder\'s engine review at its top tier when the only other engine is on a machine the task may not use', async () => {
const pool = (machineId: string, engines: string[], patch: Record<string, unknown> = {}) => ({ machineId, name: machineId, cwd: '/w', engines, paused: false, contributorId: 'owner',
observation: { receivedAt: Date.now(), resources: { memoryTotalBytes: 32e9, memoryUsedBytes: 2e9, projectDiskFreeBytes: 200e9 }, tools: { git: true }, runningHarnessIds: [],
diff --git a/cli/src/superTabs/routeCommand.ts b/cli/src/superTabs/routeCommand.ts
index 7d5fd6eb9..495ed31c3 100644
--- a/cli/src/superTabs/routeCommand.ts
+++ b/cli/src/superTabs/routeCommand.ts
@@ -322,7 +322,7 @@ export async function routeTask(input: { tabId: string; conversationId: string;
const devices = object(object(start?.request).requirements).devices
return required.devices.every(d => Array.isArray(devices) && devices.includes(d))
}
- const builder = review ? reviewedBuilder(conversations.find(c => c.id === group.reviewOf), agents) : null
+ const builder = review ? reviewedBuilder(conversations.find(c => c.id === group.reviewOf), agents, list(state.starts), policy) : null
// Another engine counts only on a machine the task may run on, and that its access lets take this project's work.
const teamRefused = (p: Probe) => { const why = machines.get(p.machineId)?.pool?.teammatesRefused; return typeof why === 'string' && p.refusals.includes(why) }
const otherFamily = otherFamilyReviews(probes.filter(p => !outside(p.machineId) && !teamRefused(p)), builder, rules, Date.now())
@@ -342,7 +342,7 @@ export async function routeTask(input: { tabId: string; conversationId: string;
const failedOn = text(lostAttempt.machineId) ?? text(lostBy?.machineId), failedEngine = text(lostAttempt.engine) ?? text(object(lostBy?.configuration).engine)
const avoid = failedOn && failedEngine ? [...new Set([`${failedOn}:${failedEngine}`,
...probes.filter(p => p.machineId === failedOn && p.engine === failedEngine && !p.gridModel).map(accountOf)])] : []
- const choice = choose(probes, policy, assessment, Date.now(), working, rules, heldLocalModels(state), avoid)
+ const choice = choose(probes, policy, assessment, Date.now(), working, rules, heldLocalModels(state), avoid, builder?.quality ?? 0)
choice.excluded.push(...offlineModels(state, policy, assessment, review))
// The task stays in the Lead's queue rather than going where it cannot be done.
if ('error' in choice) return { ...choice, leftOut: leftOut(choice.excluded, []), ...required.machines || required.devices.length ? { waiting: true, detail: WAITING } : {} }
@@ -395,13 +395,17 @@ export function leftOut(excluded: Excluded[], shown: Array<{ machineName: string
const MAX_LEFT_OUT = 20, MAX_REASONS = 4
/** What the reviewed group's last attempt ran on: its agent's engine and grid model while it is here, else its assignment's
- * engine. Null before any attempt. */
-function reviewedBuilder(reviewed: Json | undefined, agents: Json[]): Reviewed | null {
+ * engine; and how strong that was, which a Reviewer is held to (route.ts choose). Null before any attempt. */
+function reviewedBuilder(reviewed: Json | undefined, agents: Json[], starts: Json[], policy: Policy): Reviewed | null {
const assignment = object(reviewed?.assignment)
if (!assignment.id) return null
- const agent = agents.find(a => a.id === assignment.agentId)
+ // Rated as its route rates a member: by the effort and model it was launched with (review of #2274).
+ const found = agents.find(a => a.id === assignment.agentId), agent = found && withLaunchEffort(found, starts)
const gridModel = text(agent?.gridModel)
- return { engine: String(object(agent?.configuration ?? assignment.configuration).engine), ...(gridModel ? { gridModel } : {}) }
+ const ran = object(agent?.configuration ?? assignment.configuration), engine = String(ran.engine)
+ const quality = gridModel ? gridQuality(policy, gridModel, text(agent?.gridName) ?? '')
+ : rateFor(policy, engine, text(ran.model), text(ran.effort), agent?.engineDefault === true).quality
+ return { engine, ...(gridModel ? { gridModel } : {}), quality }
}
/** The next two rows, and the best row of every other machine, so the Lead can choose another machine with an overrideReason. */
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index b93252118..79614780d 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -294,8 +294,21 @@ class AgentCreationAttempt {
String? creationId,
this.holdWait,
this.beforeSubmit,
+ this.launchModel,
}) : _id = creationId ?? _newCreationId();
+ /// A model and effort for this session alone, passed as the engine's own
+ /// flags (cli lib/launchModel.ts): a Product Manager's role default. A
+ /// machine that cannot take them refuses before anything launches, and the
+ /// same request then starts the agent on its engine's own model.
+ final ({String model, String effort})? launchModel;
+ bool _launchModelDropped = false;
+
+ /// The [launchModel] the machine refused, once the agent started on its
+ /// engine's own model instead; null when it launched with it.
+ ({String model, String effort})? get launchModelRefused =>
+ _launchModelDropped ? launchModel : null;
+
/// How long a request the machine holds is waited for before the create
/// answers ([AppNotifier._createFollowingHold]). Null answers at once with
/// what it waits for, as a form wants: the person reads it and may cancel.
@@ -362,6 +375,15 @@ class AgentCreationAttempt {
String? _existingFolder;
String? get existingFolder => _existingFolder;
+ /// After the machine refused a launch model before launching anything
+ /// (AppNotifier.createAgent): the request may be sent again without it.
+ void _retryWithoutLaunchModel() {
+ _launchModelDropped = true;
+ _finished = false;
+ _outcome = null;
+ _refusal = null;
+ }
+
String? _complete(String? error) {
_finished = true;
_awaitingConfirmation = false;
@@ -14822,7 +14844,9 @@ class AppNotifier extends ChangeNotifier {
PaneSplitRequest? split,
AgentCreationAttempt? attempt,
HarnessPlacement? placement,
- }) {
+ }) async {
+ final creation = attempt ?? AgentCreationAttempt();
+ final launch = creation._launchModelDropped ? null : creation.launchModel;
final choices = <String, dynamic>{
'engine': engine,
if (projectFolder == null && folder != null) 'cwd': folder,
@@ -14842,6 +14866,8 @@ class AppNotifier extends ChangeNotifier {
},
'gridModel': ?model?.id,
'gridName': ?model?.grid,
+ 'model': ?launch?.model,
+ 'effort': ?launch?.effort,
// A first message the engine is opened with, and the pane's name before
// the engine reports a session title. Both absent unless asked for: a
// daemon that predates them ignores an unknown field, but one that knows
@@ -14856,7 +14882,6 @@ class AppNotifier extends ChangeNotifier {
// same refusal for an engine that has no such thing (`AGENT_UNSUPPORTED`).
'agent': ?agent,
};
- final creation = attempt ?? AgentCreationAttempt();
Future<String?> ask() => _create(
machineId,
choices,
@@ -14867,9 +14892,27 @@ class AppNotifier extends ChangeNotifier {
attempt: creation,
placement: placement,
);
+ final answer = await _createFollowingHold(creation, creation.holdWait, ask);
+ if (launch == null ||
+ !_launchModelRefusals.contains(creation._refusal) ||
+ _disposed) {
+ return answer;
+ }
+ // Refused before any receipt: the same request, without them, so the
+ // agent starts on its engine's own model rather than not at all.
+ choices
+ ..remove('model')
+ ..remove('effort');
+ creation._retryWithoutLaunchModel();
return _createFollowingHold(creation, creation.holdWait, ask);
}
+ /// A machine's refusals of a launch model, made before anything launched.
+ static const _launchModelRefusals = {
+ 'LAUNCH_MODEL_UNSUPPORTED',
+ 'INVALID_LAUNCH_MODEL',
+ };
+
/// How often a harness the machine holds or is starting is asked after
/// ([_createFollowingHold]): the pace `harness new` asks at.
@visibleForTesting
@@ -15440,6 +15483,7 @@ class AppNotifier extends ChangeNotifier {
// Refusals that happen before a launch are safe to correct. INTERNAL,
// spawn timeouts and connection failures cannot prove nothing started.
const refusedBeforeLaunch = {
+ ..._launchModelRefusals,
'INVALID_PROJECT_SOURCE',
'INVALID_REPOSITORY',
'PROJECT_EXISTS',
diff --git a/desktop/lib/state/harness_launch_integration.dart b/desktop/lib/state/harness_launch_integration.dart
index e6e493bb4..0106ab070 100644
--- a/desktop/lib/state/harness_launch_integration.dart
+++ b/desktop/lib/state/harness_launch_integration.dart
@@ -99,6 +99,10 @@ class HarnessLaunchIntegration {
final bool Function()? needsAttachmentReview;
final Future<void> Function(bool resend)? resolveAttachments;
bool pending = false;
+
+ /// The model and effort the launch asked for that its machine refused, so
+ /// the agent runs its engine's own model: its join says so in the chat.
+ ({String model, String effort})? launchModelRefused;
bool completed = false;
String? preparedPrompt;
// What a request was sent with. The journal keeps them, and a [pending]
diff --git a/desktop/lib/state/lead_placement.dart b/desktop/lib/state/lead_placement.dart
index 050c2b90b..084d61ba8 100644
--- a/desktop/lib/state/lead_placement.dart
+++ b/desktop/lib/state/lead_placement.dart
@@ -229,6 +229,7 @@ class LeadModelList {
this.disabledEngines = const {},
this.disabledModels = const {},
this.gridModels = true,
+ this.rows = const {},
});
/// Engines the list has no enabled model of.
@@ -240,6 +241,21 @@ class LeadModelList {
/// Whether the list lets work run on models served on the Swarm's grid.
final bool gridModels;
+ /// Whether each row is on, as (engine, model, effort).
+ final Map<(String, String, String), bool> rows;
+
+ /// Whether [engine] may run [model] at [effort], as the Swarm judges a
+ /// role's default (backend commands.ts): that effort's row when the list
+ /// has one, else any row of the model. A model the list does not name is
+ /// left to the Swarm.
+ bool modelOn(String engine, String model, String effort) {
+ final named = {
+ for (final MapEntry(:key, :value) in rows.entries)
+ if (key.$1 == engine && key.$2 == model) key.$3: value,
+ };
+ return named.isEmpty || (named[effort] ?? named.values.any((on) => on));
+ }
+
/// Why the list rules [engine] out, or null.
String? engineRefusal(String engine) => disabledEngines.contains(engine)
? 'The Swarm’s model list has no enabled ${_engineName(engine)} model.'
@@ -259,6 +275,7 @@ class LeadModelList {
/// Read from the Swarm's routing policy; null reads as an empty list.
factory LeadModelList.of(Map<String, dynamic>? policy) {
final byModel = <(String, String), bool>{};
+ final rows = <(String, String, String), bool>{};
final byEngine = <String, bool>{};
for (final row in policy?['models'] as List? ?? const []) {
if (row case {
@@ -266,6 +283,10 @@ class LeadModelList {
'model': final String model,
'enabled': final bool enabled,
}) {
+ if (row['effort'] case final String effort) {
+ rows[(engine, model, effort)] =
+ (rows[(engine, model, effort)] ?? false) || enabled;
+ }
byModel[(engine, model)] =
(byModel[(engine, model)] ?? false) || enabled;
byEngine[engine] = (byEngine[engine] ?? false) || enabled;
@@ -280,6 +301,7 @@ class LeadModelList {
for (final MapEntry(:key, :value) in byModel.entries)
if (!value) key,
},
+ rows: rows,
gridModels: switch (policy?['localModels']) {
{'enabled': false} => false,
_ => true,
diff --git a/desktop/lib/state/new_harness.dart b/desktop/lib/state/new_harness.dart
index 868279181..bad445a87 100644
--- a/desktop/lib/state/new_harness.dart
+++ b/desktop/lib/state/new_harness.dart
@@ -1734,9 +1734,34 @@ class NewHarnessController extends ChangeNotifier {
notifyListeners();
}
- /// The model the Product Manager runs: the one chosen, else its engine's
- /// default, which nothing knows before it starts.
- String get leadModelLabel => _model != null ? modelLabel : 'Default model';
+ /// The model the Product Manager runs: the one chosen; else its role's
+ /// default, Claude Opus 5.5 at xhigh (Scholes's roadmap, piece 1); else its
+ /// engine's own, which nothing knows before it starts.
+ String get leadModelLabel => _model != null
+ ? modelLabel
+ : leadLaunchModel != null
+ ? '${kLeadModel.label} · ${kLeadModel.effort}'
+ : 'Default model';
+
+ /// The model and effort a Claude Product Manager is launched with when its
+ /// person chose no model and the Swarm's model list leaves Opus on: on this
+ /// Mac as flags. Through the Swarm its start names none, and the Swarm
+ /// fills the same default under the owner's list and rules (backend
+ /// commands.ts). A machine that cannot take them starts it on the engine's
+ /// own (AppNotifier.createAgent).
+ ({String model, String effort})? get leadLaunchModel =>
+ integration?.swarmRole == 'lead' &&
+ _engine == 'claude' &&
+ _model == null &&
+ !asGuest &&
+ (integration?.leadModels?.modelOn(
+ 'claude',
+ kLeadModel.model,
+ kLeadModel.effort,
+ ) ??
+ true)
+ ? (model: kLeadModel.model, effort: kLeadModel.effort)
+ : null;
/// Why the Swarm's model list rules out [model] (null for the engine's
/// default) for a new project's Product Manager, or null.
@@ -4271,6 +4296,7 @@ class NewHarnessController extends ChangeNotifier {
_attempt = AgentCreationAttempt(
background: integration != null,
beforeSubmit: integration?.beforeSubmit,
+ launchModel: leadLaunchModel,
);
_existing = null;
_warnedAboutClosing = false;
@@ -4436,6 +4462,7 @@ class NewHarnessController extends ChangeNotifier {
destination.pending = true;
try {
if (!destination.completed) {
+ destination.launchModelRefused = attempt.launchModelRefused;
await destination.complete(_machineId, attempt.agentId!);
destination.completed = true;
}
@@ -4621,3 +4648,7 @@ class NewHarnessController extends ChangeNotifier {
super.dispose();
}
}
+
+/// The Product Manager's default (backend projects.ts BUILT_IN_ROLE_DEFAULTS):
+/// `opus` is Claude Code's name for its newest Opus, Opus 5.5.
+const kLeadModel = (model: 'opus', label: 'Opus 5.5', effort: 'xhigh');
diff --git a/desktop/lib/super_tabs/launch.dart b/desktop/lib/super_tabs/launch.dart
index b97f4e03f..fee22bb4f 100644
--- a/desktop/lib/super_tabs/launch.dart
+++ b/desktop/lib/super_tabs/launch.dart
@@ -226,6 +226,12 @@ class SuperTabLaunch {
await launch.persist();
},
complete: (machine, harnessId) async {
+ if (integration.launchModelRefused case final refused?) {
+ saved['launchRefused'] = {
+ 'model': refused.model,
+ 'effort': refused.effort,
+ };
+ }
try {
await launch.join(machine, harnessId);
} catch (_) {
@@ -680,6 +686,8 @@ class SuperTabLaunch {
'type': 'lead.start',
'projectId': saved['projectId'],
'machineId': start.machineId,
+ // No model: the Swarm fills its role's default where the owner's
+ // model list and rules allow it (backend commands.ts lead.start).
'engine': start.engine,
'repositoryUrl': ?start.repositoryUrl,
},
@@ -939,14 +947,35 @@ class SuperTabLaunch {
},
if ((saved['initialMessage'] as String? ?? '').isNotEmpty)
'initialMessage': saved['initialMessage'],
+ // Its chat says it runs its engine's own model (backend agent.add).
+ if (saved['lead'] == true && saved['launchRefused'] is Map)
+ 'launchRefused': saved['launchRefused'],
};
await persist();
final tabId = saved['tabId'] as String;
- await app.superTabs.map(
- 'POST',
- '/api/super-tabs/$tabId/commands',
- body: {'operationId': saved['joinId'], 'command': saved['command']},
- );
+ try {
+ await app.superTabs.map(
+ 'POST',
+ '/api/super-tabs/$tabId/commands',
+ body: {'operationId': saved['joinId'], 'command': saved['command']},
+ );
+ } on SuperTabFailure catch (failure) {
+ final command = saved['command'] as Map;
+ if (failure.code != 'VALIDATION_ERROR' ||
+ !command.containsKey('launchRefused')) {
+ rethrow;
+ }
+ // A backend from before the note refuses the whole join for it, having
+ // committed nothing: the join again without it, as a new operation.
+ saved['command'] = Map.of(command)..remove('launchRefused');
+ saved['joinId'] = '${saved['joinId']}-plain';
+ await persist();
+ await app.superTabs.map(
+ 'POST',
+ '/api/super-tabs/$tabId/commands',
+ body: {'operationId': saved['joinId'], 'command': saved['command']},
+ );
+ }
// Waking the exact host starts only its authorized contributions. It is
// safe to retry, and never grants machine access to the tab's members.
await app.wakeSuperTabHost(machine);
diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dart
index 79fce26c1..8fa253cbf 100644
--- a/desktop/lib/super_tabs/model.dart
+++ b/desktop/lib/super_tabs/model.dart
@@ -302,9 +302,17 @@ class SuperTabRole {
: id = _text(row, 'id'),
name = _text(row, 'name'),
kind = _text(row, 'kind'),
- version = _text(row, 'version');
+ version = _text(row, 'version'),
+ defaults = row['defaults'] is Map
+ ? Map.unmodifiable(superTabMap(row['defaults']))
+ : null;
final String id, name, kind, version;
+
+ /// The engine, model and effort its agents start on when a start names
+ /// none (backend projects.ts RoleDefaults). Kept as read, so an edit here
+ /// sends it back unchanged.
+ final Map<String, dynamic>? defaults;
}
class SuperTabProject {
diff --git a/desktop/lib/super_tabs/roles_editor.dart b/desktop/lib/super_tabs/roles_editor.dart
index 981ea1933..c8ff579aa 100644
--- a/desktop/lib/super_tabs/roles_editor.dart
+++ b/desktop/lib/super_tabs/roles_editor.dart
@@ -410,6 +410,8 @@ class _RolesEditorState extends State<_RolesEditor> {
'name': name,
'kind': kind,
'text': markdown,
+ // Not shown here; kept so an edit never drops it.
+ 'defaults': ?role?.defaults,
},
});
if (!dialogContext.mounted) return;
diff --git a/desktop/test/super_tab_launch_test.dart b/desktop/test/super_tab_launch_test.dart
index 900cb995a..f7957f8f8 100644
--- a/desktop/test/super_tab_launch_test.dart
+++ b/desktop/test/super_tab_launch_test.dart
@@ -77,6 +77,10 @@ class SuperTabFixtureConnection extends WsConn {
bool failResume = false;
bool nativeSurface = false;
bool failFiles = false, failCreation = false, changeAccountOnUpload = false;
+
+ /// The machine's Claude Code takes no model or effort flags: refused before
+ /// any receipt, as the daemon does (`LAUNCH_MODEL_UNSUPPORTED`).
+ bool refuseLaunchModel = false;
bool changeAccountOnProjectRead = false;
late AppNotifier app;
final sentFiles = <Uint8List>[];
@@ -319,6 +323,16 @@ class SuperTabFixtureConnection extends WsConn {
'agent': native,
};
}
+ if (type == 'agent_create' &&
+ refuseLaunchModel &&
+ (payload['model'] != null || payload['effort'] != null)) {
+ throw const WsRequestFailure(
+ responseType: 'agent_create_result',
+ code: 'LAUNCH_MODEL_UNSUPPORTED',
+ detail: 'The claude on this machine does not support --effort.',
+ payload: {},
+ );
+ }
if (type == 'agent_create') {
// Match the native daemon: this refusal happens before a receipt or pane.
if ((payload['prompt'] as String? ?? '').trim().length >
@@ -1450,6 +1464,206 @@ void main() {
expect(f.connection.calls.where((c) => c.$1 == 'agent_create'), isEmpty);
});
+ // Scholes's roadmap, piece 1: the Product Manager runs Claude Opus 5.5 at xhigh.
+ group('The Product Manager’s model', () {
+ Future<List<Map<String, dynamic>>> creates(
+ SuperTabLaunchFixture f, {
+ required String engine,
+ required bool newProject,
+ }) async {
+ if (newProject) f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Company');
+ final box = await f.box(engine: engine, newProject: newProject);
+ expect(await box.create(), NewHarnessOutcome.created, reason: box.error);
+ return [
+ for (final call in f.connection.calls)
+ if (call.$1 == 'agent_create') call.$2,
+ ];
+ }
+
+ test(
+ 'on its person’s own Mac, a Claude PM launches on Opus 5.5 at xhigh',
+ () async {
+ for (final newProject in [false, true]) {
+ final f = SuperTabLaunchFixture();
+ final sent = await creates(
+ f,
+ engine: 'claude',
+ newProject: newProject,
+ );
+ expect(sent.single['swarmRole'], 'lead');
+ expect(sent.single['model'], 'opus');
+ expect(sent.single['effort'], 'xhigh');
+ }
+ },
+ );
+
+ test('a Codex PM keeps its engine’s own model', () async {
+ final f = SuperTabLaunchFixture();
+ final sent = await creates(f, engine: 'codex', newProject: true);
+ expect(sent.single.containsKey('model'), isFalse);
+ expect(sent.single.containsKey('effort'), isFalse);
+ });
+
+ test('a machine that cannot launch with them starts the PM on the engine’s own model, never failing', () async {
+ final f = SuperTabLaunchFixture()..connection.refuseLaunchModel = true;
+ final sent = await creates(f, engine: 'claude', newProject: true);
+ expect(sent, hasLength(2));
+ expect(sent.first['model'], 'opus');
+ expect(sent.last.containsKey('model'), isFalse);
+ expect(sent.last.containsKey('effort'), isFalse);
+ // The same request, so the same harness: nothing launched the first time.
+ expect(sent.last['creationId'], sent.first['creationId']);
+ // Its project chat is told, as for a PM the Swarm starts.
+ expect(commandsOf(f, 'agent.add').single['launchRefused'], {
+ 'model': 'opus',
+ 'effort': 'xhigh',
+ });
+ });
+
+ test(
+ 'a PM that launched on Opus 5.5 at xhigh joins without a note',
+ () async {
+ final f = SuperTabLaunchFixture();
+ await creates(f, engine: 'claude', newProject: true);
+ expect(
+ commandsOf(f, 'agent.add').single.containsKey('launchRefused'),
+ isFalse,
+ );
+ },
+ );
+
+ test(
+ 'a backend from before the note still joins the PM, without it',
+ () async {
+ final f = SuperTabLaunchFixture()..connection.refuseLaunchModel = true;
+ f.connection.server.unknownCommand = (command) =>
+ command['type'] == 'agent.add' &&
+ command.containsKey('launchRefused');
+ await creates(f, engine: 'claude', newProject: true);
+ final joins = commandsOf(f, 'agent.add');
+ expect(joins, hasLength(2));
+ expect(joins.first['launchRefused'], isNotNull);
+ expect(joins.last.containsKey('launchRefused'), isFalse);
+ },
+ );
+
+ test('a Claude PM the Swarm starts leaves its model to the Swarm, which fills its role’s default', () async {
+ final f = SuperTabLaunchFixture();
+ addDiego(f);
+ knownRepo(f);
+ f.connection.server.state['machines'] = [
+ machineRow('diego-mac', 'Diego MacBook'),
+ machineRow(
+ 'diego-team',
+ 'Diego MacBook',
+ host: 'diego-mac',
+ kind: 'team',
+ lead: true,
+ ),
+ ];
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Company');
+ final box = await f.box(engine: 'claude', newProject: true);
+ box.chooseLeadMachine('diego-mac');
+ expect(box.leadThroughSwarm, isTrue);
+ expect(box.leadModelLabel, 'Opus 5.5 · xhigh');
+ expect(await box.create(), NewHarnessOutcome.created, reason: box.error);
+ // The server fills it, so the owner's model list and rules decide
+ // (review of #2274: a default the client named read as its person's).
+ final start = commandsOf(f, 'lead.start').single;
+ expect(start.containsKey('model'), isFalse);
+ expect(start.containsKey('effort'), isFalse);
+ });
+
+ test('with Opus at xhigh off and at high on in the Swarm’s model list, a Claude PM on its own Mac launches on its engine’s own model', () async {
+ final f = SuperTabLaunchFixture();
+ Map<String, dynamic> row(String effort, bool on) => {
+ 'engine': 'claude',
+ 'model': 'opus',
+ 'effort': effort,
+ 'quality': 3,
+ 'cost': 3,
+ 'enabled': on,
+ };
+ f.connection.server.routingPolicy = {
+ 'policy': {
+ 'version': 1,
+ 'models': [row('high', true), row('xhigh', false)],
+ 'floor': {'low': 1, 'medium': 2, 'high': 3},
+ 'quotaReserve': 10,
+ 'notes': '',
+ },
+ 'warnings': <String>[],
+ 'overridden': <String>[],
+ 'override': null,
+ };
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Company');
+ final box = await f.box(engine: 'claude', newProject: true);
+ expect(box.leadLaunchModel, isNull);
+ expect(box.leadModelLabel, 'Default model');
+ });
+
+ test('with every Opus row of the Swarm’s model list off, a Claude PM on its own Mac launches on its engine’s own model', () async {
+ final f = SuperTabLaunchFixture();
+ Map<String, dynamic> row(String model, String effort, bool on) => {
+ 'engine': 'claude',
+ 'model': model,
+ 'effort': effort,
+ 'quality': 3,
+ 'cost': 3,
+ 'enabled': on,
+ };
+ f.connection.server.routingPolicy = {
+ 'policy': {
+ 'version': 1,
+ 'models': [
+ row('opus', 'high', false),
+ row('opus', 'xhigh', false),
+ row('sonnet', 'medium', true),
+ ],
+ 'floor': {'low': 1, 'medium': 2, 'high': 3},
+ 'quotaReserve': 10,
+ 'notes': '',
+ },
+ 'warnings': <String>[],
+ 'overridden': <String>[],
+ 'override': null,
+ };
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Company');
+ final box = await f.box(engine: 'claude', newProject: true);
+ expect(box.leadLaunchModel, isNull);
+ expect(box.leadModelLabel, 'Default model');
+ // As the server judges it (backend commands.ts): the xhigh row
+ // decides, and any Opus row only when the list has none at xhigh
+ // (re-review of #2274).
+ LeadModelList list(List<(String, bool)> opus) => LeadModelList.of({
+ 'models': [for (final (effort, on) in opus) row('opus', effort, on)],
+ });
+ expect(
+ list([('high', true), ('xhigh', false)])
+ .modelOn('claude', 'opus', 'xhigh'),
+ isFalse,
+ );
+ expect(
+ list([('high', false), ('xhigh', true)])
+ .modelOn('claude', 'opus', 'xhigh'),
+ isTrue,
+ );
+ expect(list([('high', true)]).modelOn('claude', 'opus', 'xhigh'), isTrue);
+ expect(
+ list([('high', false)]).modelOn('claude', 'opus', 'xhigh'),
+ isFalse,
+ );
+ expect(list([]).modelOn('claude', 'opus', 'xhigh'), isTrue);
+ expect(await box.create(), NewHarnessOutcome.created, reason: box.error);
+ final sent = [
+ for (final call in f.connection.calls)
+ if (call.$1 == 'agent_create') call.$2,
+ ];
+ expect(sent.single.containsKey('model'), isFalse);
+ expect(sent.single.containsKey('effort'), isFalse);
+ });
+ });
+
test(
'New Project asks the Swarm to start the PM in a teammate’s Team account',
() async {
diff --git a/desktop/test/super_tab_project_skills_test.dart b/desktop/test/super_tab_project_skills_test.dart
index 939620496..fea16c80e 100644
--- a/desktop/test/super_tab_project_skills_test.dart
+++ b/desktop/test/super_tab_project_skills_test.dart
@@ -136,12 +136,22 @@ void main() {
String account = 'owner',
String? skillMode,
bool custom = false,
+ Map<String, Map<String, String>> roleDefaults = const {},
}) async {
final server = _RolesServer();
final project = projectFixture('lead', 'Pilot', 'lead');
if (skillMode != null) project['skillMode'] = skillMode;
server.state['projects'] = [project];
if (custom) server.seedRoles();
+ if (roleDefaults.isNotEmpty) {
+ project['roles'] = [
+ for (final role in project['roles'] as List)
+ <String, dynamic>{
+ ...role as Map,
+ 'defaults': ?roleDefaults[role['id']],
+ },
+ ];
+ }
if (account != 'owner') {
(server.state['people'] as List).add({
'id': account,
@@ -407,6 +417,39 @@ void main() {
expect(find.text('Research Engineer'), findsOneWidget);
});
+ testWidgets('editing a role keeps its default engine, model and effort', (
+ tester,
+ ) async {
+ // Set elsewhere: this editor shows no defaults, and must not drop them
+ // (review of #2274).
+ final server = await mount(
+ tester,
+ custom: true,
+ roleDefaults: {
+ 'dev': {'engine': 'codex', 'model': 'gpt-6.1-sol', 'effort': 'high'},
+ },
+ );
+ await openInstructions(tester);
+ await tester.tap(find.text('Edit custom roles'));
+ await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const ValueKey('role-edit-dev')));
+ await tester.pumpAndSettle();
+ await tester.enterText(
+ find.byKey(const ValueKey('role-text')),
+ '# Research work',
+ );
+ await tester.pump();
+ await tester.tap(find.widgetWithText(FilledButton, 'Save role'));
+ await tester.pumpAndSettle();
+ expect((server.posts.last['command'] as Map)['role'], {
+ 'id': 'dev',
+ 'name': 'Engineer',
+ 'kind': 'builder',
+ 'text': '# Research work',
+ 'defaults': {'engine': 'codex', 'model': 'gpt-6.1-sol', 'effort': 'high'},
+ });
+ });
+
testWidgets('owner adds a named reviewer role with a stable id', (
tester,
) async {
diff --git a/desktop/test/support/super_tab_fixture.dart b/desktop/test/support/super_tab_fixture.dart
index 13523eb1b..e0ef7b264 100644
--- a/desktop/test/support/super_tab_fixture.dart
+++ b/desktop/test/support/super_tab_fixture.dart
@@ -438,6 +438,10 @@ class ConversationServer {
// Makes every command answer with this refusal: {code, message}, with
// [refuseStatus] as its HTTP status.
Map<String, String>? refuse;
+
+ /// Commands the server refuses as a backend from before them does: its
+ /// strict schema answers `VALIDATION_ERROR` with a 400.
+ bool Function(Map command)? unknownCommand;
// While set, every command waits for it before it answers: a slow server.
Completer<void>? holdCommands;
@@ -811,6 +815,13 @@ class ConversationServer {
statusCode: 400,
);
}
+ if (unknownCommand?.call(body['command'] as Map? ?? const {}) ?? false) {
+ throw const SuperTabFailure(
+ 'VALIDATION_ERROR',
+ 'Invalid request.',
+ statusCode: 400,
+ );
+ }
if (refuse case final refusal?) {
throw SuperTabFailure(
refusal['code']!,
diff --git a/mobile/lib/swarm/model.dart b/mobile/lib/swarm/model.dart
index 65391c28d..9aac77302 100644
--- a/mobile/lib/swarm/model.dart
+++ b/mobile/lib/swarm/model.dart
@@ -341,9 +341,17 @@ class SuperTabRole {
: id = _text(row, 'id'),
name = _text(row, 'name'),
kind = _text(row, 'kind'),
- version = _text(row, 'version');
+ version = _text(row, 'version'),
+ defaults = row['defaults'] is Map
+ ? Map.unmodifiable(superTabMap(row['defaults']))
+ : null;
final String id, name, kind, version;
+
+ /// The engine, model and effort its agents start on when a start names
+ /// none (backend projects.ts RoleDefaults). Read and kept as the desktop's
+ /// model does; the phone shows none of it.
+ final Map<String, dynamic>? defaults;
}
class SuperTabProject {