{"record":{"id":"7a43b5344236db53","repo":"moeru-ai/airi","slug":"action-queue-full-queuesize-max-queued-contr","errorCode":null,"errorMessage":"Action queue full (${queueSize}/${MAX_QUEUED_CONTROL_ACTIONS}). Use stop() or wait for completion.","messagePattern":"Action queue full \\((.+?)/(.+?)\\)\\. Use stop\\(\\) or wait for completion\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"integrations/minecraft/src/cognitive/conscious/brain.ts","lineNumber":1173,"sourceCode":"    const cleared = this.pendingControlActions.splice(0, this.pendingControlActions.length)\n    for (const entry of cleared) {\n      entry.state = state\n      entry.finishedAt = clearedAt\n      entry.error = state === 'failed' ? entry.error : entry.error ?? 'Cleared from action queue'\n      this.pushRecentControlAction(entry)\n    }\n    this.touchActionQueue()\n    return cleared.length\n  }\n\n  private async enqueueControlAction(\n    bot: MineflayerWithAgents,\n    action: ActionInstruction,\n    sourceTurnId: number,\n  ): Promise<unknown> {\n    const queueSize = this.pendingControlActions.length + (this.activeControlAction ? 1 : 0)\n    if (queueSize >= MAX_QUEUED_CONTROL_ACTIONS) {\n      throw new Error(`Action queue full (${queueSize}/${MAX_QUEUED_CONTROL_ACTIONS}). Use stop() or wait for completion.`)\n    }\n\n    const entry: ControlActionQueueEntry = {\n      id: ++this.nextControlActionId,\n      action: {\n        tool: action.tool,\n        params: this.cloneActionParams(action.params),\n      },\n      sourceTurnId,\n      state: 'pending',\n      enqueuedAt: Date.now(),\n    }\n    this.pendingControlActions.push(entry)\n    this.touchActionQueue()\n\n    this.appendLlmLog({\n      turnId: sourceTurnId,\n      kind: 'scheduler',","sourceCodeStart":1155,"sourceCodeEnd":1191,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/integrations/minecraft/src/cognitive/conscious/brain.ts#L1155-L1191","documentation":"Thrown by Brain.enqueueControlAction when the pending control-action queue plus any active action reaches MAX_QUEUED_CONTROL_ACTIONS (defined as 5 at brain.ts:229). Async control actions are serialized through a single worker, so this guard prevents unbounded backlog. The message tells the caller to stop() or wait.","triggerScenarios":"The LLM/cognitive loop issues async actions faster than the worker drains them (e.g. repeated collectBlocks while pathfinding is slow); a stuck active action never completes, filling the queue with subsequent turns; stop() was not called before a new burst of actions.","commonSituations":"Long-running navigation/mining actions stacking up while the planner keeps emitting new ones; a deadlocked pathfinder holding the active slot; insufficient backpressure between the planner and the action worker.","solutions":["Call brain.stop() to cancel the active action and clear pending ones before issuing new work.","Wait for the current action to complete (await the enqueueControlAction promise / poll getActionQueueSnapshot).","Throttle the planner so it does not enqueue a new async action while queueSize is near the cap.","Investigate why the active action is not completing if the queue stays full (pathfinder deadlock, stuck entity)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function canEnqueue(brain) {\n  const counts = brain.getActionQueueSnapshot().counts\n  const size = counts.pending + (counts.active ? 1 : 0)\n  return size < MAX_QUEUED_CONTROL_ACTIONS\n}\nif (!canEnqueue(brain)) await brain.stop()  // or await completion","typeGuard":"function queueHasCapacity(brain, max = 5) {\n  const c = brain.getActionQueueSnapshot().counts\n  return (c.pending + (c.active ? 1 : 0)) < max\n}","tryCatchPattern":"try {\n  await brain.enqueueControlAction(bot, action, turnId)\n} catch (e) {\n  if (e.message.startsWith('Action queue full'))\n    await brain.stop()  // clear backlog then retry\n  throw e\n}","preventionTips":["Call stop() before issuing a new burst of async actions.","Apply backpressure in the planner: do not enqueue while the queue is near cap.","Investigate stuck active actions that keep the queue full."],"tags":["minecraft","brain","queue","scheduler","backpressure"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}