{"record":{"id":"6c83418850c443dc","repo":"CopilotKit/CopilotKit","slug":"failed-to-create-interrupt-error-instanceof-err","errorCode":null,"errorMessage":"Failed to create interrupt: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Failed to create interrupt: (.+?)","errorType":"exception","errorClass":"CopilotKitMisuseError","httpStatus":null,"severity":"error","filePath":"packages/sdk-js/src/langgraph/utils.ts","lineNumber":661,"sourceCode":"      });\n      interruptValues = {\n        action,\n        args: args ?? {},\n      };\n    }\n\n    const response = interrupt({\n      __copilotkit_interrupt_value__: interruptValues,\n      __copilotkit_messages__: [interruptMessage],\n    });\n    answer = response[response.length - 1].content;\n\n    return {\n      answer,\n      messages: response,\n    };\n  } catch (error) {\n    throw new CopilotKitMisuseError({\n      message: `Failed to create interrupt: ${error instanceof Error ? error.message : String(error)}`,\n    });\n  }\n}\n","sourceCodeStart":643,"sourceCodeEnd":666,"githubUrl":"https://github.com/CopilotKit/CopilotKit/blob/68fbe97d87420bd84e8196965c71bd6e394a3f7a/packages/sdk-js/src/langgraph/utils.ts#L643-L666","documentation":"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.","triggerScenarios":"Calling copilotKitInterrupt() outside a running LangGraph graph/node execution, or when the underlying interrupt() machinery (thread/config missing) throws.","commonSituations":"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.","solutions":["Move the copilotKitInterrupt call inside a LangGraph node that executes during graph.run/stream","Ensure the graph is invoked with a config containing a thread_id (checkpointer enabled)","Inspect the appended inner message to identify the underlying cause"],"exampleFix":"// before\nconst handler = () => copilotKitInterrupt({ action: \"confirm\" }); // outside graph\n// after\nconst node = () => copilotKitInterrupt({ action: \"confirm\" });\nconst graph = new StateGraph(...).addNode(\"ask\", node);\nawait graph.invoke(input, { configurable: { thread_id: \"t1\" } });","handlingStrategy":"try-catch","validationCode":"null","typeGuard":null,"tryCatchPattern":"try {\n  return copilotKitInterrupt(opts);\n} catch (e) {\n  if (e instanceof CopilotKitMisuseError && e.message.startsWith(\"Failed to create interrupt\")) {\n    // log inner cause; likely called outside a LangGraph node\n  }\n  throw e;\n}","preventionTips":["Only call copilotKitInterrupt inside graph nodes","Always invoke graphs with a thread_id config when interrupts are used"],"tags":["sdk-js","langgraph","interrupt","runtime-context"],"backgroundTag":"missing-runtime-context","analyzedSha":"68fbe97d87420bd84e8196965c71bd6e394a3f7a","analyzedAt":"2026-08-27T04:03:26.537Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}