using System.Collections.Generic; using System.Linq; namespace AIStudio.Tools.ToolCallingSystem; public static class ToolSelectionRules { public const string WEB_SEARCH_TOOL_ID = "web_search"; public const string READ_WEB_PAGE_TOOL_ID = "read_web_page"; public static HashSet NormalizeSelection(IEnumerable selectedToolIds) { var normalized = selectedToolIds.ToHashSet(StringComparer.Ordinal); if (normalized.Contains(WEB_SEARCH_TOOL_ID)) normalized.Add(READ_WEB_PAGE_TOOL_ID); return normalized; } public static bool IsRequiredBySelectedTools(string toolId, IEnumerable selectedToolIds) { var normalized = NormalizeSelection(selectedToolIds); return toolId == READ_WEB_PAGE_TOOL_ID && normalized.Contains(WEB_SEARCH_TOOL_ID); } }