use super::{LogitsContext, LogitsProcessor, ProcessorOutcome};
use crate::scheduler::ActiveSeq;
pub struct PinToToolCallStart;
impl LogitsProcessor for PinToToolCallStart {
fn apply(
&self,
logits: &mut [f32],
a: &mut ActiveSeq,
ctx: &LogitsContext,
) -> ProcessorOutcome {
if a.think_just_ended
&& a.require_tool_call
&& !a.tool_call_opened
&& !a.inside_thinking
&& let Some(start_tok) = ctx.tool_call_start_token
{
let idx = start_tok as usize;
if idx < logits.len() {
for logit in logits.iter_mut() {
*logit = f32::NEG_INFINITY;
}
logits[idx] = 0.0;
tracing::debug!(
"Forced tool_call_start_token after </think> (require_tool_call set)"
);
}
}
ProcessorOutcome::Continue
}
fn name(&self) -> &'static str {
"pin_to_tool_call_start"
}
}