sophia: cursor cache iteration fix