isToolSearchEnabledOptimistic method
Optimistic check -- returns true if tool search could potentially be enabled, without checking dynamic factors like model support or threshold.
Implementation
bool isToolSearchEnabledOptimistic() {
final currentMode = getToolSearchMode();
if (currentMode == ToolSearchMode.standard) {
if (!_loggedOptimistic) {
_loggedOptimistic = true;
_logDebug(
'[ToolSearch:optimistic] mode=$currentMode, '
'ENABLE_TOOL_SEARCH=${_envConfig['ENABLE_TOOL_SEARCH']}, result=false',
);
}
return false;
}
// Third-party API gateways may not support tool_reference.
final enableToolSearch = _envConfig['ENABLE_TOOL_SEARCH'];
if ((enableToolSearch == null || enableToolSearch.isEmpty) &&
_getApiProvider() == 'firstParty' &&
!_isFirstPartyAnthropicBaseUrl()) {
if (!_loggedOptimistic) {
_loggedOptimistic = true;
_logDebug(
'[ToolSearch:optimistic] disabled: ANTHROPIC_BASE_URL='
'${_envConfig['ANTHROPIC_BASE_URL']} is not a first-party host.',
);
}
return false;
}
if (!_loggedOptimistic) {
_loggedOptimistic = true;
_logDebug(
'[ToolSearch:optimistic] mode=$currentMode, '
'ENABLE_TOOL_SEARCH=${_envConfig['ENABLE_TOOL_SEARCH']}, result=true',
);
}
return true;
}