Mintplex-Labs/anything-llm · warning · Error

Maximum rounds reached

Error message

Maximum rounds reached

What it means

Thrown by AIbitat.continue() after it pops the last interrupted chat and checks hasReachedMaximumRounds(from, to). hasReachedMaximumRounds returns true when the message history between the two nodes is >= maxRounds (default 100). This is a hard stop to prevent infinite agent-to-agent conversation loops.

Source

Thrown at server/utils/agents/aibitat/index.js:1333

   * Provide a feedback where it was interrupted if you want to.
   *
   * @param feedback The feedback to the interruption if any.
   * @param attachments Optional attachments (images) to include with the feedback.
   * @returns
   */
  async continue(feedback, attachments = []) {
    const lastChat = this._chats.at(-1);
    if (!lastChat || lastChat.state !== "interrupt") {
      throw new Error("No chat to continue");
    }

    // remove the last chat's that was interrupted
    this._chats.pop();

    const { from, to } = lastChat;

    if (this.hasReachedMaximumRounds(from, to)) {
      throw new Error("Maximum rounds reached");
    }

    if (feedback) {
      const message = {
        from,
        to,
        content: feedback,
        ...(attachments?.length > 0 ? { attachments } : {}),
      };

      // register the message in the chat history
      this.newMessage(message);

      // ask the node to reply
      await this.chat({
        to: message.from,
        from: message.to,
      });

View on GitHub (pinned to 526360e320)

Solutions

  1. Increase maxRounds when constructing the AIbitat instance or channel config if the task legitimately needs more turns.
  2. Inspect the chat history between the two nodes to find why the loop is not converging.
  3. Restructure the agent routing so the task completes in fewer rounds.
  4. Start a new conversation once the limit is hit rather than continuing.

Example fix

// before - default maxRounds (100) too low for the task
new AIbitat({ maxRounds: 100 });
// after - raise the budget for long multi-agent flows
new AIbitat({ maxRounds: 250 });
Defensive patterns

Strategy: validation

Validate before calling

// before calling continue(), check the round budget
function canContinue(aibitat, from, to) {
  if (aibitat.hasReachedMaximumRounds(from, to))
    throw new Error(`Round budget exhausted for ${from} <-> ${to}; raise maxRounds or restructure`);
}

Try / catch

try {
  await aibitat.continue(feedback);
} catch (error) {
  if (error.message === "Maximum rounds reached") {
    // start a new conversation or increase maxRounds
  } else throw error;
}

Prevention

When it happens

Trigger: Calling continue() on a conversation between two nodes whose history length has reached or exceeded maxRounds (default 100, configurable per AIbitat instance or channel config). Each continue()/chat() between the same from/to pair grows the history.

Common situations: Two agents stuck passing a task back and forth without resolution; a complex multi-agent workflow with a low maxRounds override; a long-running session that legitimately needs more rounds than the default budget.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/0d1bca1162b34ac7. Report an issue: GitHub.