Skip to main content

Module tool_watcher

Module tool_watcher 

Source
Expand description

Tool-call / region watcher.

Mirrors libcodec’s codec_tool_watcher, the .NET ToolWatcher, and @codecai/web’s ToolWatcher — same state-machine semantics. Detects delimited regions (tool calls, reasoning blocks, vision spans, sandbox regions, channel headers) in a token-ID stream without ever decoding. The hot loop is a u32 compare against two cached IDs; no vocab read, no detokenize call, no string allocation.

State survives across ToolWatcher::feed calls — a region split between network frames buffers internally until the end marker arrives.

Structs§

ToolWatcher
Stateful watcher for delimited regions in a token-ID stream.
WatcherEvent
One event from ToolWatcher::feed.

Enums§

ToolWatcherError
Errors raised when constructing a ToolWatcher.
WatcherEventKind
Kind of event emitted by ToolWatcher::feed.