pub fn find_tool_start(s: &str) -> Option<usize>Expand description
Byte offset of the earliest complete tool-call stanza opening in s, if any.
Port of the C server’s find_any_tool_start: the wrapper opener under any
accepted marker, its dropped-leading-bar typo, and the bare <tool_calls>
the model sometimes emits. Deliberately not the bare invoke opener the
streaming detector also accepts — this feeds mid-generation recovery, where
acting on a weaker signal costs a forced injection.
Matching is on accumulated text, so how the marker was tokenized does not matter; an incomplete opening does not match, and the caller is expected to re-scan from far enough back that one split across tokens is still seen.