
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
Given the function $f(x)=\sqrt{3} \sin \omega x \cdot \cos \omega x + \cos^2 \omega x - \frac{1}{2} (\omega > 0)$, its smallest positive period is $\frac{\pi}{2}$.

$(1)$ Find the expression for $f(x)$;

$(2)$ After shifting the graph of $f(x)$ to the right by $\frac{\pi}{8}$ units, and then stretching the x-coordinates of the points on the obtained graph by $2$ times (the y-coordinates remain unchanged), we get the graph of the function $y=g(x)$. If the equation $g(x)+k=0$ has exactly one real solution in the interval $\left[0, \frac{\pi}{2}\right]$, find the range of the real number $k$.

Present the answer in LaTex format: \boxed{Your answer}
user