%
\documentclass[english,11pt]{book}
\usepackage[fleqn]{amsmath} %
\usepackage{amsthm} %
\usepackage{amssymb}
\usepackage[explicit]{titlesec}
\usepackage{titletoc} %
\usepackage[skins,theorems,most]{tcolorbox} %
\newtcolorbox{parabox}{
boxsep=0pt,
boxrule=0.7pt,
width=\textwidth, % to vary with length of text
right=2pt,
colframe=black,
colback=yellow}
\titleformat{\paragraph}{}{}{0pt} %
{\begin{parabox}
{#1} %
\end{parabox}}
\renewcommand{\theparagraph}{[\hspace{0.9pt}\roman{paragraph}\hspace{1.0pt}]} %
\titlespacing{name=\paragraph}{4pt}{2pt}{0pt}[0pt] % from left, before (vert), after (vert), [0pt]
\begin{document}
\paragraph{The box to be of variable length and stop here {\color{red}$|||$}}
\vspace{-6pt}
\noindent A full length line of ordinary text - extended to the full width of the page $>$
\end{document}