Skip to content

Commit 89b88b4

Browse files
jongallowayCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <[email protected]>
1 parent 810aab2 commit 89b88b4

File tree

3 files changed

+7
-27
lines changed

3 files changed

+7
-27
lines changed

src/NLWebNet/Extensions/ServiceCollectionExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public static IServiceCollection AddNLWebNet(this IServiceCollection services, A
4040
services.AddScoped<IToolSelector, ToolSelector>();
4141

4242
// Register Advanced Tool System
43-
services.AddAdvancedToolSystem();
43+
if (!services.Any(service => service.ServiceType == typeof(IAdvancedToolService)))
44+
{
45+
services.AddAdvancedToolSystem();
46+
}
4447

4548
// Register MCP services
4649
services.AddScoped<IMcpService, McpService>(); // Register default data backend (can be overridden)

src/NLWebNet/Services/DetailsToolHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public override async Task<NLWebResponse> ExecuteAsync(NLWebRequest request, Can
4444

4545
// Create details-focused query
4646
var detailsQuery = $"{subject} overview definition explanation details";
47-
var processedQuery = await QueryProcessor.ProcessQueryAsync(request, cancellationToken);
4847

4948
// Generate detailed results
5049
var searchResults = await ResultGenerator.GenerateListAsync(detailsQuery, request.Site, cancellationToken);

src/NLWebNet/Services/NLWebService.cs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -117,32 +117,10 @@ public async Task<NLWebResponse> ProcessRequestAsync(NLWebRequest request, Cance
117117
_logger.LogDebug("ProcessQueryAsync complete for QueryId={QueryId}", queryId);
118118

119119
// Check if tool execution is available and enabled
120-
if (_toolSelector != null && _toolExecutor != null && _options.ToolSelectionEnabled)
120+
var toolResponse = await HandleToolSelectionAsync(request, queryId, cancellationToken);
121+
if (toolResponse != null)
121122
{
122-
_logger.LogDebug("Tool execution enabled, checking if tool selection is needed for QueryId={QueryId}", queryId);
123-
124-
if (_toolSelector.ShouldSelectTool(request))
125-
{
126-
_logger.LogDebug("Tool selection needed for QueryId={QueryId}", queryId);
127-
128-
var selectedTool = await _toolSelector.SelectToolAsync(request, cancellationToken);
129-
if (!string.IsNullOrEmpty(selectedTool))
130-
{
131-
_logger.LogInformation("Tool '{Tool}' selected for QueryId={QueryId}, executing tool", selectedTool, queryId);
132-
133-
try
134-
{
135-
var toolResponse = await _toolExecutor.ExecuteToolAsync(request, selectedTool, cancellationToken);
136-
_logger.LogInformation("[END] Tool execution completed for QueryId={QueryId} with tool '{Tool}'", queryId, selectedTool);
137-
return toolResponse;
138-
}
139-
catch (Exception toolEx)
140-
{
141-
_logger.LogError(toolEx, "Tool execution failed for QueryId={QueryId} with tool '{Tool}', falling back to standard processing", queryId, selectedTool);
142-
// Fall through to standard processing
143-
}
144-
}
145-
}
123+
return toolResponse;
146124
}
147125

148126
_logger.LogDebug("Using standard processing pipeline for QueryId={QueryId}", queryId);

0 commit comments

Comments
 (0)