CopilotKit/CopilotKit · error · CopilotKitMisuseError

Failed to create interrupt: ${error instanceof Error ? error

Error message

Failed to create interrupt: ${error instanceof Error ? error.message : String(error)}

What it means

copilotKitInterrupt() wraps its whole interrupt-construction flow in try/catch and rethrows any internal failure as a CopilotKitMisuseError with the original error message appended. It usually indicates a LangGraph interrupt() call failing — most commonly because the code is not running inside a LangGraph node execution context.

Source

Thrown at packages/sdk-js/src/langgraph/utils.ts:661

      });
      interruptValues = {
        action,
        args: args ?? {},
      };
    }

    const response = interrupt({
      __copilotkit_interrupt_value__: interruptValues,
      __copilotkit_messages__: [interruptMessage],
    });
    answer = response[response.length - 1].content;

    return {
      answer,
      messages: response,
    };
  } catch (error) {
    throw new CopilotKitMisuseError({
      message: `Failed to create interrupt: ${error instanceof Error ? error.message : String(error)}`,
    });
  }
}

View on GitHub (pinned to 68fbe97d87)

Solutions

  1. Move the copilotKitInterrupt call inside a LangGraph node that executes during graph.run/stream
  2. Ensure the graph is invoked with a config containing a thread_id (checkpointer enabled)
  3. Inspect the appended inner message to identify the underlying cause

Example fix

// before
const handler = () => copilotKitInterrupt({ action: "confirm" }); // outside graph
// after
const node = () => copilotKitInterrupt({ action: "confirm" });
const graph = new StateGraph(...).addNode("ask", node);
await graph.invoke(input, { configurable: { thread_id: "t1" } });
Defensive patterns

Strategy: try-catch

Validate before calling

null

Try / catch

try {
  return copilotKitInterrupt(opts);
} catch (e) {
  if (e instanceof CopilotKitMisuseError && e.message.startsWith("Failed to create interrupt")) {
    // log inner cause; likely called outside a LangGraph node
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling copilotKitInterrupt() outside a running LangGraph graph/node execution, or when the underlying interrupt() machinery (thread/config missing) throws.

Common situations: Invoking copilotKitInterrupt from a plain function, API handler, or during module init instead of inside a graph node; missing thread_id in the LangGraph config.

Related errors


AI-assisted analysis of CopilotKit/CopilotKit@68fbe97d87 (2026-08-27). Data as JSON: /api/errors/6c83418850c443dc. Report an issue: GitHub.