
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 $f(x)=-\sin^2x+a\sin x+b\cos x$ is an even function, and $f(\pi)=-1$  
$(1)$ Find $f(x)$;  
$(2)$ Given $\theta\in(0, \frac{\pi}{2})$, and $\tan \theta= \sqrt{2}$, if for any $x\in[-\frac{\pi}{2},0]$, the inequality $a\leqslant f(2x+\theta)+m\leqslant 4b$ always holds, find the range of $m$.

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