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.

fix(swarm): a status or check with no group goes to the one task the agent holds

bitcoinbuilder210fb333f5a7
diff --git a/cli/src/superTabs/assignmentIds.spec.ts b/cli/src/superTabs/assignmentIds.spec.ts
index 19bb151a3..e8d168529 100644
--- a/cli/src/superTabs/assignmentIds.spec.ts
+++ b/cli/src/superTabs/assignmentIds.spec.ts
@@ -33,6 +33,18 @@ describe('assignment ids', () => {
expect(withCurrentAssignment(none, state, 'builder')).toBe(none)
})
+ it('fills a missing group for a status or check from the one task the agent holds', () => {
+ const two = { conversations: [...state.conversations, { id: 'g3', assignment: { id: 'a3', agentId: 'builder', status: 'working' } }] }
+ const ended = { conversations: [state.conversations[0], { id: 'g3', assignment: { id: 'a3', agentId: 'builder', status: 'done' } }] }
+ const check = { type: 'work.check', assignmentId: 'current', checkId: 'c1', passed: true }
+ expect(withCurrentAssignment(check, state, 'builder')).toEqual({ ...check, conversationId: 'g1', assignmentId: '58c2d5f2bdc100771bc57de7' })
+ expect(withCurrentAssignment(check, ended, 'builder')).toMatchObject({ conversationId: 'g1' })
+ expect(withCurrentAssignment(check, two, 'builder')).toBe(check)
+ expect(withCurrentAssignment(check, state, 'lead')).toBe(check)
+ const cancel = { type: 'work.cancel', assignmentId: 'current' }
+ expect(withCurrentAssignment(cancel, state, 'builder')).toBe(cancel)
+ })
+
it('names the id to use when a stale one is refused', () => {
const stale = { type: 'work.status', conversationId: 'g1', assignmentId: '9887f5667a24ace0b589b7ff' }
expect(staleAssignmentHint(stale, state, 'builder')).toContain('"assignmentId": "58c2d5f2bdc100771bc57de7"')
diff --git a/cli/src/superTabs/assignmentIds.ts b/cli/src/superTabs/assignmentIds.ts
index 8021ce9da..6d6062f9f 100644
--- a/cli/src/superTabs/assignmentIds.ts
+++ b/cli/src/superTabs/assignmentIds.ts
@@ -7,6 +7,8 @@
* active assignment.") without saying which one is, and the task stayed open until the Lead cancelled it. An agent may now
* write `current` (or leave it out), and a stale id is answered with the one to use.
*/
+import { ENDED_WORK } from './wire.js'
+
type Json = Record<string, unknown>
const object = (value: unknown): Json => value && typeof value === 'object' && !Array.isArray(value) ? value as Json : {}
@@ -23,6 +25,19 @@ export function currentAssignment(state: unknown, conversationId: unknown): { id
return typeof assignment.id === 'string' && typeof assignment.agentId === 'string' ? { id: assignment.id, agentId: assignment.agentId } : null
}
+/** The one group whose active assignment [agentId] holds, or null when it holds none or several.
+ *
+ * A Codex Builder on Mac Auto (Swarm group #17, 2026-10-30) sent its first work.check with "current" but no
+ * conversationId; the backend refused it, the check stayed pending, and its done came back CHECKS_PENDING. */
+export function ownGroup(state: unknown, agentId: string): string | null {
+ const conversations = object(state).conversations
+ const held = (Array.isArray(conversations) ? conversations.map(object) : []).filter(c => {
+ const assignment = object(c.assignment)
+ return typeof c.id === 'string' && assignment.agentId === agentId && !ENDED_WORK.includes(String(assignment.status))
+ })
+ return held.length === 1 ? held[0].id as string : null
+}
+
/** Whether [command] asks for its group's current assignment: `current`, or no id at all. */
export const wantsCurrent = (command: Json) => ASSIGNMENT_COMMANDS.has(String(command.type))
&& (command.assignmentId === undefined || command.assignmentId === null || command.assignmentId === '' || command.assignmentId === CURRENT)
@@ -31,6 +46,9 @@ export const wantsCurrent = (command: Json) => ASSIGNMENT_COMMANDS.has(String(co
* Unchanged when there is none, so the backend refuses it as it would have. */
export function withCurrentAssignment(command: Json, state: unknown, agentId: string): Json {
if (!wantsCurrent(command)) return command
+ // A status or check with no group names the agent's own task's group, when it holds exactly one.
+ const group = OWN_TASK.has(String(command.type)) && !command.conversationId ? ownGroup(state, agentId) : null
+ if (group) command = { ...command, conversationId: group }
const current = currentAssignment(state, command.conversationId)
if (!current || (OWN_TASK.has(String(command.type)) && current.agentId !== agentId)) return command
return { ...command, assignmentId: current.id }
diff --git a/cli/src/superTabs/service.spec.ts b/cli/src/superTabs/service.spec.ts
index f44b9a1ab..075da49f6 100644
--- a/cli/src/superTabs/service.spec.ts
+++ b/cli/src/superTabs/service.spec.ts
@@ -1282,6 +1282,13 @@ describe('the assignment a command names', () => {
error: 'STALE_ASSIGNMENT', detail: `This is no longer the active assignment. This group's active assignment is ${live}: send it again with "assignmentId": "${live}" (or "current").` })
})
+ it('sends a check with no group to the one task the agent holds', async () => {
+ const t = setup(); withTask(t, t.agentId)
+ const check = { type: 'work.check', assignmentId: 'current', checkId: 'c1', passed: true, evidence: 'Posted' }
+ expect(await t.ask({ action: 'command', tabId: 'tab', agentId: t.agentId, operationId: 'e', command: check }, owner)).toMatchObject({ ok: true })
+ expect(posted(t)).toEqual([{ ...check, conversationId: 'g1', assignmentId: live }])
+ })
+
it('never fills in another agent\'s task for a status', async () => {
const t = setup(); withTask(t, 'someone-else')
await t.ask({ action: 'command', tabId: 'tab', agentId: t.agentId, operationId: 'd', command: status('current') }, owner)