ToolSearchController class

Controller for tool search state and operations.

Manages the tool search indexing, mode detection, and deferred tool discovery lifecycle using Sint reactive state management.

Inheritance

Constructors

ToolSearchController({Map<String, String>? envConfig})

Properties

deferredToolTokenCount → Rxn<int>
Cached deferred tool token count (null if not yet computed).
final
discoveredToolNames → RxSet<String>
Set of discovered tool names from message history.
final
hashCode int
The hash code for this object.
no setterinherited
initialized bool
Checks whether the controller has already been initialized.
no setterinherited
isClosed bool
Checks whether the controller has already been closed.
no setterinherited
isDisposed bool
no setterinherited
listenersLength int
no setterinherited
mode → Rx<ToolSearchMode>
Current tool search mode.
final
optimisticEnabled → RxBool
Whether tool search has been optimistically enabled.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(SintStateUpdate listener) → Disposer
Register a closure to be called when the object notifies its listeners.
inherited
addListenerId(Object? key, SintStateUpdate listener) → Disposer
inherited
calculateDeferredToolDescriptionChars(List<ToolDefinition> tools) int
Calculate total deferred tool description size in characters.
containsListener(SintStateUpdate listener) bool
inherited
debounce<T>(RxInterface<T> rx, void callback(T), {Duration duration = const Duration(milliseconds: 400)}) → void
Calls callback after rx stops changing for duration. Useful for search-as-you-type, form validation, etc.
inherited
dispose() → void
inherited
ever<T>(RxInterface<T> rx, void callback(T)) → void
Calls callback every time rx changes. Auto-cancels on controller disposal.
inherited
extractDiscoveredToolNames(List<ToolSearchMessage> messages) Set<String>
Extract tool names from tool_reference blocks in message history.
getAutoToolSearchCharThreshold({required String model, required int contextWindow}) int
Get the character threshold for auto-enabling tool search for a given model.
getAutoToolSearchTokenThreshold({required String model, required int contextWindow}) int
Get the token threshold for auto-enabling tool search for a given model.
getDeferredToolsDelta({required List<ToolDefinition> tools, required List<ToolSearchMessage> messages, DeferredToolsDeltaScanContext? scanContext}) DeferredToolsDelta?
Diff the current deferred-tool pool against what has been announced.
getToolSearchMode() ToolSearchMode
Determines the tool search mode from configuration.
interval<T>(RxInterface<T> rx, void callback(T), {Duration duration = const Duration(seconds: 1)}) → void
Calls callback at most once per duration, ignoring intermediate changes. Useful for rate-limiting UI updates.
inherited
isDeferredToolsDeltaEnabled() bool
Whether deferred tools delta attachments are enabled.
isToolSearchEnabled({required String model, required List<ToolDefinition> tools, required int contextWindow, String? source}) Future<bool>
Check if tool search is enabled for a specific request.
isToolSearchEnabledOptimistic() bool
Optimistic check -- returns true if tool search could potentially be enabled, without checking dynamic factors like model support or threshold.
isToolSearchToolAvailable(List<ToolDefinition> tools) bool
Check if ToolSearchTool is available in the provided tools list.
modelSupportsToolReference(String model) bool
Check if a model supports tool_reference blocks (required for tool search).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
once<T>(RxInterface<T> rx, void callback(T)) → void
Calls callback only the first time rx changes, then cancels.
inherited
onClose() → void
Called before onDelete method. onClose might be used to dispose resources used by the controller. Like closing events, or streams before the controller is destroyed. Or dispose objects that can potentially create some memory leaks, like TextEditingControllers, AnimationControllers. Might be useful as well to persist some data on disk.
inherited
onDelete() → void
inherited
onInit() → void
Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.
override
onReady() → void
Called 1 frame after onInit(). It is the perfect place to enter navigation events, like snackbar, dialogs, or a new route, or async request.
inherited
onStart() → void
Called at the exact moment the widget is allocated in memory. It uses an internal "callable" type, to avoid any @overrides in subclasses. This method should be internal and is required to define the lifetime cycle of the subclass.
inherited
refresh() → void
inherited
refreshGroup(Object id) → void
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that the object notifies.
inherited
removeListenerId(Object id, VoidCallback listener) → void
inherited
reportAdd(VoidCallback disposer) → void
inherited
reportRead() → void
inherited
toString() String
A string representation of this object.
inherited
update([List<Object>? ids, bool condition = true]) → void
Notifies listeners to update the UI.
inherited
updateEnvConfig(Map<String, String> config) → void
Update environment config at runtime.
updateUnsupportedModelPatterns(List<String> patterns) → void
Update unsupported model patterns from remote configuration.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

isToolReferenceBlock(Map<String, dynamic>? obj) bool
Check if an object map represents a tool_reference block.
isToolReferenceWithName(Map<String, dynamic>? obj) bool
Check if an object is a tool_reference with a tool_name.
isToolResultBlockWithContent(Map<String, dynamic>? obj) bool
Check if an object is a tool_result block with array content.