lobehub/lobehub · warning · TRPCError

CONFLICT

CONFLICT

Error message

A previous transfer of this group's agents is still migrating history

What it means

Thrown by removeAgentsFromGroup when an in-flight agent-transfer backfill job still maps one or more of the target agents' message rows. Removing a member now would leave the job pointing at a dangling messages.agent_id, so the repo raises AGENT_TRANSFER_IN_PROGRESS and the router translates it to HTTP 409 CONFLICT. This is a transient state that resolves when the backfill completes.

Source

Thrown at apps/server/src/routers/lambda/agentGroup.ts:715

          action: 'edit',
          db: ctx.serverDB,
          resourceId: input.groupId,
          resourceType: 'agentGroup',
          userId: ctx.userId,
          workspaceId: ctx.workspaceId,
        });
      }
      try {
        return await ctx.agentGroupRepo.removeAgentsFromGroup(
          input.groupId,
          input.agentIds,
          input.deleteVirtualAgents,
        );
      } catch (error) {
        // A backfill still maps these agents' message rows — removing a member
        // now would strand the job on a dangling `messages.agent_id`.
        if (error instanceof Error && error.message === AGENT_TRANSFER_IN_PROGRESS) {
          throw new TRPCError({
            code: 'CONFLICT',
            message: "A previous transfer of this group's agents is still migrating history",
          });
        }
        if (error instanceof Error && error.message === AGENT_COPY_IN_PROGRESS) {
          throw new TRPCError({
            code: 'CONFLICT',
            message: 'A previous copy of this agent is still duplicating its history',
          });
        }
        throw error;
      }
    }),

  /**
   * Members these groups only reference (the roster's `External` rows).
   *
   * Asked before a transfer: those agents stay in the source scope and the

View on GitHub (pinned to 10f24d7ade)

Solutions

  1. Retry the removal after the transfer backfill completes (watch the job status or poll agentGroupRepo for the in-progress flag to clear).
  2. Inspect agentTransferJob rows for the affected agentIds; if a job is stuck (status not advancing, no heart-beat), escalate to an admin to reap or replay it, then retry.
  3. If you must remove members immediately, transfer them fully first (complete the job) rather than racing it.

Example fix

// before
await trpc.agentGroup.removeAgentsFromGroup.mutate({ groupId, agentIds, deleteVirtualAgents: true });
// after — surface the transient state and retry
try {
  await trpc.agentGroup.removeAgentsFromGroup.mutate({ groupId, agentIds, deleteVirtualAgents: true });
} catch (e) {
  if (e.data?.code === 'CONFLICT' && /still migrating history/.test(e.message)) {
    // backoff and retry, or prompt the user that a transfer is finishing
  } else throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

// Inspect agentTransferJob rows for the agents you intend to remove
const inFlight = await db.select()
  .from(agentTransferJob)
  .where(and(
    inArray(agentTransferJob.agentId, agentIds),
    notEquals(agentTransferJob.status, 'done'),
  ));
if (inFlight.length > 0) throw new Error('Transfer backfill still running');

Try / catch

async function removeWithRetry(groupId, agentIds, opts) {
  for (let attempt = 0; attempt < 5; attempt++) {
    try {
      return await trpc.agentGroup.removeAgentsFromGroup.mutate({ groupId, agentIds, ...opts });
    } catch (e) {
      const migrating = e.shape?.data?.code === 'CONFLICT' && /still migrating history/.test(e.message);
      if (!migrating || attempt === 4) throw e;
      await waitForTransferJobsToSettle(agentIds);
    }
  }
}

Prevention

When it happens

Trigger: Calling removeAgentsFromGroup with agentIds that include agents currently being moved by a recent transferGroup call. The repo error message AGENT_TRANSFER_IN_PROGRESS is matched literally — any other error is rethrown unchanged.

Common situations: A user transfers a group between workspaces and immediately tries to prune members before the async history backfill finishes. An automation pipeline fires transfer then edit in quick succession. A previous transfer crashed leaving a stuck job row.

Related errors


AI-assisted analysis of lobehub/lobehub@10f24d7ade (2026-08-12). Data as JSON: /api/errors/f474344fd1d0cfce. Report an issue: GitHub.