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.

Route leaves out a refused pick instead of refusing the whole route (#4194) (#3462)

0xken152892c52df464
diff --git a/backend/integration/superTabTeam.test.ts b/backend/integration/superTabTeam.test.ts
index 107c78e6e..e4cfa8d82 100644
--- a/backend/integration/superTabTeam.test.ts
+++ b/backend/integration/superTabTeam.test.ts
@@ -744,7 +744,7 @@ describe('a teammate\'s work and the machines that take it', () => {
expect((await store.read(owner, f.tab)).state.conversations.find(c => c.id === other)!.agentIds).not.toContain(f.builder)
})
- it('routes the owner\'s project past Team machines and new agents on another person\'s computer, records why, and refuses a pick there', async () => {
+ it('routes the owner\'s project past Team machines and new agents on another person\'s computer, records why, and leaves out a pick there', async () => {
const f = await fixture()
await personalMac(f)
const volunteer = String((await run(f.tab, { type: 'agent.add', conversationId: f.teamGroup, machineId: 'personal-mac', harnessId: randomUUID(),
@@ -758,8 +758,46 @@ describe('a teammate\'s work and the machines that take it', () => {
const recorded = await store.routeDecision(owner, f.tab, String(routed.result.routeDecisionId))
expect(recorded.record.candidates.map(c => c.id)).toEqual(['c2'])
expect(recorded.record.excluded.map(e => e.title)).toEqual(['Builder · team-mac', 'Builder · personal-mac'])
- await expect(run(f.tab, { type: 'route.record', conversationId: f.teamGroup, decision: decision('c0') }, owner, f.lead))
+ // A route that picked the Team account still answers (task #4194): the pick is left out with why, and the rest is kept.
+ const rerouted = await run(f.tab, { type: 'route.record', conversationId: f.teamGroup, decision: decision('c0') }, owner, f.lead)
+ const kept = await store.routeDecision(owner, f.tab, String(rerouted.result.routeDecisionId))
+ expect(kept.record.candidates.map(c => c.id)).toEqual(['c2'])
+ expect(kept.record.pick).toBeUndefined()
+ expect(kept.record.excluded).toContainEqual({ title: 'Builder · team-mac', reason: expect.stringContaining('Harness Team accounts are gone') })
+ })
+
+ // Task #4194: since #4120 a route whose pick was a Team account was refused whole, so the PM could start or assign nothing.
+ it('routes the owner\'s project to an own-account candidate when its pick was a Team account, and that decision starts and assigns', async () => {
+ const f = await fixture()
+ await personalMac(f)
+ const volunteer = String((await run(f.tab, { type: 'agent.add', conversationId: f.teamGroup, machineId: 'personal-mac', harnessId: randomUUID(),
+ name: 'Volunteer', configuration: config, lead: false }, person)).result.agentId)
+ const decision = () => ({ assessment: { difficulty: 'medium' as const, risk: 'low' as const, why: 'A small change.' },
+ candidates: [
+ { id: 'c0', kind: 'member' as const, agentId: f.builder, machineId: 'team-mac', engine: 'codex' as const, model: 'default', effort: 'default',
+ quality: 3, cost: 2, title: 'Builder · team-mac', label: 'Codex on team-mac' },
+ { id: 'c1', kind: 'new' as const, machineId: 'owner-host', engine: 'codex' as const, model: 'default', effort: 'default',
+ quality: 3, cost: 2, title: 'Builder · owner-host', label: 'Codex on owner-host' },
+ { id: 'c2', kind: 'member' as const, agentId: volunteer, machineId: 'personal-mac', engine: 'codex' as const, model: 'default', effort: 'default',
+ quality: 3, cost: 2, title: 'Volunteer · personal-mac', label: 'Codex on personal-mac' }],
+ excluded: [], floor: 2, notes: false, pick: 'c0', via: 'order' as const, p: null, belowFloor: false, why: 'Policy order.' })
+ const route = async () => {
+ const id = String((await run(f.tab, { type: 'route.record', conversationId: f.teamGroup, decision: decision() }, owner, f.lead)).result.routeDecisionId)
+ const recorded = await store.routeDecision(owner, f.tab, id)
+ expect(recorded.record.candidates.map(c => c.id)).toEqual(['c1', 'c2'])
+ expect(recorded.record.excluded.filter(e => e.title === 'Builder · team-mac')).toHaveLength(1)
+ return id
+ }
+ const reason = 'Routing order: the account resetting soonest.'
+ const started = await run(f.tab, { type: 'agent.start', routeDecisionId: await route(), overrideReason: reason, request: { conversationId: f.teamGroup,
+ machineId: 'owner-host', engine: 'codex', name: 'Builder', cwd: '/work/lead', worktree: false, requirements } }, owner, f.lead)
+ expect(started.result.startId).toBeTruthy()
+ // Still no work for the Team agent (task #4120).
+ await expect(run(f.tab, { type: 'work.assign', conversationId: f.teamGroup, agentId: f.builder, routeDecisionId: await route(), overrideReason: reason }, owner, f.lead))
.rejects.toMatchObject({ code: 'TEAM_ACCOUNTS_REMOVED' })
+ const assigned = await run(f.tab, { type: 'work.assign', conversationId: f.teamGroup, agentId: volunteer, routeDecisionId: await route(), overrideReason: reason },
+ owner, f.lead)
+ expect(assigned.result.assignmentId).toBeTruthy()
})
it('refuses at its launch a start queued in a Team account before the release', async () => {
diff --git a/backend/src/superTabs/buddyMachines.test.ts b/backend/src/superTabs/buddyMachines.test.ts
index 46e1da632..c3e443727 100644
--- a/backend/src/superTabs/buddyMachines.test.ts
+++ b/backend/src/superTabs/buddyMachines.test.ts
@@ -132,14 +132,16 @@ describe('a Buddy on its person\'s own machine outside the Swarm', () => {
expect((f.state.starts ?? []).filter(s => s.request.leadFor)).toEqual([])
})
- it('is no route candidate: a pick there is refused', () => {
+ it('is no route candidate: a pick there is left out with why, and the rest kept with no pick (task #4194)', () => {
const f = setup()
addOwn(f, f.app.projectId)
const candidate = (id: string, machineId: string) => ({ id, kind: 'new', machineId, engine: 'claude', model: 'opus', effort: 'high', quality: 3, cost: 3,
title: `Title ${id}`, label: `Label ${id}` })
const decision = { assessment: { difficulty: 'low', risk: 'low', why: 'Fix a typo.' }, candidates: [candidate('c0', 'peer-laptop'), candidate('c1', 'owner-mac')],
excluded: [], floor: 3, notes: false, pick: 'c0', via: 'jev', p: 0.8, belowFloor: false, why: 'Free machine.' }
- expect(() => f.run({ type: 'route.record', conversationId: f.group, decision } as unknown as Command, pmActor(f))).toThrow('This machine is not one of the Swarm\'s machines')
+ const [created] = f.run({ type: 'route.record', conversationId: f.group, decision } as unknown as Command, pmActor(f)).routeDecisions as Array<{ record: Record<string, unknown> }>
+ expect(created!.record).toMatchObject({ candidates: [{ id: 'c1' }], excluded: [{ title: 'Title c0', reason: expect.stringContaining('not one of the Swarm\'s machines') }] })
+ expect(created!.record.pick).toBeUndefined()
})
it('is in nobody\'s Swarm read, its own person\'s included: Machines, status and the leaderboard\'s lent hours', () => {
@@ -406,8 +408,10 @@ describe('a Buddy-only machine after its reviews', () => {
running(f, f.app.projectId)
f.run({ type: 'work.define', conversationId: f.group, brief: 'Save edits.', checks: [{ description: 'Edits survive a reload.', independent: false }] })
const pane = paneIn(f, f.group)
- expect(() => f.run({ type: 'route.record', conversationId: f.group, decision: decision(pane) } as unknown as Command, pmActor(f)))
- .toThrow('This machine is not one of the Swarm\'s machines')
+ const [created] = f.run({ type: 'route.record', conversationId: f.group, decision: decision(pane) } as unknown as Command, pmActor(f))
+ .routeDecisions as Array<{ record: { candidates: Array<{ id: string }>; pick?: string } }>
+ expect(created!.record.candidates.map(c => c.id)).toEqual(['c1'])
+ expect(created!.record.pick).toBeUndefined()
expect(() => f.run({ type: 'work.assign', conversationId: f.group, agentId: pane })).toThrow('This machine is not one of the Swarm\'s machines')
expect(f.state.conversations.find(c => c.id === f.group)!.assignment).toBeNull()
}))
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.ts
index 3be9f63b7..81934ab0e 100644
--- a/backend/src/superTabs/commands.ts
+++ b/backend/src/superTabs/commands.ts
@@ -4461,19 +4461,19 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,
case 'route.record': {
chatOnly(command.conversationId)
projectChatWork(command.conversationId)
- // A teammate's work runs only on Team machines: candidates elsewhere leave the decision for its exclusions, with
- // why, so the Lead and people see it. A pick there is refused; a current CLI already leaves those machines out.
+ // Candidates that cannot take the work (a Team account, another person's computer, task #4120) leave the decision for its
+ // exclusions, with why, so the Lead and people see it. A pick among them is left out too and the record keeps no pick, so
+ // the coordinator chooses among the rest by the Routing rules: refusing the whole route stopped every PM (task #4194).
const starter = actor.kind === 'agent' ? agent(state, actor.agentId).contributorId : actor.userId
const refusals = new Map(command.decision.candidates.flatMap(c => {
const refusal = candidateRefusal(c, command.conversationId, starter)
return refusal ? [[c.id, refusal] as const] : []
}))
- const pickRefusal = command.decision.pick === undefined ? undefined : refusals.get(command.decision.pick)
- if (pickRefusal) failTeamWork(pickRefusal, ' Route again.')
- // A route that names no pick (task #2901) is refused only once it has no candidate left to choose.
+ // A route is refused only once it has no candidate left to choose.
const [firstRefusal] = refusals.values()
if (firstRefusal && refusals.size === command.decision.candidates.length) failTeamWork(firstRefusal, ' Route again.')
- const decision = !refusals.size ? command.decision : { ...command.decision,
+ const { pick: sentPick, ...unpicked } = command.decision
+ const decision = !refusals.size ? command.decision : { ...(sentPick !== undefined && refusals.has(sentPick) ? unpicked : command.decision),
candidates: command.decision.candidates.filter(c => !refusals.has(c.id)),
excluded: [...command.decision.candidates.flatMap(c => refusals.has(c.id) ? [{ title: c.title, reason: refusals.get(c.id)!.reason }] : []),
...command.decision.excluded].slice(0, 200) }
diff --git a/backend/src/superTabs/teamRouting.test.ts b/backend/src/superTabs/teamRouting.test.ts
index cd99c8373..226966507 100644
--- a/backend/src/superTabs/teamRouting.test.ts
+++ b/backend/src/superTabs/teamRouting.test.ts
@@ -276,11 +276,18 @@ describe('routing a teammate\'s work', () => {
expect(effects.messages[0]!.source).toMatchObject({ pick: { id: 'c3' }, alternatives: [{ id: 'c2', title: 'personal on mate-mac' }] })
})
- it('refuses a pick that cannot take it, so no decision names it', () => {
+ // Task #4194: a route that picked a Team account was refused whole, and routing again picked it again, so no PM could route.
+ it('leaves out a pick that cannot take it and keeps the rest, with no pick, so the coordinator chooses among them', () => {
const f = routed()
- expect(refusal(() => f.run({ type: 'route.record', conversationId: f.group, decision: record([candidate('c0', 'mate-team'), candidate('c1', 'owner-mac')]) } as Command,
- f.leadActor, {}))).toMatchObject({ code: 'TEAM_ACCOUNTS_REMOVED',
- message: 'Harness Team accounts are gone: an agent runs on its own person\'s computer, in their own account. Route again.' })
+ const effects = f.run({ type: 'route.record', conversationId: f.group, decision: record([candidate('c0', 'mate-team'), candidate('c1', 'owner-mac')]) } as Command,
+ f.leadActor, {})
+ const [created] = effects.routeDecisions as Array<{ record: Record<string, unknown> }>
+ expect(created!.record).toMatchObject({ candidates: [{ id: 'c1' }],
+ excluded: [{ title: 'c0 on mate-team', reason: 'Harness Team accounts are gone: an agent runs on its own person\'s computer, in their own account.' },
+ { title: 'Owner Mac · claude' }] })
+ expect(created!.record.pick).toBeUndefined()
+ // No row names a pick the record does not keep: the start or assignment posts the one it chose.
+ expect(effects.messages.filter(m => m.source?.kind === 'route')).toEqual([])
})
// Task #2901 (Ken, 2026-11-04): a route names no pick, so no single refusal decides it; it is refused once no candidate is left.