ruvnet/ruflo · error · Error
The sibling message is the root message, therefore we can't
Error message
The sibling message is the root message, therefore we can't add a sibling
What it means
Thrown by addSibling when the sibling exists but has no ancestors (ancestors is undefined/empty). A node with no ancestors is the root of the tree; the root has no parent to attach a sibling under, so adding one is structurally impossible.
Source
Thrown at ruflo/src/ruvocal/src/lib/utils/tree/addSibling.ts:19
import { v4 } from "uuid";
import type { Tree, TreeId, NewNode, TreeNode } from "./tree";
export function addSibling<T>(conv: Tree<T>, message: NewNode<T>, siblingId: TreeId): TreeId {
if (conv.messages.length === 0) {
throw new Error("Cannot add a sibling to an empty conversation");
}
if (!conv.rootMessageId) {
throw new Error("Cannot add a sibling to a legacy conversation");
}
const sibling = conv.messages.find((m) => m.id === siblingId);
if (!sibling) {
throw new Error("The sibling message doesn't exist");
}
if (!sibling.ancestors || sibling.ancestors?.length === 0) {
throw new Error("The sibling message is the root message, therefore we can't add a sibling");
}
const messageId = v4();
conv.messages.push({
...message,
id: messageId,
ancestors: sibling.ancestors,
children: [],
} as TreeNode<T>);
const nearestAncestorId = sibling.ancestors[sibling.ancestors.length - 1];
const nearestAncestor = conv.messages.find((m) => m.id === nearestAncestorId);
if (nearestAncestor) {
if (nearestAncestor.children) {
nearestAncestor.children.push(messageId);
} else nearestAncestor.children = [messageId];View on GitHub (pinned to 6b01dc5a68)
Solutions
- Pick a non-root node as the sibling (any node with ancestors.length > 0).
- To create alternative first turns, start a new conversation rather than adding a sibling to the root.
- Validate sibling.ancestors?.length > 0 before calling addSibling.
Example fix
// before
addSibling(conv, message, conv.rootMessageId); // root → throws
// after
const sibling = conv.messages.find((m) => m.id === siblingId);
if (!sibling || !sibling.ancestors?.length) {
throw new Error("cannot branch from root; create a new conversation instead");
}
addSibling(conv, message, siblingId); Defensive patterns
Strategy: validation
Validate before calling
const sibling = conv.messages.find((m) => m.id === siblingId);
if (!sibling || !sibling.ancestors || sibling.ancestors.length === 0) {
throw new Error("cannot add sibling to root message; start a new conversation instead");
}
addSibling(conv, message, siblingId); Type guard
function isRootNode<T>(node: TreeNode<T>): boolean {
return !node.ancestors || node.ancestors.length === 0;
} Prevention
- Disable the 'branch/regenerate' affordance on the conversation root.
- Validate sibling.ancestors?.length > 0 before calling addSibling.
- For alternative first turns, create a new conversation rather than branching the root.
When it happens
Trigger: Passing the conversation's rootMessageId (or any node whose ancestors chain is []) as siblingId — e.g. a "regenerate" action triggered on the very first user/root message.
Common situations: UI that offers "try again" on the root message; misidentifying the root id; a tree where ancestors were not populated correctly so an inner node looks like the root.
Related errors
- You need to specify a parentId if this is not the first mess
- Cannot add a sibling to an empty conversation
- The sibling message doesn't exist
- Message not found
- This is a legacy conversation, you can only append to the la
AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12).
Data as JSON: /api/errors/4d1746dc0fd6c96d.
Report an issue: GitHub.