fix(core,langchain): override instanceof where applicable (#11344)