Creates a new instance of the Pregel graph with updated configuration. This method follows the immutable pattern - instead of modifying the current instance, it returns a new instance with the merged configuration.
withConfig<
TTransformers extends readonly () =
> StreamTransformer<any>[] = []>(
config: Omit<LangGraphRunnableConfig<Record<string, any>>, "store" | "writer" | "interrupt"> __type
): CompiledGraph<N, S, U, ExtractStateType<C, C>, ExtractUpdateType<I, ExtractStateType<I, I>>, ExtractStateType<O, O>, NodeReturnType, CommandInstance<InferInterruptResumeType<InterruptType, false>, { [K in string | number | symbol]: U[K] }, N>, InferWriterType<WriterType>, readonly [TStreamTransformers, TTransformers]>| Name | Type | Description |
|---|---|---|
config* | Omit<LangGraphRunnableConfig<Record<string, any>>, "store" | "writer" | "interrupt"> & __type | The configuration to merge with the current configuration |
// Create a new instance with debug enabled
const debugGraph = graph.withConfig({ debug: true });
// Create a new instance with a specific thread ID
const threadGraph = graph.withConfig({
configurable: { thread_id: "123" }
});