ruvnet/ruflo · 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 target sibling is the root message (its ancestors array is empty or missing). The root has no parent, so a node 'next to' it would have no parent either — every tree needs exactly one root. Branching at the top level is therefore illegal; the message must be edited in place or a new conversation started.
Solutions
- Do not offer sibling insert on the root: check sibling.ancestors?.length (or id === conv.rootMessageId) and disable the action.
- For 'change the first prompt' UX, create a new conversation instead of a sibling.
- If editing the root content is required, mutate the root node's content rather than adding a sibling.
Example fix
// before
addSibling(conv, message, conv.rootMessageId); // throws
// after
if (siblingId === conv.rootMessageId) {
// edit in place or start a new conversation
const root = conv.messages.find((m) => m.id === conv.rootMessageId)!;
root.content = newContent;
} else {
addSibling(conv, message, siblingId);
} Defensive patterns
Strategy: validation
Validate before calling
if (siblingId === conv.rootMessageId) {
throw new Error("cannot branch at the root message");
}
addSibling(conv, message, siblingId); Type guard
function isRootMessage(conv: { rootMessageId: string }, id: string): boolean {
return id === conv.rootMessageId;
} Prevention
- Disable alternative/regenerate affordances on the root node in the UI.
- Treat 'edit first prompt' as create-new-conversation, not sibling insert.
- Assert sibling.ancestors?.length > 0 before calling addSibling.
When it happens
Trigger: addSibling(conv, message, siblingId) where the found sibling has empty/undefined ancestors — i.e., siblingId === conv.rootMessageId. Typically an 'edit user message as alternative' action fired on the very first prompt of a conversation.
Common situations: Users editing their opening message to restart a chat; UI code that offers regeneration uniformly on every node including the root.
Related errors
- Cannot add a sibling to an empty conversation
- You need to specify a parentId if this is not the first…
- Message not found
- The sibling message doesn't exist
- at least one agent is required
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/4d1746dc0fd6c96d.
Report an issue: GitHub.
Appendix: 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 fa13ee4ad6)